Module Name:    src
Committed By:   manu
Date:           Mon Mar 25 02:13:01 UTC 2019

Modified Files:
        src/sbin/dump: dump.8 dump.h itime.c main.c
        src/sbin/dump_lfs: dump_lfs.8

Log Message:
Add -U flag to dump(8) and dump_lfs(8) to specify dumpdates entry

This address situations where dump(8) cannot figure out the device being
dumped. It also allows tracking of subvolume dumps by using virtual
device as dumpdates entry.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/dump/dump.8
cvs rdiff -u -r1.56 -r1.57 src/sbin/dump/dump.h
cvs rdiff -u -r1.21 -r1.22 src/sbin/dump/itime.c
cvs rdiff -u -r1.74 -r1.75 src/sbin/dump/main.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/dump_lfs/dump_lfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/dump/dump.8
diff -u src/sbin/dump/dump.8:1.69 src/sbin/dump/dump.8:1.70
--- src/sbin/dump/dump.8:1.69	Sun Jul 15 06:14:13 2018
+++ src/sbin/dump/dump.8	Mon Mar 25 02:13:01 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dump.8,v 1.69 2018/07/15 06:14:13 dholland Exp $
+.\"	$NetBSD: dump.8,v 1.70 2019/03/25 02:13:01 manu Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	 Regents of the University of California.
@@ -51,6 +51,7 @@
 .Op Fl r Ar cachesize
 .Op Fl s Ar feet
 .Op Fl T Ar date
+.Op Fl U Ar dumpdev
 .Op Fl x Ar snap-backup
 .Ar files-to-dump
 .Nm
@@ -299,10 +300,22 @@ The file
 .Pa /etc/dumpdates
 may be edited to change any of the fields,
 if necessary.
-If a list of files or subdirectories is being dumped
+If the
+.Fl T
+option is used or if a list of files or subdirectories is being dumped
 (as opposed to an entire file system), then
 .Fl u
 is ignored.
+.It Fl U Ar dumpdev
+Same as
+.Fl u
+but specifies the device in
+.Pa /etc/dumpdates
+as
+.Ar dumpdev .
+This option can be used with subdir dumps and with the
+.Fl T
+option.
 .It Fl W
 .Nm
 tells the operator what file systems need to be dumped.

Index: src/sbin/dump/dump.h
diff -u src/sbin/dump/dump.h:1.56 src/sbin/dump/dump.h:1.57
--- src/sbin/dump/dump.h:1.56	Fri Mar  1 16:42:11 2019
+++ src/sbin/dump/dump.h	Mon Mar 25 02:13:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dump.h,v 1.56 2019/03/01 16:42:11 christos Exp $	*/
+/*	$NetBSD: dump.h,v 1.57 2019/03/25 02:13:01 manu Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1993
@@ -115,6 +115,7 @@ const char *temp;	/* name of the file fo
 char	lastlevel;	/* dump level of previous dump */
 char	level;		/* dump level of this dump */
 int	uflag;		/* update flag */
+const char *dumpdev;	/* device name in dumpdates */
 int	eflag;		/* eject flag */
 int	lflag;		/* autoload flag */
 int	diskfd;		/* disk file descriptor */

Index: src/sbin/dump/itime.c
diff -u src/sbin/dump/itime.c:1.21 src/sbin/dump/itime.c:1.22
--- src/sbin/dump/itime.c:1.21	Fri Mar  1 16:42:11 2019
+++ src/sbin/dump/itime.c	Mon Mar 25 02:13:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: itime.c,v 1.21 2019/03/01 16:42:11 christos Exp $	*/
+/*	$NetBSD: itime.c,v 1.22 2019/03/25 02:13:01 manu Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)itime.c	8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: itime.c,v 1.21 2019/03/01 16:42:11 christos Exp $");
+__RCSID("$NetBSD: itime.c,v 1.22 2019/03/25 02:13:01 manu Exp $");
 #endif
 #endif /* not lint */
 
