Philip Guenther <[email protected]> writes:
> On Fri, Apr 3, 2015 at 7:14 AM, Manuel Giraud <[email protected]> wrote:
>> The following patch replaces the -U flag with a -D flag that forces
>> usage of device name in /etc/dumpdates. The default is now to use DUID.
>>
>> Why?:
>> - dump identification would better be unique
>> - dumpdates is less human readable but not that less if need be
>
> I don't think this the right direction, simply adding a different
> option. To quote what I wrote back in mid March:
> I wonder if it could be made the default by first searching for an
> entry with DUID and lower dump level, and falling back to a device
> name entry if no matching DUID entry was found or if they were just
> for higher dump levels. Once you do a level zero for a DUID it'll
> never look for a device entry again, but during the transition I think
> that strategy would find the same device entries that it would
> otherwise have found.
>
> This will require more invasive work, but will to the Right Thing for
> both device and DUID users and will silently and correctly handle the
> device->DUID transition.
Ok. Here is a patch that tries to do this. I've lightly tested it but
this needs way more eyeballs.
Index: dump.8
===================================================================
RCS file: /cvs/src/sbin/dump/dump.8,v
retrieving revision 1.48
diff -u -p -r1.48 dump.8
--- dump.8 17 Jul 2014 19:58:05 -0000 1.48
+++ dump.8 7 Apr 2015 11:28:33 -0000
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Nm dump
.Bk -words
-.Op Fl 0123456789acnSUuWw
+.Op Fl 0123456789acnSuWw
.Op Fl B Ar records
.Op Fl b Ar blocksize
.Op Fl d Ar density
@@ -229,13 +229,6 @@ The
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
@@ -244,7 +237,9 @@ The format of
.Pa /etc/dumpdates
is human readable, consisting of one
free format record per line:
-filesystem name,
+filesystem name (defaults to
+.Xr disklabel 8
+UID when possible),
increment level
and
.Xr ctime 3
Index: dump.h
===================================================================
RCS file: /cvs/src/sbin/dump/dump.h,v
retrieving revision 1.22
diff -u -p -r1.22 dump.h
--- dump.h 3 Sep 2014 02:34:34 -0000 1.22
+++ dump.h 7 Apr 2015 11:28:33 -0000
@@ -60,7 +60,6 @@ char *duid; /* duid of the disk being d
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int uflag; /* update flag */
-int Uflag; /* use duids in dumpdates flag */
int diskfd; /* disk file descriptor */
int tapefd; /* tape file descriptor */
int pipeout; /* true => output to standard output */
Index: itime.c
===================================================================
RCS file: /cvs/src/sbin/dump/itime.c,v
retrieving revision 1.19
diff -u -p -r1.19 itime.c
--- itime.c 16 Jan 2015 06:39:57 -0000 1.19
+++ itime.c 7 Apr 2015 11:28:33 -0000
@@ -125,7 +125,7 @@ getdumptime(void)
int i;
char *fname;
- fname = Uflag ? duid : disk;
+ fname = duid ? duid : disk;
#ifdef FDEBUG
msg("Looking for name %s in dumpdates = %s for level = %c\n",
fname, dumpdates, level);
@@ -139,7 +139,8 @@ getdumptime(void)
* and older date
*/
ITITERATE(i, ddp) {
- if (strncmp(fname, ddp->dd_name, sizeof(ddp->dd_name)) != 0)
+ if ((strncmp(fname, ddp->dd_name, sizeof(ddp->dd_name)) != 0) &&
+ (strncmp(disk, ddp->dd_name, sizeof(ddp->dd_name)) != 0))
continue;
if (ddp->dd_level >= level)
continue;
@@ -165,7 +166,7 @@ putdumptime(void)
quit("cannot rewrite %s: %s\n", dumpdates, strerror(errno));
fd = fileno(df);
(void) flock(fd, LOCK_EX);
- fname = Uflag ? duid : disk;
+ fname = duid ? duid : disk;
free((char *)ddatev);
ddatev = 0;
nddates = 0;
@@ -176,8 +177,10 @@ putdumptime(void)
quit("fseek: %s\n", strerror(errno));
spcl.c_ddate = 0;
ITITERATE(i, dtwalk) {
- if (strncmp(fname, dtwalk->dd_name,
- sizeof(dtwalk->dd_name)) != 0)
+ if ((strncmp(fname, dtwalk->dd_name,
+ sizeof(dtwalk->dd_name)) != 0) &&
+ (strncmp(disk, dtwalk->dd_name,
+ sizeof(dtwalk->dd_name)) != 0))
continue;
if (dtwalk->dd_level != level)
continue;
Index: main.c
===================================================================
RCS file: /cvs/src/sbin/dump/main.c,v
retrieving revision 1.54
diff -u -p -r1.54 main.c
--- main.c 20 Jan 2015 18:22:20 -0000 1.54
+++ main.c 7 Apr 2015 11:28:33 -0000
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
usage();
obsolete(&argc, &argv);
- while ((ch = getopt(argc, argv, "0123456789aB:b:cd:f:h:ns:ST:UuWw")) !=
-1)
+ while ((ch = getopt(argc, argv, "0123456789aB:b:cd:f:h:ns:ST:uWw")) !=
-1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@@ -183,10 +183,6 @@ main(int argc, char *argv[])
lastlevel = '?';
break;
- case 'U':
- Uflag = 1; /* use duids */
- break;
-
case 'u': /* update /etc/dumpdates */
uflag = 1;
break;
@@ -394,11 +390,9 @@ main(int argc, char *argv[])
}
if (ioctl(diskfd, DIOCGDINFO, (char *)&lab) < 0)
err(1, "ioctl (DIOCGDINFO)");
- if (!Uflag)
- ;
- else if (memcmp(lab.d_uid, &zero_uid, sizeof(lab.d_uid)) == 0) {
- msg("Cannot find DUID of disk %s\n", disk);
- exit(X_STARTUP);
+
+ if (memcmp(lab.d_uid, &zero_uid, sizeof(lab.d_uid)) == 0) {
+ duid = NULL;
} else if (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],
@@ -594,7 +588,7 @@ usage(void)
{
extern char *__progname;
- (void)fprintf(stderr, "usage: %s [-0123456789acnSUuWw] [-B records] "
+ (void)fprintf(stderr, "usage: %s [-0123456789acnSuWw] [-B records] "
"[-b blocksize] [-d density]\n"
"\t[-f file] [-h level] [-s feet] "
"[-T date] files-to-dump\n",
--
Manuel Giraud