]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: add a helper function for adding a nodev to the nodev_table
authorMasatake YAMATO <yamato@redhat.com>
Mon, 20 Mar 2023 17:19:11 +0000 (02:19 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Tue, 23 May 2023 15:49:47 +0000 (00:49 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c
misc-utils/lsfd.h

index 513d10d6a6dfe63b95620b2d40845b58442d86d4..d9c1a00bc209c4731d02e7471b08d9f0e294997a 100644 (file)
@@ -983,6 +983,14 @@ static void free_nodev(struct nodev *nodev)
        free(nodev);
 }
 
+void add_nodev(unsigned long minor, const char *filesystem)
+{
+       struct nodev *nodev = new_nodev(minor, filesystem);
+       unsigned long slot = nodev->minor % NODEV_TABLE_SIZE;
+
+       list_add_tail(&nodev->nodevs, &nodev_table.tables[slot]);
+}
+
 static void initialize_nodevs(void)
 {
        int i;
@@ -1023,9 +1031,6 @@ static void add_nodevs(FILE *mnt)
        while (fgets(line, sizeof(line), mnt)) {
                unsigned long major, minor;
                char filesystem[256];
-               struct nodev *nodev;
-               int slot;
-
 
                /* 23 61 0:22 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw,seclabel */
                if(sscanf(line, "%*d %*d %lu:%lu %*s %*s %*s %*[^-] - %s %*[^\n]",
@@ -1040,10 +1045,7 @@ static void add_nodevs(FILE *mnt)
                if (get_nodev_filesystem(minor))
                        continue;
 
-               nodev = new_nodev(minor, filesystem);
-               slot = minor % NODEV_TABLE_SIZE;
-
-               list_add_tail(&nodev->nodevs, &nodev_table.tables[slot]);
+               add_nodev(minor, filesystem);
        }
 }
 
index a0a20e66eff635f172541cdb5840df35df875734..dc02e30ecb9d2a2e2c5942b74dd4b669afe509cd 100644 (file)
@@ -231,6 +231,7 @@ const char *get_blkdrv(unsigned long major);
 const char *get_chrdrv(unsigned long major);
 const char *get_miscdev(unsigned long minor);
 const char *get_nodev_filesystem(unsigned long minor);
+void add_nodev(unsigned long minor, const char *filesystem);
 
 static inline void xstrappend(char **a, const char *b)
 {