]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wipefs: use blkid_probe_open_device()
authorKarel Zak <kzak@redhat.com>
Tue, 30 Jun 2026 13:52:08 +0000 (15:52 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 9 Jul 2026 10:18:04 +0000 (12:18 +0200)
Convert wipefs new_probe() to use blkid_probe_open_device() instead
of open() + blkid_probe_set_device(). The flags argument allows
passing the open mode directly.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/wipefs.c

index dad1ad277435c14f87fcb53aa29f0dde30b25415..c596d6f87aafec11b721425e21f954e34fd24644 100644 (file)
@@ -367,21 +367,11 @@ new_probe(const char *devname, int mode)
        if (!devname)
                return NULL;
 
-       if (mode) {
-               int fd = open(devname, mode | O_NONBLOCK);
-               if (fd < 0)
-                       goto error;
-
-               pr = blkid_new_probe();
-               if (!pr || blkid_probe_set_device(pr, fd, 0, 0) != 0) {
-                       close(fd);
-                       goto error;
-               }
-       } else
-               pr = blkid_new_probe_from_filename(devname);
-
+       pr = blkid_new_probe();
        if (!pr)
                goto error;
+       if (blkid_probe_open_device(pr, devname, mode ? mode | O_NONBLOCK : 0))
+               goto error;
 
        blkid_probe_enable_superblocks(pr, 1);
        blkid_probe_set_superblocks_flags(pr,