Skip to content

Commit 204e92a

Browse files
author
mancausoft
committed
debug: dump dir-iter state under -o debug
When -o debug is set, log the FID being read in ops_readdir, the HEAD's filechar/efblk/hiblk/ffb/rtype/rattr right after accessfile, the iterate_dir block-by-block progress and every dir record / entry emitted to filler. Lets us trace why an MFD lookup yields an empty listing on a real Alpha system disk.
1 parent 8428285 commit 204e92a

2 files changed

Lines changed: 84 additions & 6 deletions

File tree

src/lookup.c

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ vmscond_t ods2_iterate_dir( struct FCB *dir_fcb, int latest_only,
229229

230230
uint32_t efblk = F11SWAP( dir_fcb->head->fh2$w_recattr.fat$l_efblk );
231231
uint16_t ffb = F11WORD( dir_fcb->head->fh2$w_recattr.fat$w_ffbyte );
232+
if( ods2_rt.debug )
233+
fprintf( stderr,
234+
"fuse-ods2: iterate_dir efblk=%u ffb=%u latest_only=%d\n",
235+
(unsigned)efblk, (unsigned)ffb, latest_only );
232236
if( efblk == 0 )
233237
return SS$_NORMAL;
234238
if( ffb == 0 )
@@ -257,23 +261,52 @@ vmscond_t ods2_iterate_dir( struct FCB *dir_fcb, int latest_only,
257261

258262
char *p = buf;
259263
char *end = buf + BLOCKSIZE;
264+
if( ods2_rt.debug )
265+
fprintf( stderr,
266+
"fuse-ods2: iterate_dir: block %u loaded blocks=%u\n",
267+
(unsigned)blk, (unsigned)blocks );
260268

261269
while( p + sizeof(struct dir$r_rec) <= end ) {
262270
struct dir$r_rec *dr = (struct dir$r_rec *)p;
263271
uint16_t size = F11WORD( dr->dir$w_size );
264272

265273
/* End-of-block sentinel: 0xffff. */
266-
if( size == 0xffff )
274+
if( size == 0xffff ) {
275+
if( ods2_rt.debug )
276+
fprintf( stderr,
277+
"fuse-ods2: iterate_dir: end-of-block at offs=%ld\n",
278+
(long)(p - buf) );
267279
break;
268-
if( size + 2 > BLOCKSIZE )
280+
}
281+
if( size + 2 > BLOCKSIZE ) {
282+
if( ods2_rt.debug )
283+
fprintf( stderr,
284+
"fuse-ods2: iterate_dir: record size=%u too big at offs=%ld\n",
285+
(unsigned)size, (long)(p - buf) );
269286
break;
270-
if( p + size + 2 > end )
287+
}
288+
if( p + size + 2 > end ) {
289+
if( ods2_rt.debug )
290+
fprintf( stderr,
291+
"fuse-ods2: iterate_dir: record overruns block at offs=%ld size=%u\n",
292+
(long)(p - buf), (unsigned)size );
271293
break;
294+
}
272295

273296
uint8_t namecount = dr->dir$b_namecount;
274297
char *namebase = dr->dir$t_name;
275-
if( namebase + namecount > end )
298+
if( namebase + namecount > end ) {
299+
if( ods2_rt.debug )
300+
fprintf( stderr,
301+
"fuse-ods2: iterate_dir: name overruns block (count=%u)\n",
302+
(unsigned)namecount );
276303
break;
304+
}
305+
if( ods2_rt.debug )
306+
fprintf( stderr,
307+
"fuse-ods2: iterate_dir: record offs=%ld size=%u namecount=%u name='%.*s'\n",
308+
(long)(p - buf), (unsigned)size,
309+
(unsigned)namecount, namecount, namebase );
277310

278311
/* Skip a record whose name we already emitted (split). */
279312
int same_as_last = ( latest_only

src/ops.c

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ static int readdir_cb( const char *name, int namelen, int version,
143143
ods2_rt.allversions, ods2_rt.lower,
144144
display, sizeof display );
145145

146+
if( ods2_rt.debug )
147+
fprintf( stderr,
148+
"fuse-ods2: readdir entry: '%.*s';%d -> '%s'\n",
149+
namelen, name, version, display );
150+
146151
memset( &st, 0, sizeof st );
147152
st.st_ino = ods2_fid_to_inode( fid );
148153
/* We don't know if it's a directory without reading the HEAD; let
@@ -165,16 +170,51 @@ int ods2_readdir( const char *path, void *buf, fuse_fill_dir_t filler,
165170
vmscond_t sts;
166171

167172
sts = ods2_path_to_fid( path, &fid, NULL );
168-
if( !$SUCCESSFUL(sts) )
173+
if( !$SUCCESSFUL(sts) ) {
174+
if( ods2_rt.debug )
175+
fprintf( stderr,
176+
"fuse-ods2: readdir('%s') path_to_fid failed (%08x)\n",
177+
path, (unsigned)(sts & STS$M_COND_ID) );
169178
return -ENOENT;
179+
}
180+
181+
if( ods2_rt.debug )
182+
fprintf( stderr,
183+
"fuse-ods2: readdir('%s') fid=(%u,%u,%u,%u)\n",
184+
path,
185+
(unsigned)F11WORD(fid.fid$w_num),
186+
(unsigned)F11WORD(fid.fid$w_seq),
187+
(unsigned)fid.fid$b_rvn,
188+
(unsigned)fid.fid$b_nmx );
170189

171190
struct FCB *dfcb = NULL;
172191
sts = accessfile( ods2_vcb, &fid, &dfcb, 0 );
173-
if( !$SUCCESSFUL(sts) )
192+
if( !$SUCCESSFUL(sts) ) {
193+
if( ods2_rt.debug )
194+
fprintf( stderr,
195+
"fuse-ods2: readdir accessfile failed (%08x)\n",
196+
(unsigned)(sts & STS$M_COND_ID) );
174197
return -EIO;
198+
}
199+
200+
if( ods2_rt.debug ) {
201+
struct HEAD *h = dfcb->head;
202+
fprintf( stderr,
203+
"fuse-ods2: readdir filechar=%08x efblk=%u hiblk=%u ffb=%u "
204+
"rtype=0x%02x rattr=0x%02x\n",
205+
(unsigned)F11LONG(h->fh2$l_filechar),
206+
(unsigned)F11SWAP(h->fh2$w_recattr.fat$l_efblk),
207+
(unsigned)F11SWAP(h->fh2$w_recattr.fat$l_hiblk),
208+
(unsigned)F11WORD(h->fh2$w_recattr.fat$w_ffbyte),
209+
(unsigned)h->fh2$w_recattr.fat$b_rtype,
210+
(unsigned)h->fh2$w_recattr.fat$b_rattrib );
211+
}
175212

176213
/* Reject non-directories. */
177214
if( !(F11LONG( dfcb->head->fh2$l_filechar ) & FH2$M_DIRECTORY) ) {
215+
if( ods2_rt.debug )
216+
fprintf( stderr,
217+
"fuse-ods2: readdir: target is not a directory\n" );
178218
deaccessfile( dfcb );
179219
return -ENOTDIR;
180220
}
@@ -188,6 +228,11 @@ int ods2_readdir( const char *path, void *buf, fuse_fill_dir_t filler,
188228
ods2_rt.allversions ? 0 : 1,
189229
readdir_cb, &ctx );
190230

231+
if( ods2_rt.debug )
232+
fprintf( stderr,
233+
"fuse-ods2: readdir iterate done sts=%08x\n",
234+
(unsigned)(sts & STS$M_COND_ID) );
235+
191236
deaccessfile( dfcb );
192237
return $SUCCESSFUL(sts) ? 0 : -EIO;
193238
}

0 commit comments

Comments
 (0)