Subject: bin/6715: dump uses boring "none" label
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bgrayson@ece.utexas.edu>
List: netbsd-bugs
Date: 01/02/1999 02:31:53
>Number: 6715
>Category: bin
>Synopsis: dump uses boring "none" label
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 2 00:35:00 1999
>Last-Modified:
>Originator: Brian Grayson
>Organization:
Parallel and Distributed Systems
Electrical and Computer Engineering
The University of Texas at Austin
>Release: Dec 31 1998
>Environment:
>Description:
The dump header provides 16 characters for a
null-terminated label string. Currently, dump always
uses "none". Note that file(1) and restore(8) already
have support for labels.
The fix below adds a -L option to dump that allows the
user to specify a label for the dump.
I don't know what the best option would be, but -L seemed
reasonable and free on the few OS's I have access to.
Surely some operating system at some point allowed the
label to be specified???
>How-To-Repeat:
>Fix:
These diffs may be a little funny, as I've submitted a whole
bunch of dump PRs that haven't yet had a chance to be
processed. But they ought to apply cleanly regardless.
--- /usr/src/sbin/dump/main.c.dist Fri Jan 1 00:11:21 1999
+++ /usr/src/sbin/dump/main.c Sat Jan 2 02:22:08 1999
@@ -116,6 +116,8 @@
int dirlist;
char *toplevel;
int just_estimate = 0;
+ char labelstr[LBLSIZE+1];
+ int labellen;
spcl.c_date = 0;
(void)time((time_t *)&spcl.c_date);
@@ -125,6 +127,8 @@
tape = _PATH_DEFTAPE;
dumpdates = _PATH_DUMPDATES;
temp = _PATH_DTMP;
+ strcpy(labelstr, "none"); /* XXX safe strcpy. */
+ labelstr[LBLSIZE] = '\0';
if (TP_BSIZE / DEV_BSIZE == 0 || TP_BSIZE % DEV_BSIZE != 0)
quit("TP_BSIZE must be a multiple of DEV_BSIZE\n");
level = '0';
@@ -134,7 +138,7 @@
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv,
- "0123456789B:b:cd:f:h:ns:ST:uWw")) != -1)
+ "0123456789B:b:cd:f:h:L:ns:ST:uWw")) != -1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@@ -169,6 +173,23 @@
honorlevel = numarg("honor level", 0L, 10L);
break;
+ case 'L':
+ /* Note that although there are LBLSIZE
+ * characters, the last must
+ * be '\0', so the limit on strlen() is
+ * really LBLSIZE-1. */
+ strncpy(labelstr, optarg, LBLSIZE-1);
+ labellen = strlen(optarg);
+ if (labellen > LBLSIZE-1) {
+ msg("WARNING: label of '%s' is larger than "
+ "limit of %d characters.\n", optarg,
+ LBLSIZE-1);
+ msg("WARNING: using label of '%s'.\n",
+ labelstr);
+ labellen = LBLSIZE-1;
+ }
+ labelstr[labellen] = '\0';
+ break;
case 'n': /* notify operators */
notify = 1;
break;
@@ -351,7 +372,7 @@
(void)strncpy(spcl.c_filesys, "an unlisted file system",
NAMELEN);
}
- (void)strncpy(spcl.c_label, "none", sizeof(spcl.c_label) - 1);
+ (void)strncpy(spcl.c_label, labelstr, sizeof(spcl.c_label) - 1);
(void)gethostname(spcl.c_host, NAMELEN);
spcl.c_host[sizeof(spcl.c_host) - 1] = '\0';
@@ -391,6 +412,7 @@
msgtail("to %s on host %s\n", tape, host);
else
msgtail("to %s\n", tape);
+ msg("Label: %s\n", labelstr);
dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1);
dev_bshift = ffs(dev_bsize) - 1;
--- /usr/src/sbin/dump/dump.8.dist Sat Jan 2 00:34:47 1999
+++ /usr/src/sbin/dump/dump.8 Sat Jan 2 00:42:11 1999
@@ -49,6 +49,7 @@
.Op Fl d Ar density
.Op Fl f Ar file
.Op Fl h Ar level
+.Op Fl L Ar label
.Op Fl s Ar feet
.Op Fl T Ar date
.Ar files-to-dump
@@ -169,6 +170,17 @@
The default honor level is 1,
so that incremental backups omit such files
but full backups retain them.
+.It Fl L Ar label
+The
+user-supplied text string
+.Ar label
+is placed into the dump header, where tools like
+.Xr restore 8
+and
+.Xr file 1
+can access it. Note that this label is limited
+to be at most LBLSIZE (currently 16) characters, which must include
+the terminating `\\0'.
.It Fl n
Whenever
.Nm
>Audit-Trail:
>Unformatted: