NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/61077: bin/: incremental dump of a byte-swapped FFS leaves out changed files



>Number:         61077
>Category:       bin
>Synopsis:       incremental dump of a byte-swapped FFS leaves out changed files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 25 17:55:00 +0000 2026
>Originator:     Showta Ishizaki
>Release:        NetBSD 11.1, also trunk of 2026-11-25
>Organization:
>Environment:
System: NetBSD 11.1 amd64
Architecture: x86_64
Machine: amd64

>Description:

An incremental dump of a file system of the other byte order does not
dump the files which have changed.  c_date and c_ddate in the header are
64 bits wide, but main.c and itime.c swap them with iswap32().
traverse.c compares the times of the files with the 64-bit swap of the
result, which is far in the future.  The dates on the tape are wrong too,
restore prints (null) for them.

>How-To-Repeat:

On NetBSD 11.1 amd64:

	# vnconfig vnd0 be.img
	# newfs -I -O 1 -B be /dev/rvnd0d
	# mount /dev/vnd0d /mnt; echo x > /mnt/new; umount /mnt
	# dump -1 -a -T "Wed Jan  1 00:00:00 2025" -f d1 /dev/rvnd0d
	# restore -tf d1
	Level 1 dump of an unlisted file system on techne.fml.org:/dev/rvnd0d
	Label: none
	Dump   date: (null)Dumped from: (null)         2	.

With -B le the same gives

	Dump   date: Wed Nov 25 17:48:31 2026
	Dumped from: Wed Jan  1 00:00:00 2025
	         2	.
	         3	./new

>Fix:

The change below has dump treat the dates as 64 bits throughout.  On
trunk of 2026-11-25, in a VM with its clock at 2030, the file is dumped
with it and not without it, and nothing changes for a file system of the
native byte order.

--- sbin/dump/itime.c
+++ sbin/dump/itime.c
@@ -156,9 +156,9 @@ getdumptime(void)
 		    (trueinc && (ddp->dd_level > level))) */
 		if (!trueinc && (ddp->dd_level >= level))
 			continue;
-		if (ddp->dd_ddate <= iswap32(spcl.c_ddate))
+		if (ddp->dd_ddate <= (time_t)iswap64(spcl.c_ddate))
 			continue;
-		spcl.c_ddate = iswap32(ddp->dd_ddate);
+		spcl.c_ddate = iswap64(ddp->dd_ddate);
 		lastlevel = ddp->dd_level;
 	}
 }
@@ -204,7 +204,7 @@ putdumptime(void)
   found:
 	(void) strlcpy(dtwalk->dd_name, fname, sizeof(dtwalk->dd_name));
 	dtwalk->dd_level = level;
-	dtwalk->dd_ddate = iswap32(spcl.c_date);
+	dtwalk->dd_ddate = iswap64(spcl.c_date);
 	dtfound = dtwalk;
 
 	ITITERATE(i, dtwalk) {
--- sbin/dump/main.c
+++ sbin/dump/main.c
@@ -528,15 +528,15 @@ main(int argc, char *argv[])
 	/* true incremental is always a level 10 dump */
 	spcl.c_level = trueinc? iswap32(10): iswap32(level - '0');
 	spcl.c_type = iswap32(TS_TAPE);
-	spcl.c_date = iswap32(spcl.c_date);
-	spcl.c_ddate = iswap32(spcl.c_ddate);
+	spcl.c_date = iswap64(spcl.c_date);
+	spcl.c_ddate = iswap64(spcl.c_ddate);
 	if (!Tflag)
 		getdumptime();		/* /etc/dumpdates snarfed */
 
-	date = iswap32(spcl.c_date);
+	date = iswap64(spcl.c_date);
 	msg("Date of this level %c dump: %s", level,
 		spcl.c_date == 0 ? "the epoch\n" : ctime(&date));
-	date = iswap32(spcl.c_ddate);
+	date = iswap64(spcl.c_ddate);
  	msg("Date of last level %c dump: %s", lastlevel,
 		spcl.c_ddate == 0 ? "the epoch\n" : ctime(&date));
 	msg("Dumping ");
@@ -694,7 +694,7 @@ main(int argc, char *argv[])
 		    (long long)iswap64(spcl.c_tapea), iswap32(spcl.c_volume),
 		    (iswap32(spcl.c_volume) == 1) ? "" : "s");
 	tnow = do_stats();
-	date = iswap32(spcl.c_date);
+	date = iswap64(spcl.c_date);
 	msg("Date of this level %c dump: %s", level,
 		spcl.c_date == 0 ? "the epoch\n" : ctime(&date));
 	msg("Date this dump completed:  %s", ctime(&tnow));




Home | Main Index | Thread Index | Old Index