summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2003-11-16 08:01:58 +0000
committermckusick <mckusick@FreeBSD.org>2003-11-16 08:01:58 +0000
commitafa14114534d3fcf296411bb2b988f1b5a5a14ad (patch)
tree72c2888172ce60ae1610bedac4b0351f3999c438 /sbin
parent712f69cd3ea5d8c2856298bd5c67eefc88421784 (diff)
downloadFreeBSD-src-afa14114534d3fcf296411bb2b988f1b5a5a14ad.zip
FreeBSD-src-afa14114534d3fcf296411bb2b988f1b5a5a14ad.tar.gz
Convert the live dump command (`dump -L') to use mksnap_ffs instead
of trying to directly create the snapshot itself. This change allows users logged into the system as operator to run live dumps. Note that dump no longer tries to create the snapshot in the root of the filesystem, but rather in a .snap directory in the root of the filesystem. The reason is that the operator is usually not permitted to write into the root of the filesystem. The newfs command and background fsck have both been modified to create a .snap directory in the root of the filesystem, but if neither of these have been run, then the .snap directory must be created manually by the superuser before a live dump can be run. The .snap directory should be owned by user root and group operator and set to mode 770.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dump/main.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 7940063..432d185 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -317,20 +317,16 @@ main(int argc, char *argv[])
msg("WARNING: %s\n",
"should use -L when dumping live filesystems!");
} else {
- struct ufs_args args;
- char snapname[BUFSIZ];
-
- snprintf(snapname, sizeof snapname, "%s/.dump_snapshot",
- mntpt);
- args.fspec = snapname;
- while (mount("ffs", mntpt,
- mntflags | MNT_UPDATE | MNT_SNAPSHOT,
- &args) < 0) {
- if (errno == EEXIST && unlink(snapname) == 0)
- continue;
+ char snapname[BUFSIZ], snapcmd[BUFSIZ];
+
+ snprintf(snapname, sizeof snapname,
+ "%s/.snap/dump_snapshot", mntpt);
+ snprintf(snapcmd, sizeof snapcmd,
+ "mksnap_ffs %s %s", 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",
OpenPOWER on IntegriCloud