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