On Tue, Sep 22, 2020 at 08:37:22PM +0300, Juha Erkkilä wrote:
>
> > On 22. Sep 2020, at 15.04, Juha Erkkilä <[email protected]> wrote:
> >
> >> On 22. Sep 2020, at 9.00, Otto Moerbeek <[email protected]> wrote:
> >> Maybe by hand, but not by using patch(1), the context differs a bit.
> >>
> >> Next obvious question: did you test if it fixes your problem? That
> >> means, do you get a dump that can be restored again?
> >>
> >> -Otto
> >
> > Thanks Otto for a very good question! So no,
> > do not use that patch as is, it breaks restore
> > as it can not be used to restore any files.
>
> Actually, I tested this again and now it appears
> dump and restore both work correctly. Previously,
> I first tested dump/restore with an empty filesystem,
> then with some files, and it may be that the second
> time I was accidentally testing restore with the first
> dump file.
>
> My tests were only with a small amount of files,
> I will do a better test with proper data (about
> 0.5 terabytes and over 100000 files) and will
> report again here in a next few days.
Lookin through FreeBSD commits I think you want the main.c one as
well, otherwise silent corruption of the dump is still possible.
-Otto
Index: main.c
===================================================================
RCS file: /cvs/src/sbin/dump/main.c,v
retrieving revision 1.61
diff -u -p -r1.61 main.c
--- main.c 28 Jun 2019 13:32:43 -0000 1.61
+++ main.c 24 Sep 2020 10:24:45 -0000
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
int ch, mode;
struct tm then;
struct statfs fsbuf;
- int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
+ int i, anydirskipped, c_count, bflag = 0, Tflag = 0, honorlevel = 1;
ino_t maxino;
time_t t;
int dirlist;
@@ -442,6 +442,9 @@ main(int argc, char *argv[])
#endif
maxino = (ino_t)sblock->fs_ipg * sblock->fs_ncg;
mapsize = roundup(howmany(maxino, NBBY), TP_BSIZE);
+ c_count = howmany(mapsize * sizeof(char), TP_BSIZE);
+ if (c_count > TP_NINDIR)
+ quit("fs is too large for dump!");
usedinomap = calloc((unsigned) mapsize, sizeof(char));
dumpdirmap = calloc((unsigned) mapsize, sizeof(char));
dumpinomap = calloc((unsigned) mapsize, sizeof(char));
Index: tape.c
===================================================================
RCS file: /cvs/src/sbin/dump/tape.c,v
retrieving revision 1.45
diff -u -p -r1.45 tape.c
--- tape.c 28 Jun 2019 13:32:43 -0000 1.45
+++ tape.c 24 Sep 2020 10:24:45 -0000
@@ -330,7 +330,8 @@ flushtape(void)
}
blks = 0;
- if (spcl.c_type != TS_END) {
+ if (spcl.c_type != TS_END && spcl.c_type != TS_CLRI &&
+ spcl.c_type != TS_BITS) {
for (i = 0; i < spcl.c_count; i++)
if (spcl.c_addr[i] != 0)
blks++;