Improved error checking for existence of a .snap directory to

generate snapshots in when -L is requested.  If the .snap directory
does not exist, or is not a directory, issue a warning and revert
to the non- live behavior.

Obtained from:	St. Bernard Software RAPID
This commit is contained in:
wes 2005-01-21 22:13:25 +00:00
parent 0b29d18074
commit bb68fc2b6e
2 changed files with 29 additions and 18 deletions

View File

@ -237,9 +237,9 @@ This option is ignored for unmounted or read-only file systems.
If the If the
.Pa .snap .Pa .snap
directory does not exist in the root of the file system being dumped, directory does not exist in the root of the file system being dumped,
the a warning will be issued and the
.Nm .Nm
will fail. will revert to the standard behavior.
This problem can be corrected by creating a This problem can be corrected by creating a
.Pa .snap .Pa .snap
directory in the root of the file system to be dumped; directory in the root of the file system to be dumped;
@ -271,7 +271,7 @@ The default tape length is 2300 feet.
.It Fl T Ar date .It Fl T Ar date
Use the specified date as the starting time for the dump Use the specified date as the starting time for the dump
instead of the time determined from looking in instead of the time determined from looking in
the a warning will be issued and the
.Pa dumpdates .Pa dumpdates
file. file.
The format of date is the same as that of The format of date is the same as that of

View File

@ -336,23 +336,34 @@ main(int argc, char *argv[])
} else { } else {
char snapname[BUFSIZ], snapcmd[BUFSIZ]; char snapname[BUFSIZ], snapcmd[BUFSIZ];
snprintf(snapname, sizeof snapname, snprintf(snapname, sizeof snapname, "%s/.snap", mntpt);
"%s/.snap/dump_snapshot", mntpt); if ((stat(snapname, &sb) < 0) || !S_ISDIR(sb.st_mode)) {
snprintf(snapcmd, sizeof snapcmd, "%s %s %s", msg("WARNING: %s %s\n",
_PATH_MKSNAP_FFS, mntpt, snapname); "-L requested but snapshot location",
unlink(snapname); snapname);
if (system(snapcmd) != 0) msg(" %s: %s\n",
errx(X_STARTUP, "Cannot create %s: %s\n", "is not a directory",
snapname, strerror(errno)); "dump downgraded, -L ignored");
if ((diskfd = open(snapname, O_RDONLY)) < 0) { snapdump = 0;
} else {
snprintf(snapname, sizeof snapname,
"%s/.snap/dump_snapshot", mntpt);
snprintf(snapcmd, sizeof snapcmd, "%s %s %s",
_PATH_MKSNAP_FFS, mntpt, snapname);
unlink(snapname); unlink(snapname);
errx(X_STARTUP, "Cannot open %s: %s\n", if (system(snapcmd) != 0)
snapname, strerror(errno)); errx(X_STARTUP, "Cannot create %s: %s\n",
snapname, strerror(errno));
if ((diskfd = open(snapname, O_RDONLY)) < 0) {
unlink(snapname);
errx(X_STARTUP, "Cannot open %s: %s\n",
snapname, strerror(errno));
}
unlink(snapname);
if (fstat(diskfd, &sb) != 0)
err(X_STARTUP, "%s: stat", snapname);
spcl.c_date = _time_to_time64(sb.st_mtime);
} }
unlink(snapname);
if (fstat(diskfd, &sb) != 0)
err(X_STARTUP, "%s: stat", snapname);
spcl.c_date = _time_to_time64(sb.st_mtime);
} }
} else if (snapdump != 0) { } else if (snapdump != 0) {
msg("WARNING: Cannot use -L on an unmounted filesystem.\n"); msg("WARNING: Cannot use -L on an unmounted filesystem.\n");