diff options
author | Karel Zak <kzak@redhat.com> | 2012-11-26 11:21:40 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2012-11-26 11:21:40 +0100 |
commit | ec8121b103bafec90bc1d2fef524f94d408caab3 (patch) | |
tree | a0993bfb03c8ebdd7111fdf46c269c0b5ae10e71 /libmount/src | |
parent | 6c32b388b5407c4692dbaf4d7ee835f87f2e98b2 (diff) | |
download | util-linux-ec8121b103bafec90bc1d2fef524f94d408caab3.tar.gz |
libmount: correctly interpret '*' from /etc/filesystems
- single line with '*' in /etc/filesystems means that libmount has to
read /proc/filesystems, otherwise /proc/filesystems has to be ignored
- mount(2) ENODEV is no reason to break the do_mount_by_pattern()
loop when trying to mount by /{etc,proc}/filesystems
Reported-by: NeilBrown <neilb@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/context_mount.c | 3 | ||||
-rw-r--r-- | libmount/src/utils.c | 29 |
2 files changed, 26 insertions, 6 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 1e21db7c..196e3a24 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -590,7 +590,8 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern) rc = do_mount(cxt, *fp); if (mnt_context_get_status(cxt)) break; - if (mnt_context_get_syscall_errno(cxt) != EINVAL) + if (mnt_context_get_syscall_errno(cxt) != EINVAL && + mnt_context_get_syscall_errno(cxt) != ENODEV) break; } mnt_free_filesystems(filesystems); diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 624633dd..28eca7c8 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -453,7 +453,9 @@ static int get_filesystems(const char *filename, char ***filesystems, const char f = fopen(filename, "r"); if (!f) - return 0; + return 1; + + DBG(UTILS, mnt_debug("reading filesystems list from: %s", filename)); while (fgets(line, sizeof(line), f)) { char name[sizeof(line)]; @@ -462,6 +464,10 @@ static int get_filesystems(const char *filename, char ***filesystems, const char continue; if (sscanf(line, " %128[^\n ]\n", name) != 1) continue; + if (strcmp(name, "*") == 0) { + rc = 1; + break; /* end of the /etc/filesystems */ + } if (pattern && !mnt_match_fstype(name, pattern)) continue; rc = add_filesystem(filesystems, name); @@ -474,8 +480,15 @@ static int get_filesystems(const char *filename, char ***filesystems, const char } /* - * Returns zero also if not found any matching filesystem. Always check - * @filesystems pointer! + * Always check @filesystems pointer! + * + * man mount: + * + * ...mount will try to read the file /etc/filesystems, or, if that does not + * exist, /proc/filesystems. All of the filesystem types listed there will + * be tried, except for those that are labeled "nodev" (e.g., devpts, + * proc and nfs). If /etc/filesystems ends in a line with a single * only, + * mount will read /proc/filesystems after‐ wards. */ int mnt_get_filesystems(char ***filesystems, const char *pattern) { @@ -483,12 +496,18 @@ int mnt_get_filesystems(char ***filesystems, const char *pattern) if (!filesystems) return -EINVAL; + *filesystems = NULL; rc = get_filesystems(_PATH_FILESYSTEMS, filesystems, pattern); - if (rc) + if (rc != 1) return rc; - return get_filesystems(_PATH_PROC_FILESYSTEMS, filesystems, pattern); + + rc = get_filesystems(_PATH_PROC_FILESYSTEMS, filesystems, pattern); + if (rc == 1 && *filesystems) + rc = 0; /* not found /proc/filesystems */ + + return rc; } static size_t get_pw_record_size(void) |