libmount: allow empty source for mount(2) syscall

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797438
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2012-02-28 00:02:30 +01:00
parent 9bf9690114
commit 772cce373f
2 changed files with 8 additions and 2 deletions

View 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);

View 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