* Add the ability to dump specific files & directories of a single
filesystem. This uses fts(3) to access the directory structure (and not the raw device), so the standard access permissions are adhered to (unlike dumping an entire filesystem, which just requires read access to the raw disk device). * Support SIGINFO status reporting. * Remove now unused variables that previously stored the (e)uid. * Be more informative in a couple of error messages.
This commit is contained in:
parent
5d78b65530
commit
4c54f5b742
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: dump.8,v 1.15 1997/04/15 07:00:45 lukem Exp $
|
.\" $NetBSD: dump.8,v 1.16 1997/06/05 11:13:18 lukem Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1980, 1991, 1993
|
.\" Copyright (c) 1980, 1991, 1993
|
||||||
.\" Regents of the University of California.
|
.\" Regents of the University of California.
|
||||||
|
@ -34,14 +34,14 @@
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)dump.8 8.1 (Berkeley) 6/16/93
|
.\" @(#)dump.8 8.1 (Berkeley) 6/16/93
|
||||||
.\"
|
.\"
|
||||||
.Dd June 16, 1993
|
.Dd June 4, 1997
|
||||||
.Dt DUMP 8
|
.Dt DUMP 8
|
||||||
.Os BSD 4
|
.Os BSD 4
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm dump
|
.Nm dump
|
||||||
.Nd filesystem backup
|
.Nd filesystem backup
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm dump
|
.Nm
|
||||||
.Op Fl 0123456789cnu
|
.Op Fl 0123456789cnu
|
||||||
.Op Fl B Ar records
|
.Op Fl B Ar records
|
||||||
.Op Fl b Ar blocksize
|
.Op Fl b Ar blocksize
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
.Op Fl h Ar level
|
.Op Fl h Ar level
|
||||||
.Op Fl s Ar feet
|
.Op Fl s Ar feet
|
||||||
.Op Fl T Ar date
|
.Op Fl T Ar date
|
||||||
.Ar filesystem
|
.Ar files-to-dump
|
||||||
.Nm dump
|
.Nm dump
|
||||||
.Op Fl W Li \&| Fl w
|
.Op Fl W Li \&| Fl w
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
option syntax is implemented for backward compatibility, but
|
option syntax is implemented for backward compatibility, but
|
||||||
is not documented here.)
|
is not documented here.)
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm Dump
|
.Nm
|
||||||
examines files
|
examines files
|
||||||
on a filesystem
|
on a filesystem
|
||||||
and determines which files
|
and determines which files
|
||||||
|
@ -81,6 +81,18 @@ block count options below.
|
||||||
By default, the same output file name is used for each volume
|
By default, the same output file name is used for each volume
|
||||||
after prompting the operator to change media.
|
after prompting the operator to change media.
|
||||||
.Pp
|
.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.
|
||||||
|
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.
|
||||||
|
.Pp
|
||||||
The following options are supported by
|
The following options are supported by
|
||||||
.Nm dump :
|
.Nm dump :
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
|
@ -134,7 +146,7 @@ If the name of the file is of the form
|
||||||
.Dq host:file ,
|
.Dq host:file ,
|
||||||
or
|
or
|
||||||
.Dq user@host:file ,
|
.Dq user@host:file ,
|
||||||
.Nm dump
|
.Nm
|
||||||
writes to the named file on the remote host using
|
writes to the named file on the remote host using
|
||||||
.Xr rmt 8 .
|
.Xr rmt 8 .
|
||||||
.It Fl h Ar level
|
.It Fl h Ar level
|
||||||
|
@ -149,7 +161,7 @@ so that incremental backups omit such files
|
||||||
but full backups retain them.
|
but full backups retain them.
|
||||||
.It Fl n
|
.It Fl n
|
||||||
Whenever
|
Whenever
|
||||||
.Nm dump
|
.Nm
|
||||||
requires operator attention,
|
requires operator attention,
|
||||||
notify all operators in the group
|
notify all operators in the group
|
||||||
.Dq operator
|
.Dq operator
|
||||||
|
@ -159,7 +171,7 @@ by means similar to a
|
||||||
Attempt to calculate the amount of tape needed
|
Attempt to calculate the amount of tape needed
|
||||||
at a particular density.
|
at a particular density.
|
||||||
If this amount is exceeded,
|
If this amount is exceeded,
|
||||||
.Nm dump
|
.Nm
|
||||||
prompts for a new tape.
|
prompts for a new tape.
|
||||||
It is recommended to be a bit conservative on this option.
|
It is recommended to be a bit conservative on this option.
|
||||||
The default tape length is 2300 feet.
|
The default tape length is 2300 feet.
|
||||||
|
@ -194,8 +206,12 @@ The file
|
||||||
.Pa /etc/dumpdates
|
.Pa /etc/dumpdates
|
||||||
may be edited to change any of the fields,
|
may be edited to change any of the fields,
|
||||||
if necessary.
|
if necessary.
|
||||||
|
If a list of files or subdirectories is being dumped
|
||||||
|
(as opposed to and entire filesystem), then
|
||||||
|
.Fl u
|
||||||
|
is ignored.
|
||||||
.It Fl W
|
.It Fl W
|
||||||
.Nm Dump
|
.Nm
|
||||||
tells the operator what file systems need to be dumped.
|
tells the operator what file systems need to be dumped.
|
||||||
This information is gleaned from the files
|
This information is gleaned from the files
|
||||||
.Pa /etc/dumpdates
|
.Pa /etc/dumpdates
|
||||||
|
@ -204,7 +220,7 @@ and
|
||||||
The
|
The
|
||||||
.Fl W
|
.Fl W
|
||||||
flag causes
|
flag causes
|
||||||
.Nm dump
|
.Nm
|
||||||
to print out, for each file system in
|
to print out, for each file system in
|
||||||
.Pa /etc/dumpdates
|
.Pa /etc/dumpdates
|
||||||
the most recent dump date and level,
|
the most recent dump date and level,
|
||||||
|
@ -212,13 +228,13 @@ and highlights those file systems that should be dumped.
|
||||||
If the
|
If the
|
||||||
.Fl W
|
.Fl W
|
||||||
flag is set, all other options are ignored, and
|
flag is set, all other options are ignored, and
|
||||||
.Nm dump
|
.Nm
|
||||||
exits immediately.
|
exits immediately.
|
||||||
.It Fl w
|
.It Fl w
|
||||||
Is like W, but prints only those filesystems which need to be dumped.
|
Is like W, but prints only those filesystems which need to be dumped.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
.Nm Dump
|
.Nm
|
||||||
requires operator intervention on these conditions:
|
requires operator intervention on these conditions:
|
||||||
end of tape,
|
end of tape,
|
||||||
end of dump,
|
end of dump,
|
||||||
|
@ -228,15 +244,15 @@ disk read error (if there are more than a threshold of 32).
|
||||||
In addition to alerting all operators implied by the
|
In addition to alerting all operators implied by the
|
||||||
.Fl n
|
.Fl n
|
||||||
flag,
|
flag,
|
||||||
.Nm dump
|
.Nm
|
||||||
interacts with the operator on
|
interacts with the operator on
|
||||||
.Nm dump Ns 's
|
.Nm dump Ns 's
|
||||||
control terminal at times when
|
control terminal at times when
|
||||||
.Nm dump
|
.Nm
|
||||||
can no longer proceed,
|
can no longer proceed,
|
||||||
or if something is grossly wrong.
|
or if something is grossly wrong.
|
||||||
All questions
|
All questions
|
||||||
.Nm dump
|
.Nm
|
||||||
poses
|
poses
|
||||||
.Em must
|
.Em must
|
||||||
be answered by typing
|
be answered by typing
|
||||||
|
@ -246,17 +262,17 @@ or
|
||||||
appropriately.
|
appropriately.
|
||||||
.Pp
|
.Pp
|
||||||
Since making a dump involves a lot of time and effort for full dumps,
|
Since making a dump involves a lot of time and effort for full dumps,
|
||||||
.Nm dump
|
.Nm
|
||||||
checkpoints itself at the start of each tape volume.
|
checkpoints itself at the start of each tape volume.
|
||||||
If writing that volume fails for some reason,
|
If writing that volume fails for some reason,
|
||||||
.Nm dump
|
.Nm
|
||||||
will,
|
will,
|
||||||
with operator permission,
|
with operator permission,
|
||||||
restart itself from the checkpoint
|
restart itself from the checkpoint
|
||||||
after the old tape has been rewound and removed,
|
after the old tape has been rewound and removed,
|
||||||
and a new tape has been mounted.
|
and a new tape has been mounted.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm Dump
|
.Nm
|
||||||
tells the operator what is going on at periodic intervals,
|
tells the operator what is going on at periodic intervals,
|
||||||
including usually low estimates of the number of blocks to write,
|
including usually low estimates of the number of blocks to write,
|
||||||
the number of tapes it will take, the time to completion, and
|
the number of tapes it will take, the time to completion, and
|
||||||
|
@ -264,7 +280,7 @@ the time to the tape change.
|
||||||
The output is verbose,
|
The output is verbose,
|
||||||
so that others know that the terminal
|
so that others know that the terminal
|
||||||
controlling
|
controlling
|
||||||
.Nm dump
|
.Nm
|
||||||
is busy,
|
is busy,
|
||||||
and will be for some time.
|
and will be for some time.
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -301,6 +317,19 @@ used, also on a cyclical basis.
|
||||||
.Pp
|
.Pp
|
||||||
After several months or so, the daily and weekly tapes should get
|
After several months or so, the daily and weekly tapes should get
|
||||||
rotated out of the dump cycle and fresh tapes brought in.
|
rotated out of the dump cycle and fresh tapes brought in.
|
||||||
|
.Pp
|
||||||
|
If
|
||||||
|
.Nm
|
||||||
|
receives a
|
||||||
|
.Dv SIGINFO
|
||||||
|
signal
|
||||||
|
(see the
|
||||||
|
.Dq status
|
||||||
|
argument of
|
||||||
|
.Xr stty 1 )
|
||||||
|
whilst a backup is in progress, statistics on the amount completed,
|
||||||
|
current transfer rate, and estimated finished time, will be written
|
||||||
|
to the standard error output.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width /etc/dumpdates -compact
|
.Bl -tag -width /etc/dumpdates -compact
|
||||||
.It Pa /dev/rst0
|
.It Pa /dev/rst0
|
||||||
|
@ -316,14 +345,16 @@ to find group
|
||||||
.Em operator
|
.Em operator
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
|
.Xr dump 5 ,
|
||||||
|
.Xr fstab 5 ,
|
||||||
.Xr restore 8 ,
|
.Xr restore 8 ,
|
||||||
.Xr rmt 8 ,
|
.Xr rmt 8 ,
|
||||||
.Xr dump 5 ,
|
.Xr stty 1
|
||||||
.Xr fstab 5
|
|
||||||
.Sh DIAGNOSTICS
|
.Sh DIAGNOSTICS
|
||||||
Many, and verbose.
|
Many, and verbose.
|
||||||
.Pp
|
.Pp
|
||||||
Dump exits with zero status on success.
|
.Nm
|
||||||
|
exits with zero status on success.
|
||||||
Startup errors are indicated with an exit code of 1;
|
Startup errors are indicated with an exit code of 1;
|
||||||
abnormal termination is indicated with an exit code of 3.
|
abnormal termination is indicated with an exit code of 3.
|
||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
|
@ -333,7 +364,7 @@ Each reel requires a new process, so parent processes for
|
||||||
reels already written just hang around until the entire tape
|
reels already written just hang around until the entire tape
|
||||||
is written.
|
is written.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm Dump
|
.Nm
|
||||||
with the
|
with the
|
||||||
.Fl W
|
.Fl W
|
||||||
or
|
or
|
||||||
|
@ -344,8 +375,13 @@ in
|
||||||
even if listed in
|
even if listed in
|
||||||
.Pa /etc/fstab .
|
.Pa /etc/fstab .
|
||||||
.Pp
|
.Pp
|
||||||
|
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).
|
||||||
|
.Pp
|
||||||
It would be nice if
|
It would be nice if
|
||||||
.Nm dump
|
.Nm
|
||||||
knew about the dump sequence,
|
knew about the dump sequence,
|
||||||
kept track of the tapes scribbled on,
|
kept track of the tapes scribbled on,
|
||||||
told the operator which tape to mount when,
|
told the operator which tape to mount when,
|
||||||
|
@ -354,5 +390,5 @@ for the operator running
|
||||||
.Xr restore .
|
.Xr restore .
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
A
|
A
|
||||||
.Nm dump
|
.Nm
|
||||||
command appeared in Version 6 AT&T UNIX.
|
command appeared in Version 6 AT&T UNIX.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: dump.h,v 1.10 1997/04/10 05:36:23 lukem Exp $ */
|
/* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1993
|
* Copyright (c) 1980, 1993
|
||||||
|
@ -101,13 +101,16 @@ int query __P((char *question));
|
||||||
void quit __P((const char *fmt, ...));
|
void quit __P((const char *fmt, ...));
|
||||||
void set_operators __P((void));
|
void set_operators __P((void));
|
||||||
time_t do_stats __P((void));
|
time_t do_stats __P((void));
|
||||||
|
void statussig __P((int));
|
||||||
void timeest __P((void));
|
void timeest __P((void));
|
||||||
time_t unctime __P((char *str));
|
time_t unctime __P((char *str));
|
||||||
|
|
||||||
/* mapping routines */
|
/* mapping routines */
|
||||||
struct dinode;
|
struct dinode;
|
||||||
long blockest __P((struct dinode *dp));
|
long blockest __P((struct dinode *dp));
|
||||||
int mapfiles __P((ino_t maxino, long *tapesize));
|
void mapfileino __P((ino_t, long *, int *));
|
||||||
|
int mapfiles __P((ino_t maxino, long *tapesize, char *disk,
|
||||||
|
char * const *dirv));
|
||||||
int mapdirs __P((ino_t maxino, long *tapesize));
|
int mapdirs __P((ino_t maxino, long *tapesize));
|
||||||
|
|
||||||
/* file dumping routines */
|
/* file dumping routines */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: dumprmt.c,v 1.15 1997/05/27 08:35:27 mrg Exp $ */
|
/* $NetBSD: dumprmt.c,v 1.16 1997/06/05 11:13:23 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1993
|
* Copyright (c) 1980, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)dumprmt.c 8.1 (Berkeley) 6/5/93";
|
static char sccsid[] = "@(#)dumprmt.c 8.1 (Berkeley) 6/5/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: dumprmt.c,v 1.15 1997/05/27 08:35:27 mrg Exp $";
|
static char rcsid[] = "$NetBSD: dumprmt.c,v 1.16 1997/06/05 11:13:23 lukem Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -91,8 +91,6 @@ static void rmtgets __P((char *, int));
|
||||||
static int rmtreply __P((char *));
|
static int rmtreply __P((char *));
|
||||||
|
|
||||||
extern int ntrec; /* blocking factor on tape */
|
extern int ntrec; /* blocking factor on tape */
|
||||||
extern uid_t uid; /* real uid */
|
|
||||||
extern uid_t euid; /* effective uid */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
rmthost(host)
|
rmthost(host)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: main.c,v 1.13 1997/05/27 08:35:28 mrg Exp $ */
|
/* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1991, 1993, 1994
|
* Copyright (c) 1980, 1991, 1993, 1994
|
||||||
|
@ -43,12 +43,15 @@ static char copyright[] =
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/15/94";
|
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/15/94";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: main.c,v 1.13 1997/05/27 08:35:28 mrg Exp $";
|
static char rcsid[] = "$NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
|
||||||
#ifdef sunos
|
#ifdef sunos
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
|
|
||||||
|
@ -108,6 +111,8 @@ main(argc, argv)
|
||||||
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
|
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
|
||||||
ino_t maxino;
|
ino_t maxino;
|
||||||
time_t tnow;
|
time_t tnow;
|
||||||
|
int dirlist;
|
||||||
|
char *toplevel;
|
||||||
|
|
||||||
spcl.c_date = 0;
|
spcl.c_date = 0;
|
||||||
(void)time((time_t *)&spcl.c_date);
|
(void)time((time_t *)&spcl.c_date);
|
||||||
|
@ -198,15 +203,67 @@ main(argc, argv)
|
||||||
(void)fprintf(stderr, "Must specify disk or filesystem\n");
|
(void)fprintf(stderr, "Must specify disk or filesystem\n");
|
||||||
exit(X_ABORT);
|
exit(X_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* determine if disk is a subdirectory, and setup appropriately
|
||||||
|
*/
|
||||||
|
dirlist = 0;
|
||||||
|
toplevel = NULL;
|
||||||
|
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))
|
||||||
|
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 (!disk) {
|
||||||
|
if ((toplevel = strdup(fsbuf.f_mntonname)) == NULL) {
|
||||||
|
msg("Cannot malloc diskname\n");
|
||||||
|
exit(X_ABORT);
|
||||||
|
}
|
||||||
|
disk = toplevel;
|
||||||
|
if (uflag) {
|
||||||
|
msg("Ignoring u flag for subdir dump\n");
|
||||||
|
uflag = 0;
|
||||||
|
}
|
||||||
|
if (level > '0') {
|
||||||
|
msg("Subdir dump is done at level 0\n");
|
||||||
|
level = '0';
|
||||||
|
}
|
||||||
|
msg("Dumping sub files/directories from %s\n", disk);
|
||||||
|
} else {
|
||||||
|
if (strcmp(disk, fsbuf.f_mntonname) != 0) {
|
||||||
|
msg("%s is not on %s\n", argv[i], disk);
|
||||||
|
exit(X_ABORT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg("Dumping file/directory %s\n", argv[i]);
|
||||||
|
dirlist++;
|
||||||
|
}
|
||||||
|
if (dirlist == 0) {
|
||||||
disk = *argv++;
|
disk = *argv++;
|
||||||
argc--;
|
if (argc != 1) {
|
||||||
if (argc >= 1) {
|
(void)fprintf(stderr, "Excess arguments to dump:");
|
||||||
(void)fprintf(stderr, "Unknown arguments to dump:");
|
while (--argc)
|
||||||
while (argc--)
|
|
||||||
(void)fprintf(stderr, " %s", *argv++);
|
(void)fprintf(stderr, " %s", *argv++);
|
||||||
(void)fprintf(stderr, "\n");
|
(void)fprintf(stderr, "\n");
|
||||||
exit(X_ABORT);
|
exit(X_ABORT);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (Tflag && uflag) {
|
if (Tflag && uflag) {
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"You cannot use the T and u flags together.\n");
|
"You cannot use the T and u flags together.\n");
|
||||||
|
@ -265,6 +322,7 @@ main(argc, argv)
|
||||||
|
|
||||||
set_operators(); /* /etc/group snarfed */
|
set_operators(); /* /etc/group snarfed */
|
||||||
getfstab(); /* /etc/fstab snarfed */
|
getfstab(); /* /etc/fstab snarfed */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* disk can be either the full special file name,
|
* disk can be either the full special file name,
|
||||||
* the suffix of the special file name,
|
* the suffix of the special file name,
|
||||||
|
@ -275,6 +333,10 @@ main(argc, argv)
|
||||||
if (dt != NULL) {
|
if (dt != NULL) {
|
||||||
disk = rawname(dt->fs_spec);
|
disk = rawname(dt->fs_spec);
|
||||||
(void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
|
(void)strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
|
||||||
|
if (dirlist != 0)
|
||||||
|
(void)snprintf(spcl.c_filesys, NAMELEN,
|
||||||
|
"a subset of %s", dt->fs_file);
|
||||||
|
else
|
||||||
(void)strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
|
(void)strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
|
||||||
} else {
|
} else {
|
||||||
(void)strncpy(spcl.c_dev, disk, NAMELEN);
|
(void)strncpy(spcl.c_dev, disk, NAMELEN);
|
||||||
|
@ -329,8 +391,11 @@ main(argc, argv)
|
||||||
|
|
||||||
nonodump = spcl.c_level < honorlevel;
|
nonodump = spcl.c_level < honorlevel;
|
||||||
|
|
||||||
|
(void)signal(SIGINFO, statussig);
|
||||||
|
|
||||||
msg("mapping (Pass I) [regular files]\n");
|
msg("mapping (Pass I) [regular files]\n");
|
||||||
anydirskipped = mapfiles(maxino, &tapesize);
|
anydirskipped = mapfiles(maxino, &tapesize, toplevel,
|
||||||
|
(dirlist ? argv : NULL));
|
||||||
|
|
||||||
msg("mapping (Pass II) [directories]\n");
|
msg("mapping (Pass II) [directories]\n");
|
||||||
while (anydirskipped) {
|
while (anydirskipped) {
|
||||||
|
@ -445,7 +510,7 @@ main(argc, argv)
|
||||||
msg("Date of this level %c dump: %s", level,
|
msg("Date of this level %c dump: %s", level,
|
||||||
spcl.c_date == 0 ? "the epoch\n" : ctime(&spcl.c_date));
|
spcl.c_date == 0 ? "the epoch\n" : ctime(&spcl.c_date));
|
||||||
msg("Date this dump completed: %s", ctime(&tnow));
|
msg("Date this dump completed: %s", ctime(&tnow));
|
||||||
msg("Average transfer rate: %ldK/s\n", xferrate / tapeno);
|
msg("Average transfer rate: %ld KB/s\n", xferrate / tapeno);
|
||||||
putdumptime();
|
putdumptime();
|
||||||
trewind();
|
trewind();
|
||||||
broadcast("DUMP IS DONE!\7\7\n");
|
broadcast("DUMP IS DONE!\7\7\n");
|
||||||
|
@ -550,7 +615,7 @@ obsolete(argcp, argvp)
|
||||||
/* Allocate space for new arguments. */
|
/* Allocate space for new arguments. */
|
||||||
if ((*argvp = nargv = malloc((argc + 1) * sizeof(char *))) == NULL ||
|
if ((*argvp = nargv = malloc((argc + 1) * sizeof(char *))) == NULL ||
|
||||||
(p = flagsp = malloc(strlen(ap) + 2)) == NULL)
|
(p = flagsp = malloc(strlen(ap) + 2)) == NULL)
|
||||||
err(1, NULL);
|
err(1, "malloc");
|
||||||
|
|
||||||
*nargv++ = *argv;
|
*nargv++ = *argv;
|
||||||
argv += 2;
|
argv += 2;
|
||||||
|
@ -569,7 +634,7 @@ obsolete(argcp, argvp)
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
if ((nargv[0] = malloc(strlen(*argv) + 2 + 1)) == NULL)
|
if ((nargv[0] = malloc(strlen(*argv) + 2 + 1)) == NULL)
|
||||||
err(1, NULL);
|
err(1, "malloc");
|
||||||
nargv[0][0] = '-';
|
nargv[0][0] = '-';
|
||||||
nargv[0][1] = *ap;
|
nargv[0][1] = *ap;
|
||||||
(void)strcpy(&nargv[0][2], *argv); /* XXX strcpy is safe */
|
(void)strcpy(&nargv[0][2], *argv); /* XXX strcpy is safe */
|
||||||
|
@ -593,7 +658,8 @@ obsolete(argcp, argvp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy remaining arguments. */
|
/* Copy remaining arguments. */
|
||||||
while (*nargv++ = *argv++);
|
while ((*nargv++ = *argv++) != NULL)
|
||||||
|
;
|
||||||
|
|
||||||
/* Update argument count. */
|
/* Update argument count. */
|
||||||
*argcp = nargv - *argvp - 1;
|
*argcp = nargv - *argvp - 1;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: tape.c,v 1.10 1997/04/15 07:00:49 lukem Exp $ */
|
/* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1991, 1993
|
* Copyright (c) 1980, 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)tape.c 8.2 (Berkeley) 3/17/94";
|
static char sccsid[] = "@(#)tape.c 8.2 (Berkeley) 3/17/94";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: tape.c,v 1.10 1997/04/15 07:00:49 lukem Exp $";
|
static char rcsid[] = "$NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -260,13 +260,38 @@ do_stats()
|
||||||
if (ttaken > 0) {
|
if (ttaken > 0) {
|
||||||
msg("Volume %d took %d:%02d:%02d\n", tapeno,
|
msg("Volume %d took %d:%02d:%02d\n", tapeno,
|
||||||
ttaken / 3600, (ttaken % 3600) / 60, ttaken % 60);
|
ttaken / 3600, (ttaken % 3600) / 60, ttaken % 60);
|
||||||
msg("Volume %d transfer rate: %ldK/s\n", tapeno,
|
msg("Volume %d transfer rate: %ld KB/s\n", tapeno,
|
||||||
blocks / ttaken);
|
blocks / ttaken);
|
||||||
xferrate += blocks / ttaken;
|
xferrate += blocks / ttaken;
|
||||||
}
|
}
|
||||||
return(tnow);
|
return(tnow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* statussig --
|
||||||
|
* information message upon receipt of SIGINFO
|
||||||
|
* (derived from optr.c::timeest())
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
statussig(notused)
|
||||||
|
int notused;
|
||||||
|
{
|
||||||
|
time_t tnow, deltat;
|
||||||
|
char msgbuf[128];
|
||||||
|
|
||||||
|
if (blockswritten < 500)
|
||||||
|
return;
|
||||||
|
(void) time((time_t *) &tnow);
|
||||||
|
deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing))
|
||||||
|
/ blockswritten * tapesize;
|
||||||
|
(void)snprintf(msgbuf, sizeof(msgbuf),
|
||||||
|
"%3.2f%% done at %ld KB/s, finished in %d:%02d\n",
|
||||||
|
(blockswritten * 100.0) / tapesize,
|
||||||
|
(spcl.c_tapea - tapea_volume) / (tnow - tstart_volume),
|
||||||
|
(int)(deltat / 3600), (int)((deltat % 3600) / 60));
|
||||||
|
write(STDERR_FILENO, msgbuf, strlen(msgbuf));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flushtape()
|
flushtape()
|
||||||
{
|
{
|
||||||
|
@ -741,6 +766,7 @@ enslave()
|
||||||
for (j = 0; j <= i; j++)
|
for (j = 0; j <= i; j++)
|
||||||
(void) close(slaves[j].fd);
|
(void) close(slaves[j].fd);
|
||||||
signal(SIGINT, SIG_IGN); /* Master handles this */
|
signal(SIGINT, SIG_IGN); /* Master handles this */
|
||||||
|
signal(SIGINFO, SIG_IGN);
|
||||||
doslave(cmd[0], i);
|
doslave(cmd[0], i);
|
||||||
Exit(X_FINOK);
|
Exit(X_FINOK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: traverse.c,v 1.16 1997/04/15 01:09:54 lukem Exp $ */
|
/* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1988, 1991, 1993
|
* Copyright (c) 1980, 1988, 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)traverse.c 8.2 (Berkeley) 9/23/93";
|
static char sccsid[] = "@(#)traverse.c 8.2 (Berkeley) 9/23/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: traverse.c,v 1.16 1997/04/15 01:09:54 lukem Exp $";
|
static char rcsid[] = "$NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ static char rcsid[] = "$NetBSD: traverse.c,v 1.16 1997/04/15 01:09:54 lukem Exp
|
||||||
#include <protocols/dumprestore.h>
|
#include <protocols/dumprestore.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fts.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -134,26 +136,20 @@ blockest(dp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dump pass 1.
|
* Determine if given inode should be dumped
|
||||||
*
|
|
||||||
* Walk the inode list for a filesystem to find all allocated inodes
|
|
||||||
* that have been modified since the previous dump time. Also, find all
|
|
||||||
* the directories in the filesystem.
|
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
mapfiles(maxino, tapesize)
|
mapfileino(ino, tapesize, dirskipped)
|
||||||
ino_t maxino;
|
ino_t ino;
|
||||||
long *tapesize;
|
long *tapesize;
|
||||||
|
int *dirskipped;
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
ino_t ino;
|
|
||||||
struct dinode *dp;
|
struct dinode *dp;
|
||||||
int anydirskipped = 0;
|
|
||||||
|
|
||||||
for (ino = ROOTINO; ino < maxino; ino++) {
|
|
||||||
dp = getino(ino);
|
dp = getino(ino);
|
||||||
if ((mode = (dp->di_mode & IFMT)) == 0)
|
if ((mode = (dp->di_mode & IFMT)) == 0)
|
||||||
continue;
|
return;
|
||||||
SETINO(ino, usedinomap);
|
SETINO(ino, usedinomap);
|
||||||
if (mode == IFDIR)
|
if (mode == IFDIR)
|
||||||
SETINO(ino, dumpdirmap);
|
SETINO(ino, dumpdirmap);
|
||||||
|
@ -163,10 +159,101 @@ mapfiles(maxino, tapesize)
|
||||||
*tapesize += 1;
|
*tapesize += 1;
|
||||||
else
|
else
|
||||||
*tapesize += blockest(dp);
|
*tapesize += blockest(dp);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
if (mode == IFDIR)
|
if (mode == IFDIR)
|
||||||
anydirskipped = 1;
|
*dirskipped = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dump pass 1.
|
||||||
|
*
|
||||||
|
* Walk the inode list for a filesystem to find all allocated inodes
|
||||||
|
* that have been modified since the previous dump time. Also, find all
|
||||||
|
* the directories in the filesystem.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
mapfiles(maxino, tapesize, disk, dirv)
|
||||||
|
ino_t maxino;
|
||||||
|
long *tapesize;
|
||||||
|
char *disk;
|
||||||
|
char * const *dirv;
|
||||||
|
{
|
||||||
|
int anydirskipped = 0;
|
||||||
|
|
||||||
|
if (dirv != NULL) {
|
||||||
|
char curdir[MAXPATHLEN];
|
||||||
|
FTS *dirh;
|
||||||
|
FTSENT *entry;
|
||||||
|
int d;
|
||||||
|
|
||||||
|
if (getcwd(curdir, sizeof(curdir)) == NULL) {
|
||||||
|
msg("Can't determine cwd: %s\n", strerror(errno));
|
||||||
|
dumpabort(0);
|
||||||
|
}
|
||||||
|
if ((dirh = fts_open(dirv, FTS_PHYSICAL|FTS_SEEDOT|FTS_XDEV,
|
||||||
|
(int (*)())NULL)) == NULL) {
|
||||||
|
msg("fts_open failed: %s\n", strerror(errno));
|
||||||
|
dumpabort(0);
|
||||||
|
}
|
||||||
|
while ((entry = fts_read(dirh)) != NULL) {
|
||||||
|
switch (entry->fts_info) {
|
||||||
|
case FTS_DNR: /* an error */
|
||||||
|
case FTS_ERR:
|
||||||
|
case FTS_NS:
|
||||||
|
msg("Can't fts_read %s: %s\n", entry->fts_path,
|
||||||
|
strerror(errno));
|
||||||
|
case FTS_DP: /* already seen dir */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mapfileino(entry->fts_statp->st_ino, tapesize,
|
||||||
|
&anydirskipped);
|
||||||
|
}
|
||||||
|
(void)fts_close(dirh);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add any parent directories
|
||||||
|
*/
|
||||||
|
for (d = 0 ; dirv[d] != NULL ; d++) {
|
||||||
|
char path[MAXPATHLEN];
|
||||||
|
|
||||||
|
if (dirv[d][0] != '/')
|
||||||
|
(void)snprintf(path, sizeof(path), "%s/%s",
|
||||||
|
curdir, dirv[d]);
|
||||||
|
else
|
||||||
|
(void)snprintf(path, sizeof(path), "%s",
|
||||||
|
dirv[d]);
|
||||||
|
while (strcmp(path, disk) != 0) {
|
||||||
|
char *p;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if (*path == '\0')
|
||||||
|
break;
|
||||||
|
if ((p = strrchr(path, '/')) == NULL)
|
||||||
|
break;
|
||||||
|
if (p == path)
|
||||||
|
break;
|
||||||
|
*p = '\0';
|
||||||
|
if (stat(path, &sb) == -1) {
|
||||||
|
msg("Can't stat %s: %s\n", path,
|
||||||
|
strerror(errno));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mapfileino(sb.st_ino, tapesize, &anydirskipped);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that the root inode actually appears in the
|
||||||
|
* file list for a subdir
|
||||||
|
*/
|
||||||
|
mapfileino(ROOTINO, tapesize, &anydirskipped);
|
||||||
|
} else {
|
||||||
|
ino_t ino;
|
||||||
|
|
||||||
|
for (ino = ROOTINO; ino < maxino; ino++) {
|
||||||
|
mapfileino(ino, tapesize, &anydirskipped);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Restore gets very upset if the root is not dumped,
|
* Restore gets very upset if the root is not dumped,
|
||||||
|
|
Loading…
Reference in New Issue