From afa14114534d3fcf296411bb2b988f1b5a5a14ad Mon Sep 17 00:00:00 2001 From: mckusick Date: Sun, 16 Nov 2003 08:01:58 +0000 Subject: 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. --- sbin/dump/main.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'sbin') 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", -- cgit v1.1