]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: simplify 'leaf' detection
authorKarel Zak <kzak@redhat.com>
Mon, 27 Jun 2022 11:00:55 +0000 (13:00 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Jun 2022 11:00:55 +0000 (13:00 +0200)
References: https://github.com/util-linux/util-linux/pull/1729
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/devname.c

index 2e64ddac46b55eae01dccf7c68c03ff16d3920d1..3f4803232749d2e09fb712b8e07ccd2c4504c5c3 100644 (file)
@@ -155,20 +155,16 @@ static const char *dirlist[] = { "/dev", "/devfs", "/devices", NULL };
  */
 static int is_dm_leaf(const char *devname)
 {
-       struct dirent   *de;
-       DIR             *dir;
-       char            path[NAME_MAX + 18 + 1];
-       int             ret = 1;
+       DIR *dir;
+       char path[NAME_MAX + 18 + 1];
+       int ret;
 
        snprintf(path, sizeof(path), "/sys/block/%s/holders", devname);
        if ((dir = opendir(path)) == NULL)
                return 0;
-       while ((de = readdir(dir)) != NULL) {
-               if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
-                       continue;
-               ret = 0;
-               break;
-       }
+
+       ret = xreaddir(dir) == NULL ? 1 : 0;    /* 'leaf' has no entries */
+
        closedir(dir);
        return ret;
 }