diff options
| author | hannken <hannken@NetBSD.org> | 2011-02-24 09:38:57 +0000 |
|---|---|---|
| committer | hannken <hannken@NetBSD.org> | 2011-02-24 09:38:57 +0000 |
| commit | d888d6cda5b11b23ea998ecef3762ef795dfbbc9 (patch) | |
| tree | 8eb94ba88d762811dcb3ea716cfd2134f8da0177 /sbin/dump | |
| parent | 1a0e59f16c9799bcb19c1529b59e6c836e946305 (diff) | |
fss(4): Allow FSSIOCSET to set the initial flags. Add a new flag
"FSS_UNLINK_ON_CREATE" to unlink the backing store before
the snapshot gets created.
With this change dump(8) no longer dumps the zero-sized, but named
snapshot it is working on. Same applies to fsck_ffs(8).
Diffstat (limited to 'sbin/dump')
| -rw-r--r-- | sbin/dump/snapshot.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sbin/dump/snapshot.c b/sbin/dump/snapshot.c index 770887f0362..df461e9dc43 100644 --- a/sbin/dump/snapshot.c +++ b/sbin/dump/snapshot.c @@ -1,4 +1,4 @@ -/* $NetBSD: snapshot.c,v 1.5 2010/04/11 08:23:51 hannken Exp $ */ +/* $NetBSD: snapshot.c,v 1.6 2011/02/24 09:38:57 hannken Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ int snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) { - int i, n, fd, israw, fsinternal, dounlink, flags; + int i, n, fd, israw, fsinternal, dounlink; char path[MAXPATHLEN], fss_dev[14], *cp; dev_t mountdev; struct fss_set fss; @@ -144,6 +144,9 @@ snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) if (close(fd) < 0) goto fail; + fss.fss_flags = FSS_UNCONFIG_ON_CLOSE; + if (dounlink) + fss.fss_flags |= FSS_UNLINK_ON_CREATE; /* * Create the snapshot on the first free snapshot device. */ @@ -152,9 +155,6 @@ snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) if ((fd = open(fss_dev, O_RDWR, 0)) < 0) goto fail; - if (ioctl(fd, FSSIOFGET, &flags) < 0) - goto fail; - if (ioctl(fd, FSSIOCSET, &fss) < 0) { if (errno != EBUSY) goto fail; @@ -162,6 +162,7 @@ snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) fd = -1; continue; } + dounlink = 0; if (snap_dev != NULL) { *snap_dev = strdup(fss_dev); @@ -171,10 +172,7 @@ snap_open(char *file, char *backup, time_t *snap_date, char **snap_dev) } } - flags |= FSS_UNCONFIG_ON_CLOSE; - if (ioctl(fd, FSSIOCGET, &fsg) < 0 || - ioctl(fd, FSSIOFSET, &flags) < 0 || - (!israw && unlink(fss.fss_bstore) < 0)) { + if (ioctl(fd, FSSIOCGET, &fsg) < 0) { ioctl(fd, FSSIOCCLR); goto fail; } |