@@ -129,9 +129,9 @@ getdumptime(void)
 {
 	struct dumpdates *ddp;
 	int i;
-	char *fname;
+	const char *fname;
 
-	fname = disk;
+	fname = dumpdev ? dumpdev : disk;
 #ifdef FDEBUG
 	msg("Looking for name %s in dumpdates = %s for level = %c\n",
 		fname, dumpdates, level);
@@ -170,15 +170,15 @@ putdumptime(void)
 	struct dumpdates *dtwalk, *dtfound;
 	int i;
 	int fd;
-	char *fname;
+	const char *fname;
 
-	if(uflag == 0)
+	if (uflag == 0 && dumpdev == NULL)
 		return;
 	if ((df = fopen(dumpdates, "r+")) == NULL)
 		quite(errno, "cannot rewrite %s", dumpdates);
 	fd = fileno(df);
 	(void) flock(fd, LOCK_EX);
-	fname = disk;
+	fname = dumpdev ? dumpdev : disk;
 	free((char *)ddatev);
 	ddatev = 0;
 	nddates = 0;

Index: src/sbin/dump/main.c
diff -u src/sbin/dump/main.c:1.74 src/sbin/dump/main.c:1.75
--- src/sbin/dump/main.c:1.74	Fri Mar  1 16:42:11 2019
+++ src/sbin/dump/main.c	Mon Mar 25 02:13:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.74 2019/03/01 16:42:11 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.74 2019/03/01 16:42:11 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $");
 #endif
 #endif /* not lint */
 
@@ -133,7 +133,7 @@ main(int argc, char *argv[])
 
 	obsolete(&argc, &argv);
 	while ((ch = getopt(argc, argv,
-	    "0123456789aB:b:cd:eFf:h:ik:l:L:nr:s:StT:uWwx:X")) != -1)
+	    "0123456789aB:b:cd:eFf:h:ik:l:L:nr:s:StT:uU:Wwx:X")) != -1)
 		switch (ch) {
 		/* dump level */
 		case '0': case '1': case '2': case '3': case '4':
@@ -245,6 +245,10 @@ main(int argc, char *argv[])
 			uflag = 1;
 			break;
 
+		case 'U':		/* dump device in /etc/dumpdates */
+			dumpdev = optarg;
+			break;
+
 		case 'W':		/* what to do */
 		case 'w':
 			lastdump(ch);
@@ -674,7 +678,7 @@ usage(void)
 "usage: %s [-0123456789aceFinStuX] [-B records] [-b blocksize]\n"
 "            [-d density] [-f file] [-h level] [-k read-blocksize]\n"
 "            [-L label] [-l timeout] [-r cachesize] [-s feet]\n"
-"            [-T date] [-x snap-backup] files-to-dump\n"
+"            [-T date] [-U dumpdev] [-x snap-backup] files-to-dump\n"
 "       %s [-W | -w]\n", prog, prog);
 	exit(X_STARTUP);
 }

Index: src/sbin/dump_lfs/dump_lfs.8
diff -u src/sbin/dump_lfs/dump_lfs.8:1.17 src/sbin/dump_lfs/dump_lfs.8:1.18
--- src/sbin/dump_lfs/dump_lfs.8:1.17	Wed Jun  7 15:24:50 2017
+++ src/sbin/dump_lfs/dump_lfs.8	Mon Mar 25 02:13:01 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dump_lfs.8,v 1.17 2017/06/07 15:24:50 abhinav Exp $
+.\"	$NetBSD: dump_lfs.8,v 1.18 2019/03/25 02:13:01 manu Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	 Regents of the University of California.
@@ -51,6 +51,7 @@
 .Op Fl r Ar cachesize
 .Op Fl s Ar feet
 .Op Fl T Ar date
+.Op Fl U Ar dumpdev
 .Op Fl x Ar snap-backup
 .Ar files-to-dump
 .Nm
@@ -280,10 +281,22 @@ The file
 .Pa /etc/dumpdates
 may be edited to change any of the fields,
 if necessary.
-If a list of files or subdirectories is being dumped
+If the
+.Fl T
+option is used or if a list of files or subdirectories is being dumped
 (as opposed to an entire file system), then
 .Fl u
 is ignored.
+.It Fl U Ar dumpdev
+Same as
+.Fl u
+but specifies the device in
+.Pa /etc/dumpdates
+as
+.Ar dumpdev .
+This option can be used with subdir dumps and with the
+.Fl T
+option.
 .It Fl X
 Prevent the log from wrapping until the dump completes, guaranteeing
 a consistent backup.

Reply via email to