summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/dump/dump.86
-rw-r--r--sbin/dump/main.c41
2 files changed, 29 insertions, 18 deletions
diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8
index adf1708..26df180 100644
--- a/sbin/dump/dump.8
+++ b/sbin/dump/dump.8
@@ -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
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 09c27ab..96f9230 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -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);
+ 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);
- errx(X_STARTUP, "Cannot open %s: %s\n",
- snapname, strerror(errno));
+ 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");
OpenPOWER on IntegriCloud