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.
This commit is contained in:
Kirk McKusick 2003-11-16 08:01:58 +00:00
parent 5e36d52bef
commit d46b52859a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122787

View File

@ -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];
char snapname[BUFSIZ], snapcmd[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;
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",