From 1325027567357d33ce392cc1c93ffb3acfdefbbb Mon Sep 17 00:00:00 2001 From: Thomas Lindner Date: Sun, 12 Feb 2023 18:32:40 +0100 Subject: [PATCH] write empty indirect blocks when dumping to stdout --- dump_inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dump_inode.c b/dump_inode.c index ff49ebc..d195bfd 100644 --- a/dump_inode.c +++ b/dump_inode.c @@ -304,6 +304,12 @@ void dump_file_indirect(union dinode *dp, void *indirblock, int level, gapsize *= NINDIR(sblock); } *filesize -= gapsize; + if (filefd == STDOUT_FILENO) { + memset(datablock, 0, sblock->fs_bsize); + for (int j = 0; j < gapsize / sblock->fs_bsize; j++) { + xwrite(filefd, datablock, sblock->fs_bsize); + } + } continue; } daddr_t blkno = fsbtodb(sblock, fsblkno); @@ -350,6 +356,12 @@ void dump_file(union dinode *dp) { gapsize *= NINDIR(sblock); } filesize -= gapsize; + if (filefd == STDOUT_FILENO) { + memset(datablock, 0, sblock->fs_bsize); + for (int j = 0; j < gapsize / sblock->fs_bsize; j++) { + xwrite(filefd, datablock, sblock->fs_bsize); + } + } continue; } daddr_t blkno = fsbtodb(sblock, DIP(dp, di_ib[i]));