]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: add VFS parameter to sysfs_devno_is_dm_*()
authorKarel Zak <kzak@redhat.com>
Tue, 30 Jun 2026 15:30:33 +0000 (17:30 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 9 Jul 2026 10:18:04 +0000 (12:18 +0200)
Add const struct ul_vfs_ops *vfs parameter to sysfs_devno_is_dm_hidden()
and sysfs_devno_is_dm_private() so the internal sysfs reads go through
VFS dispatch.

Wire pr->vfs in libblkid probe.c and topology/sysfs.c callers.
Non-library callers pass NULL.

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk-list.c
include/sysfs.h
lib/sysfs.c
libblkid/src/blkid.h.in
libblkid/src/probe.c
libblkid/src/topology/sysfs.c
libblkid/src/verify.c

index 76c1ac639fbfae9bf29f104c2190dca46407006b..e92eba897853c2cb9382695674647d5ff920294f 100644 (file)
@@ -416,7 +416,7 @@ char *next_proc_partition(FILE **f)
                if (devno <= 0)
                        continue;
 
-               if (sysfs_devno_is_dm_private(devno, NULL) ||
+               if (sysfs_devno_is_dm_private(devno, NULL, NULL) ||
                    sysfs_devno_is_wholedisk(devno) <= 0)
                        continue;
 
index 37f3b71caef6bec0b5bdd6cb713a5e6f9ef580ef..0cf833912c56ae2aaa7470ff5f817cf9e14a9cef 100644 (file)
@@ -93,10 +93,14 @@ int sysfs_blkdev_get_wholedisk( struct path_cxt *pc,
                                 size_t len,
                                 dev_t *diskdevno);
 
+struct ul_vfs_ops;
+
 int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
                              size_t len, dev_t *diskdevno);
-int sysfs_devno_is_dm_hidden(dev_t devno, char **uuid);
-int sysfs_devno_is_dm_private(dev_t devno, char **uuid);
+int sysfs_devno_is_dm_hidden(dev_t devno, char **uuid,
+                             const struct ul_vfs_ops *vfs);
+int sysfs_devno_is_dm_private(dev_t devno, char **uuid,
+                              const struct ul_vfs_ops *vfs);
 int sysfs_devno_is_wholedisk(dev_t devno);
 
 dev_t sysfs_devname_to_devno(const char *name);
index ad8a88ed0ae99e9e4fe58d897afb45f04c9717d8..99c486df7e3d94ee35d4eeb3bc60f3223781b0ab 100644 (file)
@@ -664,7 +664,8 @@ int sysfs_devno_to_wholedisk(dev_t devno, char *diskname,
  *
  * The @uuid (if not NULL) returns DM device UUID, use free() to deallocate.
  */
-int sysfs_devno_is_dm_hidden(dev_t devno, char **uuid)
+int sysfs_devno_is_dm_hidden(dev_t devno, char **uuid,
+                            const struct ul_vfs_ops *vfs)
 {
        struct path_cxt *pc = NULL;
        char *id = NULL;
@@ -673,6 +674,7 @@ int sysfs_devno_is_dm_hidden(dev_t devno, char **uuid)
        pc = ul_new_sysfs_path(devno, NULL, NULL);
        if (!pc)
                goto done;
+       ul_path_refer_vfs(pc, vfs);
        if (ul_path_read_string(pc, &id, "dm/uuid") <= 0 || !id)
                goto done;
 
@@ -698,7 +700,8 @@ done:
  * Returns 1 if the device is private device mapper device. The @uuid
  * (if not NULL) returns DM device UUID, use free() to deallocate.
  */
-int sysfs_devno_is_dm_private(dev_t devno, char **uuid)
+int sysfs_devno_is_dm_private(dev_t devno, char **uuid,
+                             const struct ul_vfs_ops *vfs)
 {
        struct path_cxt *pc = NULL;
        char *id = NULL;
@@ -707,6 +710,7 @@ int sysfs_devno_is_dm_private(dev_t devno, char **uuid)
        pc = ul_new_sysfs_path(devno, NULL, NULL);
        if (!pc)
                goto done;
+       ul_path_refer_vfs(pc, vfs);
        if (ul_path_read_string(pc, &id, "dm/uuid") <= 0 || !id)
                goto done;
 
index 1f39eefc2ab2d6a0598f3c34f2abe156c3f7a45b..c1bf350d5fa2e7786a1a9db5f0b4304387cc8f5a 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef _BLKID_BLKID_H
 #define _BLKID_BLKID_H
 
+#include <stdio.h>
 #include <stdint.h>
 #include <sys/types.h>
 
index 7f4c2791db36f3195efc63ccde97729188eeb712..36d70ebb760862faa6edfa7fd9d4461b2a853b42 100644 (file)
@@ -232,7 +232,7 @@ int blkid_probe_open_device(blkid_probe pr, const char *filename, int flags)
        struct stat sb;
 
        if (stat(filename, &sb) == 0 && S_ISBLK(sb.st_mode) &&
-           sysfs_devno_is_dm_hidden(sb.st_rdev, NULL)) {
+           sysfs_devno_is_dm_hidden(sb.st_rdev, NULL, pr->vfs)) {
                DBG(LOWPROBE, ul_debug("ignore hidden device mapper device"));
                errno = EINVAL;
                return -EINVAL;
@@ -1213,7 +1213,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
 #endif
        if (S_ISBLK(sb.st_mode) &&
            !is_floppy &&
-           sysfs_devno_is_dm_private(sb.st_rdev, &dm_uuid)) {
+           sysfs_devno_is_dm_private(sb.st_rdev, &dm_uuid, pr->vfs)) {
                DBG(LOWPROBE, ul_debug("ignore private device mapper device"));
                pr->flags |= BLKID_FL_NOSCAN_DEV;
        }
index d216cfccbfab228d72a2711b67f42b8499b62aec..c9689450a25df6978da181947179792358d83036 100644 (file)
@@ -56,6 +56,7 @@ static int probe_sysfs_tp(blkid_probe pr,
        pc = ul_new_sysfs_path(dev, NULL, NULL);
        if (!pc)
                return 1;
+       ul_path_refer_vfs(pc, pr->vfs);
 
        rc = 1;         /* nothing (default) */
 
index 7ca267dc72b33c752b77da71522be84ef0fa54fa..b59af77b9ca39172dc6f35dcf5456acbb516551e 100644 (file)
@@ -105,7 +105,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
                   (long long)diff));
 #endif
 
-       if (sysfs_devno_is_dm_private(st.st_rdev, NULL))
+       if (sysfs_devno_is_dm_private(st.st_rdev, NULL, NULL))
                goto dev_free;
        if (!cache->probe) {
                cache->probe = blkid_new_probe();