]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: allow empty source for mount(2) syscall
authorKarel Zak <kzak@redhat.com>
Mon, 27 Feb 2012 23:02:30 +0000 (00:02 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Feb 2012 23:02:30 +0000 (00:02 +0100)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797438
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_mount.c
sys-utils/mount.c

index a0c5951c1e8bedd3f158711c8db9d127249c2751..098243b72e57cb0d2220d7bb24dddf01d2fc630c 100644 (file)
@@ -451,8 +451,10 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
        src = mnt_fs_get_srcpath(cxt->fs);
        target = mnt_fs_get_target(cxt->fs);
 
-       if (!src || !target)
+       if (!target)
                return -EINVAL;
+       if (!src)
+               src = "none";
 
        type = try_type ? : mnt_fs_get_fstype(cxt->fs);
 
index 3fbac04a1a15c67236e9b6e57633a7b84b555c44..23abc917356e7c1015d876ec734a0b3740f3e730 100644 (file)
@@ -347,7 +347,11 @@ try_readonly:
                        return MOUNT_EX_USAGE;
                }
 
-               if (src == NULL || tgt == NULL) {
+               /*
+                * TODO: add mnt_context_fstab_applied() to check if we found
+                *       target/source in the file.
+                */
+               if (!tgt) {
                        if (mflags & MS_REMOUNT)
                                warnx(_("%s not mounted"), src ? src : tgt);
                        else