mount: add mount with ignore=1 for unsupported filesystems
authorRafał Miłecki <rafal@milecki.pl>
Fri, 3 Nov 2017 09:02:40 +0000 (10:02 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Mon, 6 Nov 2017 09:37:09 +0000 (10:37 +0100)
So far a check for unsupported filesystem was in the mount_add_list
which was simply stopping mount from being added to the global list.

This resulted in mount_dev_add continuously not being able to find a
mount for the given block device and trying to add it over and over.
That was non-optimal becuse with unsupported filesystem present the
code was checking all its parameters every second.

Fix this by:
1) Moving check out of the mount_add_list to keep all logic in the
   caller function.
2) Adding mount with ignore=1 for unsupported filesystem instead of
   ignoring it.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
mount.c

diff --git a/mount.c b/mount.c
index 6d95de95d1d05aff2dc575e0a5f6d6077a0fcad1..caf9d9d7abcce8935b973271e3208bcaf0603ff5 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -139,8 +139,7 @@ static void mount_add_list(char *name, char *dev, char *serial,
 {
        struct mount *mount;
        char tmp[64], tmp2[64];
 {
        struct mount *mount;
        char tmp[64], tmp2[64];
-       if(fs <= MBR || fs > LASTFS)
-               return;
+
        mount  = malloc(sizeof(struct mount));
        INIT_LIST_HEAD(&mount->list);
        strncpy(mount->vendor, vendor, 64);
        mount  = malloc(sizeof(struct mount));
        INIT_LIST_HEAD(&mount->list);
        strncpy(mount->vendor, vendor, 64);
@@ -451,6 +450,7 @@ static void mount_dev_add(char *dev)
                char sector_size[64];
                FILE *fp;
                int offset = 3;
                char sector_size[64];
                FILE *fp;
                int offset = 3;
+               int fs;
 
                strcpy(name, dev);
                if (!strncmp(name, "mmcblk", 6))
 
                strcpy(name, dev);
                if (!strncmp(name, "mmcblk", 6))
@@ -556,7 +556,11 @@ static void mount_dev_add(char *dev)
                        fclose(fp);
                }
                snprintf(tmp, 64, "/dev/%s", dev);
                        fclose(fp);
                }
                snprintf(tmp, 64, "/dev/%s", dev);
-               mount_add_list(node, dev, s, vendor, model, rev, ignore, size, sector_size, detect_fs(tmp));
+               fs = detect_fs(tmp);
+               if (fs <= MBR || fs > LASTFS) {
+                       ignore = 1;
+               }
+               mount_add_list(node, dev, s, vendor, model, rev, ignore, size, sector_size, fs);
                mount_dump_uci_state();
        }
 }
                mount_dump_uci_state();
        }
 }