Hi!
This diff adds a "-U" flag to dump that allows using disklabel
UIDs in /etc/dumpdates. That makes incremental dumps possible when a
disk is roaming between device files.
I'd be happy to receive comments.
Also, sorry for the noise in misc, and thanks to everyone pointing me
in the right direction.
Best regards,
Max
--- sbin/dump/dump.h 2014/06/24 21:35:13 1.1
+++ sbin/dump/dump.h 2014/06/24 21:38:47 1.2
@@ -56,9 +56,11 @@
char *tape; /* name of the tape file */
char *dumpdates; /* name of the file containing dump date information*/
char *temp; /* name of the file for doing rewrite of dumpdates */
+char *duid; /* duid of the disk being dumped */
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int uflag; /* update flag */
+int duidflag; /* use duids in dumpdates flag */
int diskfd; /* disk file descriptor */
int tapefd; /* tape file descriptor */
int pipeout; /* true => output to standard output */
--- sbin/dump/main.c 2014/06/24 21:35:37 1.1
+++ sbin/dump/main.c 2014/06/24 21:38:23 1.2
@@ -112,7 +112,7 @@
usage();
obsolete(&argc, &argv);
- while ((ch = getopt(argc, argv, "0123456789aB:b:cd:f:h:ns:ST:uWw")) !=
-1)
+ while ((ch = getopt(argc, argv, "0123456789aB:b:cd:f:h:ns:ST:UuWw")) !=
-1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@@ -180,6 +180,9 @@
lastlevel = '?';
break;
+ case 'U':
+ duidflag = 1; /* use duids */
+ break;
case 'u': /* update /etc/dumpdates */
uflag = 1;
break;
@@ -370,6 +373,21 @@
(void)gethostname(spcl.c_host, sizeof(spcl.c_host));
spcl.c_level = level - '0';
spcl.c_type = TS_TAPE;
+
+ if ((diskfd = open(disk, O_RDONLY)) < 0) {
+ msg("Cannot open %s\n", disk);
+ exit(X_STARTUP);
+ }
+ if (ioctl(diskfd, DIOCGDINFO, (char *)&lab) < 0)
+ err(1, "ioctl (DIOCGDINFO)");
+ if (duidflag && asprintf(&duid,
+ "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx.%c",
+ lab.d_uid[0], lab.d_uid[1], lab.d_uid[2], lab.d_uid[3],
+ lab.d_uid[4], lab.d_uid[5], lab.d_uid[6], lab.d_uid[7],
+ disk[strlen(disk)-1]) == -1) {
+ msg("Cannot malloc duid\n");
+ exit(X_STARTUP);
+ }
if (!Tflag)
getdumptime(); /* /etc/dumpdates snarfed */
@@ -387,10 +405,6 @@
else
msgtail("to %s\n", tape);
- if ((diskfd = open(disk, O_RDONLY)) < 0) {
- msg("Cannot open %s\n", disk);
- exit(X_STARTUP);
- }
if (ioctl(diskfd, DIOCGPDINFO, (char *)&lab) < 0)
err(1, "ioctl (DIOCGPDINFO)");
sync();
--- sbin/dump/itime.c 2014/06/24 21:35:30 1.1
+++ sbin/dump/itime.c 2014/06/24 21:38:33 1.2
@@ -124,7 +124,7 @@
int i;
char *fname;
- fname = disk;
+ fname = duidflag ? duid : disk;
#ifdef FDEBUG
msg("Looking for name %s in dumpdates = %s for level = %c\n",
fname, dumpdates, level);
@@ -164,7 +164,7 @@
quit("cannot rewrite %s: %s\n", dumpdates, strerror(errno));
fd = fileno(df);
(void) flock(fd, LOCK_EX);
- fname = disk;
+ fname = duidflag ? duid : disk;
free((char *)ddatev);
ddatev = 0;
nddates = 0;
--- include/protocols/dumprestore.h 2014/06/24 22:23:05 1.1
+++ include/protocols/dumprestore.h 2014/06/24 22:52:53 1.3
@@ -152,8 +152,8 @@
#define DR_NEWHEADER 0x0001 /* new format tape header */
#define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */
-#define DUMPOUTFMT "%-16s %c %s" /* for printf */
+#define DUMPOUTFMT "%-18s %c %s" /* for printf */
/* name, level, ctime(date) */
-#define DUMPINFMT "%16s %c %[^\n]\n" /* inverse for scanf */
+#define DUMPINFMT "%18s %c %[^\n]\n" /* inverse for scanf */
#endif /* !_PROTOCOLS_DUMPRESTORE_H_ */
--- sbin/dump/dump.8 2014/06/24 21:35:21 1.1
+++ sbin/dump/dump.8 2014/07/07 23:33:58 1.3
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Nm dump
.Bk -words
-.Op Fl 0123456789acnSuWw
+.Op Fl 0123456789acnSUuWw
.Op Fl B Ar records
.Op Fl b Ar blocksize
.Op Fl d Ar density
@@ -229,6 +229,13 @@
flag is mutually exclusive from the
.Fl u
flag.
+.It Fl U
+Use the
+.Xr disklabel 8
+UID instead of the device name when updating
+.Pa /etc/dumpdates
+and when searching for the date of the latest
+lower-level dump.
.It Fl u
Update the file
.Pa /etc/dumpdates