Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/dump * improve parsing of file-systems-to-dump when a p...
details: https://anonhg.NetBSD.org/src/rev/6cbedaaf3901
branches: trunk
changeset: 510395:6cbedaaf3901
user: lukem <lukem%NetBSD.org@localhost>
date: Mon May 28 01:09:54 2001 +0000
description:
* improve parsing of file-systems-to-dump when a path is given:
- if it's a path to an unmounted file-system listed in /etc/fstab, use
that instead of assuming the user wanted a subtree dump of the parent
directory. this restores the behaviour of dump before the subtree
dumping code went in.
- if it's a path to a mounted file-system which is not in /etc/fstab,
use the info from getmntinfo(3). previously, dump would choke.
* implement error checked malloc(), calloc(), strdup(), and use
appropriately (some of the calloc()s weren't being checked)
* use 'file-system' instead of 'filesystem' in the man page
diffstat:
sbin/dump/dump.8 | 40 +++++++-----
sbin/dump/dump.h | 9 ++-
sbin/dump/itime.c | 10 +-
sbin/dump/main.c | 159 ++++++++++++++++++++++++++++++++------------------
sbin/dump/optr.c | 54 +++++++++++++---
sbin/dump/tape.c | 8 +-
sbin/dump/traverse.c | 5 +-
7 files changed, 183 insertions(+), 102 deletions(-)
diffs (truncated from 628 to 300 lines):
diff -r 4c9519980f00 -r 6cbedaaf3901 sbin/dump/dump.8
--- a/sbin/dump/dump.8 Mon May 28 00:50:40 2001 +0000
+++ b/sbin/dump/dump.8 Mon May 28 01:09:54 2001 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: dump.8,v 1.35 2001/05/07 21:17:48 tron Exp $
+.\" $NetBSD: dump.8,v 1.36 2001/05/28 01:09:54 lukem Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" Regents of the University of California.
@@ -34,13 +34,13 @@
.\"
.\" @(#)dump.8 8.3 (Berkeley) 5/1/95
.\"
-.Dd January 3, 1999
+.Dd May 28, 2001
.Dt DUMP 8
.Os BSD 4
.Sh NAME
.Nm dump ,
.Nm rdump
-.Nd filesystem backup
+.Nd file-system backup
.Sh SYNOPSIS
.Nm ""
.Op Fl 0123456789cenSu
@@ -65,7 +65,7 @@
is not documented here).
.Sh DESCRIPTION
.Nm
-examines files on a filesystem and determines which files need to
+examines files on a file-system and determines which files need to
be backed up.
These files are copied to the given disk, tape or other storage
medium for safe keeping (see the
@@ -84,16 +84,20 @@
after prompting the operator to change media.
.Pp
.Ar files-to-dump
-is either a mountpoint of a filesystem,
-or a list of files and directories on a single filesystem to be backed
-up as a subset of the filesystem.
-In the former case, either the path to a mounted filesystem,
-or the device of an unmounted filesystem can be used.
+is either a single file-system,
+or a list of files and directories on a single file-system to be backed
+up as a subset of the file-system.
+In the former case,
+.Ar files-to-dump
+may be the device of a file-system,
+the path to a currently mounted file-system, or
+the path to an unmounted file-system listed in
+.Pa /etc/fstab .
In the latter case, certain restrictions are placed on the backup:
.Fl u
is ignored, the only dump level that is supported is
.Fl 0 ,
-and all of the files must reside on the same filesystem.
+and all of the files must reside on the same file-system.
.Pp
The following options are supported by
.Nm "" :
@@ -176,7 +180,7 @@
but full backups retain them.
.It Fl k Ar read blocksize
The size in kilobyte of the read buffers, rounded up to a multiple of the
-filesystem block size. Default is 32k.
+file-system block size. Default is 32k.
.It Fl L Ar label
The user-supplied text string
.Ar label
@@ -237,18 +241,18 @@
.Pa /etc/dumpdates
is readable by people, consisting of one
free format record per line:
-filesystem name,
+file-system name,
increment level
and
.Xr ctime 3
format dump date.
-There may be only one entry per filesystem at each level.
+There may be only one entry per file-system at each level.
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
-(as opposed to and entire filesystem), then
+(as opposed to and entire file-system), then
.Fl u
is ignored.
.It Fl W
@@ -272,7 +276,7 @@
.Nm
exits immediately.
.It Fl w
-Is like W, but prints only those filesystems which need to be dumped.
+Is like W, but prints only those file-systems which need to be dumped.
.El
.Pp
If
@@ -442,7 +446,7 @@
Startup errors are indicated with an exit code of 1;
abnormal termination is indicated with an exit code of 3.
.Sh BUGS
-Fewer than 32 read errors on the filesystem are ignored.
+Fewer than 32 read errors on the file-system are ignored.
.Pp
Each reel requires a new process, so parent processes for
reels already written just hang around until the entire tape
@@ -453,7 +457,7 @@
.Fl W
or
.Fl w
-options does not report filesystems that have never been recorded
+options does not report file-systems that have never been recorded
in
.Pa /etc/dumpdates ,
even if listed in
@@ -462,7 +466,7 @@
When dumping a list of files or subdirectories, access privileges are
required to scan the directory (as this is done via the
.Xr fts 3
-routines rather than directly accessing the filesystem).
+routines rather than directly accessing the file-system).
.Pp
It would be nice if
.Nm
diff -r 4c9519980f00 -r 6cbedaaf3901 sbin/dump/dump.h
--- a/sbin/dump/dump.h Mon May 28 00:50:40 2001 +0000
+++ b/sbin/dump/dump.h Mon May 28 01:09:54 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dump.h,v 1.26 2001/05/27 14:17:56 lukem Exp $ */
+/* $NetBSD: dump.h,v 1.27 2001/05/28 01:09:55 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -202,6 +202,10 @@
char *rawname(char *);
struct dinode *getino(ino_t);
+void *xcalloc(size_t, size_t);
+void *xmalloc(size_t);
+char *xstrdup(const char *);
+
/* rdump routines */
#if defined(RDUMP) || defined(RRESTORE)
void rmtclose(void);
@@ -222,7 +226,8 @@
#define OPGRENT "operator" /* group entry to notify */
#define DIALUP "ttyd" /* prefix for dialups */
-struct fstab *fstabsearch(char *); /* search fs_file and fs_spec */
+struct fstab *fstabsearch(const char *); /* search fs_file and fs_spec */
+struct statfs *mntinfosearch(const char *key);
#ifndef NAME_MAX
#define NAME_MAX 255
diff -r 4c9519980f00 -r 6cbedaaf3901 sbin/dump/itime.c
--- a/sbin/dump/itime.c Mon May 28 00:50:40 2001 +0000
+++ b/sbin/dump/itime.c Mon May 28 01:09:54 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: itime.c,v 1.10 2001/05/28 00:41:14 lukem Exp $ */
+/* $NetBSD: itime.c,v 1.11 2001/05/28 01:09:55 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93";
#else
-__RCSID("$NetBSD: itime.c,v 1.10 2001/05/28 00:41:14 lukem Exp $");
+__RCSID("$NetBSD: itime.c,v 1.11 2001/05/28 01:09:55 lukem Exp $");
#endif
#endif /* not lint */
@@ -115,7 +115,7 @@
struct dumptime *dtwalk;
for (;;) {
- dtwalk = (struct dumptime *)calloc(1, sizeof (struct dumptime));
+ dtwalk = (struct dumptime *)xcalloc(1, sizeof(struct dumptime));
if (getrecord(df, &(dtwalk->dt_value)) < 0)
break;
nddates++;
@@ -129,7 +129,7 @@
* record that we may have to add to the ddate structure
*/
ddatev = (struct dumpdates **)
- calloc((unsigned) (nddates + 1), sizeof (struct dumpdates *));
+ xcalloc((unsigned) (nddates + 1), sizeof(struct dumpdates *));
dtwalk = dthead;
for (i = nddates - 1; i >= 0; i--, dtwalk = dtwalk->dt_next)
ddatev[i] = &dtwalk->dt_value;
@@ -205,7 +205,7 @@
* Enough room has been allocated.
*/
dtwalk = ddatev[nddates] =
- (struct dumpdates *)calloc(1, sizeof (struct dumpdates));
+ (struct dumpdates *)xcalloc(1, sizeof (struct dumpdates));
nddates += 1;
found:
(void) strncpy(dtwalk->dd_name, fname, sizeof (dtwalk->dd_name));
diff -r 4c9519980f00 -r 6cbedaaf3901 sbin/dump/main.c
--- a/sbin/dump/main.c Mon May 28 00:50:40 2001 +0000
+++ b/sbin/dump/main.c Mon May 28 01:09:54 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.32 2001/05/27 15:07:34 lukem Exp $ */
+/* $NetBSD: main.c,v 1.33 2001/05/28 01:09:55 lukem Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: main.c,v 1.32 2001/05/27 15:07:34 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.33 2001/05/28 01:09:55 lukem Exp $");
#endif
#endif /* not lint */
@@ -103,14 +103,15 @@
ino_t ino;
int dirty;
struct dinode *dp;
- struct fstab *dt;
+ struct fstab *dt;
+ struct statfs *mntinfo, fsbuf;
char *map;
int ch;
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
ino_t maxino;
time_t tnow, date;
- int dirlist;
- char *toplevel;
+ int dirc;
+ char *mountpoint;
int just_estimate = 0;
char labelstr[LBLSIZE];
@@ -238,38 +239,40 @@
exit(X_ABORT);
}
+
/*
* determine if disk is a subdirectory, and setup appropriately
*/
- dirlist = 0;
- toplevel = NULL;
+ getfstab(); /* /etc/fstab snarfed */
+ disk = NULL;
+ mountpoint = NULL;
+ dirc = 0;
for (i = 0; i < argc; i++) {
struct stat sb;
- struct statfs fsbuf;
- if (lstat(argv[i], &sb) == -1) {
- msg("Cannot lstat %s: %s\n", argv[i], strerror(errno));
- exit(X_ABORT);
- }
- if (!S_ISDIR(sb.st_mode) && !S_ISREG(sb.st_mode))
+ if (lstat(argv[i], &sb) == -1)
+ quit("Cannot stat %s: %s\n", argv[i], strerror(errno));
+ if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
+ disk = argv[i];
+ multicheck:
+ if (dirc != 0)
+ quit(
+ "Can't dump a mountpoint and a filelist\n");
break;
- if (statfs(argv[i], &fsbuf) == -1) {
- msg("Cannot statfs %s: %s\n", argv[i], strerror(errno));
- exit(X_ABORT);
}
- if (strcmp(argv[i], fsbuf.f_mntonname) == 0) {
- if (dirlist != 0) {
- msg("Can't dump a mountpoint and a filelist\n");
- exit(X_ABORT);
- }
- break; /* exit if sole mountpoint */
+ if ((dt = fstabsearch(argv[i])) != NULL) {
+ disk = dt->fs_spec;
+ mountpoint = dt->fs_file;
+ goto multicheck;
}
- if (!disk) {
- if ((toplevel = strdup(fsbuf.f_mntonname)) == NULL) {
- msg("Cannot malloc diskname\n");
- exit(X_ABORT);
- }
- disk = toplevel;
+ if (statfs(argv[i], &fsbuf) == -1)
+ quit("Cannot statfs %s: %s\n", argv[i],
+ strerror(errno));
+ disk = fsbuf.f_mntfromname;
+ if (strcmp(argv[i], fsbuf.f_mntonname) == 0)
+ goto multicheck;
+ if (mountpoint == NULL) {
Home |
Main Index |
Thread Index |
Old Index