diff options
author | wes <wes@FreeBSD.org> | 2005-01-21 22:13:25 +0000 |
---|---|---|
committer | wes <wes@FreeBSD.org> | 2005-01-21 22:13:25 +0000 |
commit | bb68fc2b6ee344a5c2eecf55c47280bcfd199d8f (patch) | |
tree | dc89c6cf6bb7d9bf958470a22560828f84c5fdb4 /sbin | |
parent | 0b29d180747fdc5be41fd0b0924255d0a46641e8 (diff) | |
download | FreeBSD-src-bb68fc2b6ee344a5c2eecf55c47280bcfd199d8f.zip FreeBSD-src-bb68fc2b6ee344a5c2eecf55c47280bcfd199d8f.tar.gz |
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
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dump/dump.8 | 6 | ||||
-rw-r--r-- | sbin/dump/main.c | 41 |
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"); |