From 7826ca5d6aca691dcb6f98ab203a090d42e79337 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 3 Nov 2017 10:02:40 +0100 Subject: [PATCH] mount: add mount with ignore=1 for unsupported filesystems MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Acked-by: John Crispin --- mount.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mount.c b/mount.c index 6d95de9..caf9d9d 100644 --- 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]; - if(fs <= MBR || fs > LASTFS) - return; + 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; + int fs; 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); - 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(); } } -- 2.11.0