Re: diff: Option to use duids in /etc/dumpdates
On 07/11/14 01:15, Maximilian Fillinger wrote: On 07/10/14 16:28, Alexander Hall wrote: Anyway, I worked on your diff a bit more: - keep having -U and -u separate (as discussed) - use Uflag instead of duidflag - bail out if the duid is all 0. - allow specifying the drive to dump by duid.part on the command line. Subject to race conditions, but no more than the current code. Do you think this makes sense, and can you please test if this works for you? Works for me. I think it's good, but I'd suggest some more changes: - if the user already gives us the duid, don't read the disklabel I suspect you mean the opposite, i.e. don't opendev() unless isduid(). What's the point? I'd rather leave that to opendev. - added messages regarding duid-handling We usually just accept the input. I don't think any other DUID handling program does that. The device being dumped is already printed in the output. A new diff for main.c follows below. In the new diff, we only use opendev when isduid returns true, so I think we could replace it with diskmap(4), but I don't feel like figuring that out right now. Also, should we abort if the user specifies an all-zero duid on the command line? Would an all-zero DUID match a disk with an all-zero DUID? If so, I'd say that's questionable behaviour of diskmap(4), if anything. No offence, but I don't think these changes add value to the diff. If there are no other objections, I'd like to commit this today. OK's please? /Alexander === RCS file: sbin/dump/RCS/main.c,v retrieving revision 1.1 retrieving revision 1.4 diff -u -p -r1.1 -r1.4 --- sbin/dump/main.c2014/06/24 21:35:37 1.1 +++ sbin/dump/main.c2014/07/10 23:41:03 1.4 @@ -54,6 +54,7 @@ #include string.h #include time.h #include unistd.h +#include util.h #include dump.h #include pathnames.h @@ -94,8 +95,9 @@ main(int argc, char *argv[]) ino_t maxino; time_t t; int dirlist; - char *toplevel, *str, *mount_point = NULL; + char *toplevel, *str, *mount_point = NULL, *realpath; int just_estimate = 0; + u_int64_t zero_uid = 0; spcl.c_date = (int64_t)time(NULL); @@ -112,7 +114,7 @@ main(int argc, char *argv[]) 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 +182,10 @@ main(int argc, char *argv[]) lastlevel = '?'; break; + case 'U': + Uflag = 1; /* use duids */ + break; + case 'u': /* update /etc/dumpdates */ uflag = 1; break; @@ -213,6 +219,18 @@ main(int argc, char *argv[]) for (i = 0; i argc; i++) { struct stat sb; + /* Convert potential duid into a device name */ + if (isduid(argv[i], 0) (diskfd = opendev(argv[i], + O_RDONLY | O_NOFOLLOW, 0, realpath)) = 0) { + duid = argv[i]; + argv[i] = strdup(realpath); + if (argv[i] == NULL) { + msg(Cannot malloc realpath\n); + exit(X_STARTUP); + } + (void)close(diskfd); + msg(DUID %s maps to %s\n, duid, realpath); + } if (lstat(argv[i], sb) == -1) { msg(Cannot lstat %s: %s\n, argv[i], strerror(errno)); exit(X_STARTUP); @@ -370,6 +388,28 @@ main(int argc, char *argv[]) (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 (Uflag duid == NULL) { + if (ioctl(diskfd, DIOCGDINFO, (char *)lab) 0) + err(1, ioctl (DIOCGDINFO)); + 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 (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); + }
Re: diff: Option to use duids in /etc/dumpdates
On Fri, 2014-07-11 at 14:22 +0200, Alexander Hall wrote: If there are no other objections, I'd like to commit this today. Just don't forget to get rid of this + } else { fprintf(stderr, duid: %s\n, duid); } before committing.
Re: diff: Option to use duids in /etc/dumpdates
On 07/11/14 14:33, Maximilian Fillinger wrote: On Fri, 2014-07-11 at 14:22 +0200, Alexander Hall wrote: If there are no other objections, I'd like to commit this today. Just don't forget to get rid of this + } else { fprintf(stderr, duid: %s\n, duid); } before committing. Hmm... You've got a point there... :-P Still looking for OK's. /Alexander Index: include/protocols/dumprestore.h === RCS file: /cvs/src/include/protocols/dumprestore.h,v retrieving revision 1.9 diff -u -p -r1.9 dumprestore.h --- include/protocols/dumprestore.h 15 Dec 2009 13:11:42 - 1.9 +++ include/protocols/dumprestore.h 11 Jul 2014 13:16:41 - @@ -152,8 +152,8 @@ union u_spcl { #define DR_NEWHEADER 0x0001 /* new format tape header */ #define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ -#defineDUMPOUTFMT %-16s %c %s /* for printf */ +#defineDUMPOUTFMT %-18s %c %s /* for printf */ /* name, level, ctime(date) */ -#defineDUMPINFMT %16s %c %[^\n]\n /* inverse for scanf */ +#defineDUMPINFMT %18s %c %[^\n]\n /* inverse for scanf */ #endif /* !_PROTOCOLS_DUMPRESTORE_H_ */ Index: sbin/dump/Makefile === RCS file: /cvs/src/sbin/dump/Makefile,v retrieving revision 1.11 diff -u -p -r1.11 Makefile --- sbin/dump/Makefile 6 Jan 2013 21:59:28 - 1.11 +++ sbin/dump/Makefile 11 Jul 2014 13:16:41 - @@ -14,6 +14,8 @@ PROG= dump LINKS= ${BINDIR}/dump ${BINDIR}/rdump CFLAGS+=-DRDUMP +DPADD+=${LIBUTIL} +LDADD+=-lutil SRCS= itime.c main.c optr.c dumprmt.c tape.c traverse.c MAN= dump.8 MLINKS+=dump.8 rdump.8 Index: sbin/dump/dump.8 === RCS file: /cvs/src/sbin/dump/dump.8,v retrieving revision 1.46 diff -u -p -r1.46 dump.8 --- sbin/dump/dump.830 May 2014 20:48:21 - 1.46 +++ sbin/dump/dump.811 Jul 2014 13:16:41 - @@ -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 @@ 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 Index: sbin/dump/dump.h === RCS file: /cvs/src/sbin/dump/dump.h,v retrieving revision 1.20 diff -u -p -r1.20 dump.h --- sbin/dump/dump.h13 Jun 2014 20:43:06 - 1.20 +++ sbin/dump/dump.h11 Jul 2014 13:16:41 - @@ -56,9 +56,11 @@ char *disk; /* name of the disk file */ 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 */ intuflag; /* update flag */ +intUflag; /* use duids in dumpdates flag */ intdiskfd; /* disk file descriptor */ inttapefd; /* tape file descriptor */ intpipeout;/* true = output to standard output */ Index: sbin/dump/itime.c === RCS file: /cvs/src/sbin/dump/itime.c,v retrieving revision 1.17 diff -u -p -r1.17 itime.c --- sbin/dump/itime.c 27 Oct 2009 23:59:32 - 1.17 +++ sbin/dump/itime.c 11 Jul 2014 13:16:41 - @@ -124,7 +124,7 @@ getdumptime(void) int i; char *fname; - fname = disk; + fname = Uflag ? duid : disk; #ifdef FDEBUG msg(Looking for name %s in dumpdates = %s for level = %c\n, fname, dumpdates, level); @@ -164,7 +164,7 @@ putdumptime(void) quit(cannot rewrite %s: %s\n, dumpdates, strerror(errno)); fd = fileno(df); (void) flock(fd, LOCK_EX); - fname = disk; + fname = Uflag ? duid : disk; free((char *)ddatev); ddatev = 0; nddates = 0; Index: sbin/dump/main.c === RCS file: /cvs/src/sbin/dump/main.c,v retrieving revision 1.51 diff -u -p -r1.51 main.c --- sbin/dump/main.c13 Jun 2014 20:43:06 - 1.51 +++ sbin/dump/main.c11 Jul 2014 13:16:41 - @@ -54,6 +54,7 @@ #include string.h #include time.h #include unistd.h +#include util.h #include dump.h #include pathnames.h @@ -94,8 +95,9 @@ main(int argc, char *argv[]) ino_t maxino; time_t t; int dirlist; -
Re: diff: Option to use duids in /etc/dumpdates
On 07/09/14 23:44, Alexander Hall wrote: While looking at this, I noticed we don't support specifying the duid for the device to dump. Thinking a bit more, I'm forming a different approach for this. Hold on. Hm, the different approach was left out because of the messy argument parsing. Bah. Anyway, I worked on your diff a bit more: - keep having -U and -u separate (as discussed) - use Uflag instead of duidflag - bail out if the duid is all 0. - allow specifying the drive to dump by duid.part on the command line. Subject to race conditions, but no more than the current code. Do you think this makes sense, and can you please test if this works for you? Anyone else testing this, please note that you need to install dumprestore.h into /usr/include/protocols/ before building. /Alexander Index: include/protocols/dumprestore.h === RCS file: /cvs/src/include/protocols/dumprestore.h,v retrieving revision 1.9 diff -u -p -r1.9 dumprestore.h --- include/protocols/dumprestore.h 15 Dec 2009 13:11:42 - 1.9 +++ include/protocols/dumprestore.h 10 Jul 2014 13:41:16 - @@ -152,8 +152,8 @@ union u_spcl { #define DR_NEWHEADER 0x0001 /* new format tape header */ #define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ -#defineDUMPOUTFMT %-16s %c %s /* for printf */ +#defineDUMPOUTFMT %-18s %c %s /* for printf */ /* name, level, ctime(date) */ -#defineDUMPINFMT %16s %c %[^\n]\n /* inverse for scanf */ +#defineDUMPINFMT %18s %c %[^\n]\n /* inverse for scanf */ #endif /* !_PROTOCOLS_DUMPRESTORE_H_ */ Index: sbin/dump/Makefile === RCS file: /cvs/src/sbin/dump/Makefile,v retrieving revision 1.11 diff -u -p -r1.11 Makefile --- sbin/dump/Makefile 6 Jan 2013 21:59:28 - 1.11 +++ sbin/dump/Makefile 10 Jul 2014 13:41:16 - @@ -14,6 +14,8 @@ PROG= dump LINKS= ${BINDIR}/dump ${BINDIR}/rdump CFLAGS+=-DRDUMP +DPADD+=${LIBUTIL} +LDADD+=-lutil SRCS= itime.c main.c optr.c dumprmt.c tape.c traverse.c MAN= dump.8 MLINKS+=dump.8 rdump.8 Index: sbin/dump/dump.8 === RCS file: /cvs/src/sbin/dump/dump.8,v retrieving revision 1.46 diff -u -p -r1.46 dump.8 --- sbin/dump/dump.830 May 2014 20:48:21 - 1.46 +++ sbin/dump/dump.810 Jul 2014 13:41:16 - @@ -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 @@ 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 Index: sbin/dump/dump.h === RCS file: /cvs/src/sbin/dump/dump.h,v retrieving revision 1.20 diff -u -p -r1.20 dump.h --- sbin/dump/dump.h13 Jun 2014 20:43:06 - 1.20 +++ sbin/dump/dump.h10 Jul 2014 13:41:16 - @@ -56,9 +56,11 @@ char *disk; /* name of the disk file */ 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 */ intuflag; /* update flag */ +intUflag; /* use duids in dumpdates flag */ intdiskfd; /* disk file descriptor */ inttapefd; /* tape file descriptor */ intpipeout;/* true = output to standard output */ Index: sbin/dump/itime.c === RCS file: /cvs/src/sbin/dump/itime.c,v retrieving revision 1.17 diff -u -p -r1.17 itime.c --- sbin/dump/itime.c 27 Oct 2009 23:59:32 - 1.17 +++ sbin/dump/itime.c 10 Jul 2014 13:41:16 - @@ -124,7 +124,7 @@ getdumptime(void) int i; char *fname; - fname = disk; + fname = Uflag ? duid : disk; #ifdef FDEBUG msg(Looking for name %s in dumpdates = %s for level = %c\n, fname, dumpdates, level); @@ -164,7 +164,7 @@ putdumptime(void) quit(cannot rewrite %s: %s\n, dumpdates, strerror(errno)); fd = fileno(df); (void) flock(fd, LOCK_EX); - fname = disk; + fname = Uflag ? duid : disk; free((char *)ddatev); ddatev = 0; nddates = 0; Index: sbin/dump/main.c === RCS
Re: diff: Option to use duids in /etc/dumpdates
On Thu, Jul 10, 2014 at 04:28:49PM +0200, Alexander Hall wrote: On 07/09/14 23:44, Alexander Hall wrote: While looking at this, I noticed we don't support specifying the duid for the device to dump. Thinking a bit more, I'm forming a different approach for this. Hold on. Hm, the different approach was left out because of the messy argument parsing. Bah. Anyway, I worked on your diff a bit more: - keep having -U and -u separate (as discussed) - use Uflag instead of duidflag - bail out if the duid is all 0. - allow specifying the drive to dump by duid.part on the command line. Subject to race conditions, but no more than the current code. Do you think this makes sense, and can you please test if this works for you? Anyone else testing this, please note that you need to install dumprestore.h into /usr/include/protocols/ before building. I was looking for something like this. Manly to make dump -W work with DUIDs. Would be nice if it would not introduce a new flag but I think I can live with that if the rest works. /Alexander Index: include/protocols/dumprestore.h === RCS file: /cvs/src/include/protocols/dumprestore.h,v retrieving revision 1.9 diff -u -p -r1.9 dumprestore.h --- include/protocols/dumprestore.h 15 Dec 2009 13:11:42 - 1.9 +++ include/protocols/dumprestore.h 10 Jul 2014 13:41:16 - @@ -152,8 +152,8 @@ union u_spcl { #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_ */ Index: sbin/dump/Makefile === RCS file: /cvs/src/sbin/dump/Makefile,v retrieving revision 1.11 diff -u -p -r1.11 Makefile --- sbin/dump/Makefile6 Jan 2013 21:59:28 - 1.11 +++ sbin/dump/Makefile10 Jul 2014 13:41:16 - @@ -14,6 +14,8 @@ PROG=dump LINKS= ${BINDIR}/dump ${BINDIR}/rdump CFLAGS+=-DRDUMP +DPADD+= ${LIBUTIL} +LDADD+= -lutil SRCS=itime.c main.c optr.c dumprmt.c tape.c traverse.c MAN= dump.8 MLINKS+=dump.8 rdump.8 Index: sbin/dump/dump.8 === RCS file: /cvs/src/sbin/dump/dump.8,v retrieving revision 1.46 diff -u -p -r1.46 dump.8 --- sbin/dump/dump.8 30 May 2014 20:48:21 - 1.46 +++ sbin/dump/dump.8 10 Jul 2014 13:41:16 - @@ -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 @@ 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 Index: sbin/dump/dump.h === RCS file: /cvs/src/sbin/dump/dump.h,v retrieving revision 1.20 diff -u -p -r1.20 dump.h --- sbin/dump/dump.h 13 Jun 2014 20:43:06 - 1.20 +++ sbin/dump/dump.h 10 Jul 2014 13:41:16 - @@ -56,9 +56,11 @@ char *disk; /* name of the disk file */ 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 Uflag; /* use duids in dumpdates flag */ int diskfd; /* disk file descriptor */ int tapefd; /* tape file descriptor */ int pipeout;/* true = output to standard output */ Index: sbin/dump/itime.c === RCS file: /cvs/src/sbin/dump/itime.c,v retrieving revision 1.17 diff -u -p -r1.17 itime.c --- sbin/dump/itime.c 27 Oct 2009 23:59:32 - 1.17 +++ sbin/dump/itime.c 10 Jul 2014 13:41:16 - @@ -124,7 +124,7 @@ getdumptime(void) int i; char *fname; - fname = disk; + fname = Uflag ? duid : disk; #ifdef FDEBUG msg(Looking for name %s in dumpdates = %s for level = %c\n, fname, dumpdates, level); @@ -164,7 +164,7 @@ putdumptime(void)
Re: diff: Option to use duids in /etc/dumpdates
On 07/10/14 18:38, Claudio Jeker wrote: I was looking for something like this. Manly to make dump -W work with DUIDs. Would be nice if it would not introduce a new flag but I think I can live with that if the rest works. How would you decide whether to use the file name or the duid then? I considered defaulting to duid when the duid of the disk appears in /etc/fstab, but I thought it's better if the users tell dump what they want. Also, I'd rather not modify the behaviour under the existing flags.
Re: diff: Option to use duids in /etc/dumpdates
On 07/08/14 19:36, Maximilian Fillinger wrote: 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 like the idea. I would have liked to read an explanation for the selected solution though, or a brief description of it. I'd be happy to receive comments. Some below. Also, sorry for the noise in misc, and thanks to everyone pointing me in the right direction. Best regards, Max --- sbin/dump/dump.h2014/06/24 21:35:13 1.1 +++ sbin/dump/dump.h2014/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 */ +intduidflag; /* 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.c2014/06/24 21:35:37 1.1 +++ sbin/dump/main.c2014/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; I think -U should imply -u, since there is no use for it without it. 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) { I think adding a check to make sure there is a nonzero duid, as in u_int64_t zero_uid = 0; if (duidflag memcmp(nlp-d_uid, zero_uid, sizeof(nlp-d_uid)) == 0) { msg(Cannot find DUID of disk %s\n, disk) exit(X_STARTUP) } or somesuch, is reasonable. /Alexander + 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_NEWINODEFMT0x0002 /* new format inodes on tape */ -#defineDUMPOUTFMT %-16s %c %s /* for printf */ +#defineDUMPOUTFMT %-18s %c %s /* for printf */ /* name, level, ctime(date) */ -#defineDUMPINFMT %16s %c %[^\n]\n/* inverse for scanf */ +#defineDUMPINFMT %18s %c %[^\n]\n/* inverse for scanf */ #endif /*
Re: diff: Option to use duids in /etc/dumpdates
Thanks for your feedback! I like the idea. I would have liked to read an explanation for the selected solution though, or a brief description of it. I'll add a description below for the benefit of other readers. I think adding a check to make sure there is a nonzero duid [...] is reasonable. Right, I'll add that. I think -U should imply -u, since there is no use for it without it. I'm not sure. Whether or not -u is given, dump searches /etc/dumpdates for the date of the latest lower-level dump. With my patch, if you want dump to search by duid, you need to give it the -U flag. So, as it is now, -U should not imply -u. On the other hand, it might make sense to always search for both duid and device-filename (preferring the duid when both are present). Description of the diff: In main.c, when the flag -U is given, we set duidflag = 1. Then, the program proceeds normally to determine what is to be dumped. We end up with disk being the device file name. We then read the disklabel from disk using ioctl DIOCGDINFO. We then do duid = asprintf(...) to print the duid from the disklabel, followed by a '.' and a partition letter (last character in disk). In itime.c, the function getdumptime() reads off the date of the latest lower-level dump. The patch modifies it so that it searches for duid instead of disk if duidflag is set. Similarly, putdumptime() is modified to update /etc/dumpdates with duid instead of disk. In include/protocols/dumprestore.h, I had to change the format strings DUMPOUTFMT and DUMPINFMT. These are used for writing and reading /etc/dumpdates, and when we allow duids in that file, the first field has to be wider.
Re: diff: Option to use duids in /etc/dumpdates
On 07/09/14 21:13, Maximilian Fillinger wrote: Thanks for your feedback! I like the idea. I would have liked to read an explanation for the selected solution though, or a brief description of it. I'll add a description below for the benefit of other readers. I think adding a check to make sure there is a nonzero duid [...] is reasonable. Right, I'll add that. I think -U should imply -u, since there is no use for it without it. I'm not sure. Whether or not -u is given, dump searches /etc/dumpdates for the date of the latest lower-level dump. With my patch, if you want dump to search by duid, you need to give it the -U flag. So, as it is now, -U should not imply -u. On the other hand, it might make sense to always search for both duid and device-filename (preferring the duid when both are present). Description of the diff: In main.c, when the flag -U is given, we set duidflag = 1. Then, the program proceeds normally to determine what is to be dumped. We end up with disk being the device file name. We then read the disklabel from disk using ioctl DIOCGDINFO. We then do duid = asprintf(...) to print the duid from the disklabel, followed by a '.' and a partition letter (last character in disk). In itime.c, the function getdumptime() reads off the date of the latest lower-level dump. The patch modifies it so that it searches for duid instead of disk if duidflag is set. Similarly, putdumptime() is modified to update /etc/dumpdates with duid instead of disk. In include/protocols/dumprestore.h, I had to change the format strings DUMPOUTFMT and DUMPINFMT. These are used for writing and reading /etc/dumpdates, and when we allow duids in that file, the first field has to be wider. While looking at this, I noticed we don't support specifying the duid for the device to dump. Thinking a bit more, I'm forming a different approach for this. Hold on. /Alexander