[util-linux/f18] Include wipefs --force option (upstream patch) to fix virt-format program.
Richard W.M. Jones
rjones at fedoraproject.org
Mon Dec 3 17:42:15 UTC 2012
commit 20e038086e288c0f352466f28e5eb09ca7d826bc
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Mon Dec 3 17:40:03 2012 +0000
Include wipefs --force option (upstream patch) to fix virt-format program.
util-linux.spec | 6 +-
wipefs-Add-force-option-to-force-it-to-erase.patch | 104 ++++++++++++++++++++
2 files changed, 109 insertions(+), 1 deletions(-)
---
diff --git a/util-linux.spec b/util-linux.spec
index 0602229..1adc507 100644
--- a/util-linux.spec
+++ b/util-linux.spec
@@ -2,7 +2,7 @@
Summary: A collection of basic system utilities
Name: util-linux
Version: 2.22.1
-Release: 2.3%{?dist}
+Release: 2.4%{?dist}
License: GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ and BSD with advertising and Public Domain
Group: System Environment/Base
URL: http://en.wikipedia.org/wiki/Util-linux
@@ -99,6 +99,7 @@ Patch108: 0008-lib-loopdev-check-for-sys.patch
# 0009-fsck.cramfs-compile-with-DINCLUDE_FS_TESTS-for-make-.patch
Patch110: 0010-login-fix-compiler-warning-Wunused-result.patch
Patch111: 0011-misc-make-readlink-usage-more-robust.patch
+Patch112: wipefs-Add-force-option-to-force-it-to-erase.patch
%description
@@ -741,6 +742,9 @@ fi
%changelog
+* Mon Dec 3 2012 Richard W.M. Jones <rjones at redhat.com> 2.22.1-2.4
+- Include wipefs --force option (upstream patch) to fix virt-format program.
+
* Mon Nov 19 2012 Karel Zak <kzak at redhat.com> 2.22.1-2.3
- use for() to apply patches, cleanup sources file
diff --git a/wipefs-Add-force-option-to-force-it-to-erase.patch b/wipefs-Add-force-option-to-force-it-to-erase.patch
new file mode 100644
index 0000000..3d08df9
--- /dev/null
+++ b/wipefs-Add-force-option-to-force-it-to-erase.patch
@@ -0,0 +1,104 @@
+From 2968c3fc7388f88b8debe64d61d9785601c16436 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones at redhat.com>
+Date: Mon, 19 Nov 2012 15:02:13 +0000
+Subject: [PATCH] wipefs: Add --force option to force it to erase.
+
+Commit c550f728f724360f99aae0fdb45b0589d9a347e0 added O_EXCL when
+opening the thing to erase. This broke the wipefs utility when used
+on anything which isn't an unmounted filesystem. eg. If you use it on
+a block device containing partitions, then it won't work because the
+kernel recognizes the partitions and so thinks the device is in use.
+
+This change adds the --force option which, when used, undoes the above
+flag change. However you still have to use --force most of the time
+when erasing something that isn't a plain unmounted filesystem.
+
+Signed-off-by: Richard W.M. Jones <rjones at redhat.com>
+---
+ misc-utils/wipefs.8 | 3 +++
+ misc-utils/wipefs.c | 19 +++++++++++++++----
+ 2 files changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/misc-utils/wipefs.8 b/misc-utils/wipefs.8
+index 05a5496..67261ee 100644
+--- a/misc-utils/wipefs.8
++++ b/misc-utils/wipefs.8
+@@ -38,6 +38,9 @@ erased.
+ .IP "\fB\-a, \-\-all\fP"
+ Erase all available signatures. This set of erased signatures could be
+ restricted by \fB\-t <list>\fP option.
++.IP "\fB\-f, \-\-force\fP"
++Force erasure, even if the filesystem is mounted. This is required in
++order to erase the partition table on a block device.
+ .IP "\fB\-h, \-\-help\fP"
+ Print help and exit.
+ .IP "\fB\-n, \-\-no\-act\fP"
+diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
+index 0ddc148..a29f3cc 100644
+--- a/misc-utils/wipefs.c
++++ b/misc-utils/wipefs.c
+@@ -307,12 +307,17 @@ static void do_wipe_real(blkid_probe pr, const char *devname, struct wipe_desc *
+ }
+
+ static struct wipe_desc *
+-do_wipe(struct wipe_desc *wp, const char *devname, int noact, int all, int quiet)
++do_wipe(struct wipe_desc *wp, const char *devname, int noact, int all, int quiet, int force)
+ {
+- blkid_probe pr = new_probe(devname, O_RDWR | O_EXCL);
++ int flags;
++ blkid_probe pr;
+ struct wipe_desc *w, *wp0 = clone_offset(wp);
+ int zap = all ? 1 : wp->zap;
+
++ flags = O_RDWR;
++ if (!force)
++ flags |= O_EXCL;
++ pr = new_probe(devname, flags);
+ if (!pr)
+ return NULL;
+
+@@ -362,6 +367,7 @@ usage(FILE *out)
+
+ fputs(_("\nOptions:\n"), out);
+ fputs(_(" -a, --all wipe all magic strings (BE CAREFUL!)\n"
++ " -f, --force force erasure\n"
+ " -h, --help show this help text\n"
+ " -n, --no-act do everything except the actual write() call\n"
+ " -o, --offset <num> offset to erase, in bytes\n"
+@@ -380,11 +386,12 @@ int
+ main(int argc, char **argv)
+ {
+ struct wipe_desc *wp0 = NULL, *wp;
+- int c, all = 0, has_offset = 0, noact = 0, quiet = 0;
++ int c, all = 0, force = 0, has_offset = 0, noact = 0, quiet = 0;
+ int mode = WP_MODE_PRETTY;
+
+ static const struct option longopts[] = {
+ { "all", 0, 0, 'a' },
++ { "force", 0, 0, 'f' },
+ { "help", 0, 0, 'h' },
+ { "no-act", 0, 0, 'n' },
+ { "offset", 1, 0, 'o' },
+@@ -414,6 +421,9 @@ main(int argc, char **argv)
+ case 'a':
+ all++;
+ break;
++ case 'f':
++ force++;
++ break;
+ case 'h':
+ usage(stdout);
+ break;
+@@ -463,7 +473,8 @@ main(int argc, char **argv)
+ */
+ while (optind < argc) {
+ wp = clone_offset(wp0);
+- wp = do_wipe(wp, argv[optind++], noact, all, quiet);
++ wp = do_wipe(wp, argv[optind++], noact, all, quiet,
++ force);
+ free_wipe(wp);
+ }
+ }
+--
+1.7.11.4
+
More information about the scm-commits
mailing list