|
|
6717ab |
diff -up util-linux-2.23.2/misc-utils/wipefs.8.kzak util-linux-2.23.2/misc-utils/wipefs.8
|
|
|
6717ab |
--- util-linux-2.23.2/misc-utils/wipefs.8.kzak 2013-07-30 10:39:26.232738496 +0200
|
|
|
6717ab |
+++ util-linux-2.23.2/misc-utils/wipefs.8 2014-01-23 11:07:54.390022299 +0100
|
|
|
6717ab |
@@ -23,6 +23,9 @@ does not erase the filesystem itself nor
|
|
|
6717ab |
When used without options \fB-a\fR or \fB-o\fR, it lists all visible filesystems
|
|
|
6717ab |
and the offsets of their basic signatures.
|
|
|
6717ab |
|
|
|
6717ab |
+.B wipefs
|
|
|
6717ab |
+calls BLKRRPART ioctl when erase partition table to inform kernel about the change.
|
|
|
6717ab |
+
|
|
|
6717ab |
Note that some filesystems or some partition tables store more magic strings on
|
|
|
6717ab |
the devices. The
|
|
|
6717ab |
.B wipefs
|
|
|
6717ab |
diff -up util-linux-2.23.2/misc-utils/wipefs.c.kzak util-linux-2.23.2/misc-utils/wipefs.c
|
|
|
6717ab |
--- util-linux-2.23.2/misc-utils/wipefs.c.kzak 2013-07-30 10:39:26.232738496 +0200
|
|
|
6717ab |
+++ util-linux-2.23.2/misc-utils/wipefs.c 2014-01-23 11:12:26.786860550 +0100
|
|
|
6717ab |
@@ -40,21 +40,24 @@
|
|
|
6717ab |
#include "c.h"
|
|
|
6717ab |
#include "closestream.h"
|
|
|
6717ab |
#include "optutils.h"
|
|
|
6717ab |
+#include "blkdev.h"
|
|
|
6717ab |
|
|
|
6717ab |
struct wipe_desc {
|
|
|
6717ab |
loff_t offset; /* magic string offset */
|
|
|
6717ab |
size_t len; /* length of magic string */
|
|
|
6717ab |
unsigned char *magic; /* magic string */
|
|
|
6717ab |
|
|
|
6717ab |
- int zap; /* zap this offset? */
|
|
|
6717ab |
char *usage; /* raid, filesystem, ... */
|
|
|
6717ab |
char *type; /* FS type */
|
|
|
6717ab |
char *label; /* FS label */
|
|
|
6717ab |
char *uuid; /* FS uuid */
|
|
|
6717ab |
|
|
|
6717ab |
- int on_disk;
|
|
|
6717ab |
-
|
|
|
6717ab |
struct wipe_desc *next;
|
|
|
6717ab |
+
|
|
|
6717ab |
+ unsigned int zap : 1,
|
|
|
6717ab |
+ on_disk : 1,
|
|
|
6717ab |
+ is_parttable : 1;
|
|
|
6717ab |
+
|
|
|
6717ab |
};
|
|
|
6717ab |
|
|
|
6717ab |
enum {
|
|
|
6717ab |
@@ -72,7 +75,7 @@ print_pretty(struct wipe_desc *wp, int l
|
|
|
6717ab |
printf("----------------------------------------------------------------\n");
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
- printf("0x%-17jx %s [%s]", wp->offset, wp->type, wp->usage);
|
|
|
6717ab |
+ printf("0x%-17jx %s [%s]", wp->offset, wp->type, _(wp->usage));
|
|
|
6717ab |
|
|
|
6717ab |
if (wp->label && *wp->label)
|
|
|
6717ab |
printf("\n%27s %s", "LABEL:", wp->label);
|
|
|
6717ab |
@@ -141,7 +144,7 @@ add_offset(struct wipe_desc *wp0, loff_t
|
|
|
6717ab |
wp = xcalloc(1, sizeof(struct wipe_desc));
|
|
|
6717ab |
wp->offset = offset;
|
|
|
6717ab |
wp->next = wp0;
|
|
|
6717ab |
- wp->zap = zap;
|
|
|
6717ab |
+ wp->zap = zap ? 1 : 0;
|
|
|
6717ab |
return wp;
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
@@ -164,7 +167,7 @@ get_desc_for_probe(struct wipe_desc *wp,
|
|
|
6717ab |
const char *off, *type, *mag, *p, *usage = NULL;
|
|
|
6717ab |
size_t len;
|
|
|
6717ab |
loff_t offset;
|
|
|
6717ab |
- int rc;
|
|
|
6717ab |
+ int rc, ispt = 0;
|
|
|
6717ab |
|
|
|
6717ab |
/* superblocks */
|
|
|
6717ab |
if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) == 0) {
|
|
|
6717ab |
@@ -181,7 +184,8 @@ get_desc_for_probe(struct wipe_desc *wp,
|
|
|
6717ab |
rc = blkid_probe_lookup_value(pr, "PTMAGIC", &mag, &len;;
|
|
|
6717ab |
if (rc)
|
|
|
6717ab |
return wp;
|
|
|
6717ab |
- usage = "partition table";
|
|
|
6717ab |
+ usage = N_("partition table");
|
|
|
6717ab |
+ ispt = 1;
|
|
|
6717ab |
} else
|
|
|
6717ab |
return wp;
|
|
|
6717ab |
|
|
|
6717ab |
@@ -199,6 +203,7 @@ get_desc_for_probe(struct wipe_desc *wp,
|
|
|
6717ab |
|
|
|
6717ab |
wp->type = xstrdup(type);
|
|
|
6717ab |
wp->on_disk = 1;
|
|
|
6717ab |
+ wp->is_parttable = ispt ? 1 : 0;
|
|
|
6717ab |
|
|
|
6717ab |
wp->magic = xmalloc(len);
|
|
|
6717ab |
memcpy(wp->magic, mag, len);
|
|
|
6717ab |
@@ -309,10 +314,25 @@ static void do_wipe_real(blkid_probe pr,
|
|
|
6717ab |
putchar('\n');
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
+
|
|
|
6717ab |
+static void rereadpt(int fd, const char *devname)
|
|
|
6717ab |
+{
|
|
|
6717ab |
+#ifdef BLKRRPART
|
|
|
6717ab |
+ struct stat st;
|
|
|
6717ab |
+
|
|
|
6717ab |
+ if (fstat(fd, &st) || !S_ISBLK(st.st_mode))
|
|
|
6717ab |
+ return;
|
|
|
6717ab |
+
|
|
|
6717ab |
+ errno = 0;
|
|
|
6717ab |
+ ioctl(fd, BLKRRPART);
|
|
|
6717ab |
+ printf(_("%s: calling ioclt to re-read partition table: %m\n"), devname);
|
|
|
6717ab |
+#endif
|
|
|
6717ab |
+}
|
|
|
6717ab |
+
|
|
|
6717ab |
static struct wipe_desc *
|
|
|
6717ab |
do_wipe(struct wipe_desc *wp, const char *devname, int noact, int all, int quiet, int force)
|
|
|
6717ab |
{
|
|
|
6717ab |
- int flags;
|
|
|
6717ab |
+ int flags, reread = 0;
|
|
|
6717ab |
blkid_probe pr;
|
|
|
6717ab |
struct wipe_desc *w, *wp0;
|
|
|
6717ab |
int zap = all ? 1 : wp->zap;
|
|
|
6717ab |
@@ -345,8 +365,11 @@ do_wipe(struct wipe_desc *wp, const char
|
|
|
6717ab |
if (!wp->on_disk)
|
|
|
6717ab |
continue;
|
|
|
6717ab |
|
|
|
6717ab |
- if (zap)
|
|
|
6717ab |
+ if (zap) {
|
|
|
6717ab |
do_wipe_real(pr, devname, wp, noact, quiet);
|
|
|
6717ab |
+ if (wp->is_parttable)
|
|
|
6717ab |
+ reread = 1;
|
|
|
6717ab |
+ }
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
for (w = wp0; w != NULL; w = w->next) {
|
|
|
6717ab |
@@ -355,6 +378,10 @@ do_wipe(struct wipe_desc *wp, const char
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
fsync(blkid_probe_get_fd(pr));
|
|
|
6717ab |
+
|
|
|
6717ab |
+ if (reread)
|
|
|
6717ab |
+ rereadpt(blkid_probe_get_fd(pr), devname);
|
|
|
6717ab |
+
|
|
|
6717ab |
close(blkid_probe_get_fd(pr));
|
|
|
6717ab |
blkid_free_probe(pr);
|
|
|
6717ab |
free_wipe(wp0);
|