write empty indirect blocks when dumping to stdout

This commit is contained in:
Thomas Lindner 2023-02-12 18:32:40 +01:00
parent 36a07e26e7
commit 1325027567

View file

@ -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]));