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 Peters 2005-01-21 22:13:25 +00:00
parent a5947c18a8
commit 73e31afa1a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140602
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
.Pa .snap
directory does not exist in the root of the file system being dumped,
the
a warning will be issued and the
.Nm
will fail.
will revert to the standard behavior.
This problem can be corrected by creating a
.Pa .snap
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
Use the specified date as the starting time for the dump
instead of the time determined from looking in
the
a warning will be issued and the
.Pa dumpdates
file.
The format of date is the same as that of

View File

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