From 352e3770dfd0f06a87060fcb255cb6c94111edd7 Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 3 May 2015 01:44:34 +0000 Subject: [PATCH] Eliminate the -U flag and make usage of DUID in /etc/dumpdates the default. Correct old style entries so nothing has to be done for the admin. diff from Manuel Giraud (manuel (at) ledu-giraud.fr) Thanks! --- sbin/dump/dump.8 | 17 ++++++----------- sbin/dump/dump.h | 3 +-- sbin/dump/itime.c | 15 +++++++++------ sbin/dump/main.c | 32 +++++++++++++------------------- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8 index 9b4ce35613a..ef9656a5afa 100644 --- a/sbin/dump/dump.8 +++ b/sbin/dump/dump.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dump.8,v 1.48 2014/07/17 19:58:05 jmc Exp $ +.\" $OpenBSD: dump.8,v 1.49 2015/05/03 01:44:34 guenther Exp $ .\" $NetBSD: dump.8,v 1.17 1997/06/05 11:15:06 lukem Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 @@ -31,7 +31,7 @@ .\" .\" @(#)dump.8 8.1 (Berkeley) 6/16/93 .\" -.Dd $Mdocdate: July 17 2014 $ +.Dd $Mdocdate: May 3 2015 $ .Dt DUMP 8 .Os .Sh NAME @@ -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 diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index 83663dacfec..b7436ba4524 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.h,v 1.22 2014/09/03 02:34:34 guenther Exp $ */ +/* $OpenBSD: dump.h,v 1.23 2015/05/03 01:44:34 guenther Exp $ */ /* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */ /*- @@ -60,7 +60,6 @@ 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 Uflag; /* use duids in dumpdates flag */ int diskfd; /* disk file descriptor */ int tapefd; /* tape file descriptor */ int pipeout; /* true => output to standard output */ diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index 2392c300969..e3645dac026 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: itime.c,v 1.19 2015/01/16 06:39:57 deraadt Exp $ */ +/* $OpenBSD: itime.c,v 1.20 2015/05/03 01:44:34 guenther Exp $ */ /* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */ /*- @@ -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; diff --git a/sbin/dump/main.c b/sbin/dump/main.c index f3b78e1a39e..ff7788de3a3 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.54 2015/01/20 18:22:20 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.55 2015/05/03 01:44:34 guenther Exp $ */ /* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */ /*- @@ -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,18 +390,16 @@ 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); - } 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], - 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 (memcmp(lab.d_uid, &zero_uid, sizeof(lab.d_uid)) != 0) { + 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], + 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 */ @@ -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", -- 2.20.1