]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't treat "none" differently
authorDave Reisner <d@falconindy.com>
Fri, 2 Mar 2012 03:47:00 +0000 (22:47 -0500)
committerKarel Zak <kzak@redhat.com>
Fri, 2 Mar 2012 08:48:23 +0000 (09:48 +0100)
This causes more problems than it solves. In the latest edition:

  # mount -t proc none foo
  mount: foo: mount failed: Invalid argument

A check for source and target fails in mnt_context_apply_fstab()
because, even though they were indeed specified on the cmdline,
__mnt_fs_set_source_ptr() altered this and NULL'd out the source.

If you're able to mount this device via other means, other tools start
reporting oddities, such as mount's output:

  (null) on /foo type proc (rw,relatime)

or findmnt:

  TARGET      SOURCE FSTYPE OPTIONS
  /foo               proc   rw,relatime

Simply treat "none" like any other source when passed in.

[kzak@redhat.com: - don't translate NULL to "none" in mnt_fs_set_source()]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/fs.c
libmount/src/tab.c
libmount/src/tab_parse.c

index a28e66c71877d40a995260c9c7c32b57652af05e..5e4139c6aea8e5d569ecddef5130d659e16a2ea2 100644 (file)
@@ -304,11 +304,7 @@ int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source)
 
        assert(fs);
 
-       if (source && !strcmp(source, "none")) {
-               free(source);
-               source = NULL;
-
-       } else if (source && strchr(source, '=')) {
+       if (source && strchr(source, '=')) {
                if (blkid_parse_tag_string(source, &t, &v) != 0)
                        return -1;
        }
@@ -341,6 +337,7 @@ int mnt_fs_set_source(struct libmnt_fs *fs, const char *source)
 
        if (!fs)
                return -EINVAL;
+
        if (source) {
                p = strdup(source);
                if (!p)
index 21b05c7057ff6760c69f7ce60e474aabbafe9c00..7dd965458ffed1a32673e825fd968c5867919388 100644 (file)
@@ -480,9 +480,8 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
  * The 2nd, 3rd and 4th iterations are not performed when @tb cache is not
  * set (see mnt_table_set_cache()).
  *
- * Note that valid source path is NULL; the libmount uses NULL instead of
- * "none".  The "none" is used in /proc/{mounts,self/mountninfo} for pseudo
- * filesystems.
+ * Note that NULL is a valid source path; it will be replaced with "none". The
+ * "none" is used in /proc/{mounts,self/mountinfo} for pseudo filesystems.
  *
  * Returns: a tab entry or NULL.
  */
@@ -505,7 +504,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
 
                p = mnt_fs_get_srcpath(fs);
 
-               if (path == NULL && src == NULL)
+               if (path == NULL && (src == NULL || !strcmp(src, "none")))
                        return fs;                      /* source is "none" */
                if (path && p && streq_except_trailing_slash(p, path))
                        return fs;
index 0f618bb326cb643f04c9e07303aa354b310d1cb5..5bc55ae43d11d7089b1b4ab28f147ba00117a953 100644 (file)
@@ -180,12 +180,7 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
                unmangle_string(fs->vfs_optstr);
                unmangle_string(fstype);
                unmangle_string(src);
-
-               if (!strcmp(fs->fs_optstr, "none")) {
-                       free(fs->fs_optstr);
-                       fs->fs_optstr = NULL;
-               } else
-                       unmangle_string(fs->fs_optstr);
+               unmangle_string(fs->fs_optstr);
 
                rc = __mnt_fs_set_fstype_ptr(fs, fstype);
                if (!rc) {