From: Karel Zak Date: Mon, 27 Feb 2012 23:02:30 +0000 (+0100) Subject: libmount: allow empty source for mount(2) syscall X-Git-Tag: v2.22-rc1~747 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=772cce373f693096c2ae6f156306acf9e20c09e8;p=thirdparty%2Futil-linux.git libmount: allow empty source for mount(2) syscall Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797438 Signed-off-by: Karel Zak --- diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index a0c5951c1e..098243b72e 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -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); diff --git a/sys-utils/mount.c b/sys-utils/mount.c index 3fbac04a1a..23abc91735 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -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