aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/ufs_copy
diff options
context:
space:
mode:
authornobutaka <nobutaka@FreeBSD.org>2008-03-23 23:26:37 +0800
committernobutaka <nobutaka@FreeBSD.org>2008-03-23 23:26:37 +0800
commitdbc3e8ada85b43ca0822f42ed13d45956239bbd5 (patch)
tree4c77c45dbc43d378770bf3947c05e0e2a5eb817c /sysutils/ufs_copy
parente49b812658aed16a49e6e9f163cb1be10014428f (diff)
downloadfreebsd-ports-gnome-dbc3e8ada85b43ca0822f42ed13d45956239bbd5.tar.gz
freebsd-ports-gnome-dbc3e8ada85b43ca0822f42ed13d45956239bbd5.tar.zst
freebsd-ports-gnome-dbc3e8ada85b43ca0822f42ed13d45956239bbd5.zip
Fix error on copying snapshots on 7-stable or later.
Diffstat (limited to 'sysutils/ufs_copy')
-rw-r--r--sysutils/ufs_copy/Makefile1
-rw-r--r--sysutils/ufs_copy/files/patch-ufs_copy.c60
2 files changed, 61 insertions, 0 deletions
diff --git a/sysutils/ufs_copy/Makefile b/sysutils/ufs_copy/Makefile
index ba2429885d27..081161414d64 100644
--- a/sysutils/ufs_copy/Makefile
+++ b/sysutils/ufs_copy/Makefile
@@ -7,6 +7,7 @@
PORTNAME= ufs_copy
PORTVERSION= 20060921
+PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= http://people.freebsd.org/~simokawa/ufs/
DISTNAME= ufs-${PORTVERSION}
diff --git a/sysutils/ufs_copy/files/patch-ufs_copy.c b/sysutils/ufs_copy/files/patch-ufs_copy.c
new file mode 100644
index 000000000000..318f6818b2ba
--- /dev/null
+++ b/sysutils/ufs_copy/files/patch-ufs_copy.c
@@ -0,0 +1,60 @@
+--- ufs_copy.c.orig 2006-09-21 15:28:09.000000000 +0900
++++ ufs_copy.c 2007-12-27 23:28:55.000000000 +0900
+@@ -111,9 +111,11 @@
+ main(int argc, char *argv[])
+ {
+ struct fstab *fs;
+- int ch, eval=0;
++ int ch, eval=0, md;
+ char *snapshot = NULL;
+- char *src, *dst;
++ char *src, *dst, *snap = NULL;
++ char mddev[256];
++ FILE *readp;
+
+ #ifdef USEMMAP
+ while ((ch = getopt(argc, argv, "aBb:ceMms:v")) != -1)
+@@ -174,6 +176,21 @@
+ eval = system(buf);
+ if (eval)
+ errx(eval, "mksnap_ffs failed");
++
++ snprintf(buf, sizeof(buf),
++ "/sbin/mdconfig -a -n -t vnode -f %s", src);
++ fprintf(stderr, "%s\n", buf);
++ readp = popen(buf, "r");
++ if (readp == NULL)
++ errx(eval, "mdconfig failed");
++ eval = fscanf(readp, "%d", &md);
++ if (eval != 1)
++ errx(eval, "mdconfig failed");
++ pclose(readp);
++ snprintf(mddev, sizeof(mddev), "/dev/md%d", md);
++ snap = src;
++ src = mddev;
++ fprintf(stderr, "attached %s as memory disk %s\n", snap, mddev);
+ }
+
+ if ((fs = getfsfile(src)) == NULL) {
+@@ -188,9 +205,19 @@
+ }
+
+ if (snapshot) {
+- fprintf(stderr, "removing snapshot file %s ... ", src);
++ char buf[1024];
++
++ snprintf(buf, sizeof(buf),
++ "/sbin/mdconfig -d -u %d", md);
++ fprintf(stderr, "%s\n", buf);
++ eval = system(buf);
++ if (eval)
++ errx(eval, "mdconfig failed");
++ fprintf(stderr, "detached memory disk %s\n", mddev);
++
++ fprintf(stderr, "removing snapshot file %s ... ", snap);
+ fflush(stderr);
+- if (unlink(src) == 0)
++ if (unlink(snap) == 0)
+ fprintf(stderr, "done\n");
+ else
+ fprintf(stderr, "failed\n");