From e343acc2548fba7670977029da8373a0e58fa25a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Aug 2024 10:40:14 -0700 Subject: Added loads and loads of debugging output to myriad. There's an issue somewhere sometimes and streams are being truncated. My guess is a multi-threaded issue. --- src/unstable/myriadfs.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/unstable/myriadfs.cpp') diff --git a/src/unstable/myriadfs.cpp b/src/unstable/myriadfs.cpp index e02620d..b24997a 100644 --- a/src/unstable/myriadfs.cpp +++ b/src/unstable/myriadfs.cpp @@ -476,17 +476,32 @@ Bu::MyriadFs::Dir Bu::MyriadFs::readDir( int32_t iNode ) Bu::MyriadStream is = mStore.openStream( 2 ); Dir lDir; -// sio << "Reading dir, " << iNumChildren << " entries:" << sio.nl; + sio << "Reading dir " << iNode << ", " << iNumChildren << " entries:" << sio.nl; for( int32_t j = 0; j < iNumChildren; j++ ) { - int32_t iChildNode; - ms.read( &iChildNode, 4 ); + int32_t iChildNode = 0; + if( ms.read( &iChildNode, 4 ) < 4 ) + { + throw Bu::MyriadFsException( + "Failed to read iChildNode from directory."); + } + Bu::println(" - iNode = %1").arg( iChildNode ); Stat s; stat( iChildNode, s, is ); uint8_t uLen; - ms.read( &uLen, 1 ); + if( ms.read( &uLen, 1 ) < 1 ) + { + throw Bu::MyriadFsException( + "Failed to read uLen from directory."); + } + Bu::println(" - Name bytes = %1").arg( uLen ); s.sName.setSize( uLen ); - ms.read( s.sName.getStr(), uLen ); + if( ms.read( s.sName.getStr(), uLen ) < uLen ) + { + throw Bu::MyriadFsException( + "Failed to read sName from directory."); + } + Bu::println(" - Name = \"%1\"").arg( s.sName ); lDir.append( s ); // sio << " " << s.sName << sio.nl; @@ -504,6 +519,8 @@ Bu::MyriadStream Bu::MyriadFs::openByInode( int32_t iNode ) case typeDir: case typeSymLink: case typeRegFile: + Bu::println("Opening stream by iNode=%1, myriad stream=%2") + .arg( iNode ).arg( rs.uStreamIndex ); return mStore.openStream( rs.uStreamIndex ); default: -- cgit v1.2.3