From: Karel Zak Date: Fri, 26 May 2017 11:11:37 +0000 (+0200) Subject: wipefs: print all signature permutations X-Git-Tag: v2.31-rc1~248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92296e9ba2bf95259520fa7537ff8edc2aa9edbc;p=thirdparty%2Futil-linux.git wipefs: print all signature permutations The same FS/RAID/PT signature may be detected by more ways and on more places on the device. The libblkid returns only the first detected signature by default. This patch use blkid_probe_hide_range() to re-scan device for all possible permutations of the same signature. For example the default wipefs(8) output as well as --no-act output will contains primary as well as backup GPT signature now. Reported-by: Ruediger Meier Signed-off-by: Karel Zak --- diff --git a/misc-utils/wipefs.8 b/misc-utils/wipefs.8 index b7c7467feb..283c0b0e5a 100644 --- a/misc-utils/wipefs.8 +++ b/misc-utils/wipefs.8 @@ -16,9 +16,9 @@ can erase filesystem, raid or partition-table signatures (magic strings) from the specified .I device to make the signatures invisible for libblkid. - .B wipefs does not erase the filesystem itself nor any other data from the device. + When used without any options, \fBwipefs\fR lists all visible filesystems and the offsets of their basic signatures. @@ -27,14 +27,10 @@ calls the BLKRRPART ioctl when it has erased a partition-table signature to inform the kernel about the change. Note that some filesystems and some partition tables store more magic strings on -the device. The +the device (e.g. FAT, ZFS, GPT). The .B wipefs -command lists only the first offset where a magic string has been detected. The device -is not scanned for additional magic strings for the same filesystem. It is possible -that after a \fBwipefs -o \fIoffset\fR the same filesystem or partition -table will still be visible because of another magic string on another offset. The -option \fB\-\-no\-act\fR is also affected by this behavior and only the first -magic string for the filesystem is reported. +command (since v2.31) lists all the offset where a magic strings have been +detected. When option \fB-a\fR is used, all magic strings that are visible for libblkid are erased. In this case the diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 87abba39be..e17d6b4a0d 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -281,6 +281,10 @@ read_offsets(struct wipe_desc *wp, const char *devname) wp = get_desc_for_probe(wp, pr); if (!wp) break; + + /* hide last detected signature and scan again */ + blkid_probe_hide_range(pr, wp->offset, wp->len); + blkid_probe_step_back(pr); } blkid_free_probe(pr);