]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: hide details about failed search in fstab/mtab
authorKarel Zak <kzak@redhat.com>
Tue, 16 Sep 2014 13:30:03 +0000 (15:30 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Sep 2014 13:30:03 +0000 (15:30 +0200)
The current code returns -errno when not found "mount /foo" in fstab
and mtab does not exist (or /etc/mtab points to non-mounted /proc).

This is problem because the return value is too low-level and maybe
misinterpreted by top level code. It's better to always return
MNT_ERR_NOFSTAB when not found in fstab/mtab.

Reported-by: Dylan Cali <calid1984@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c

index 7d2b9e40fc0d1f821f23252860f60d1da9233a97..48ee985fab975df128977dea23a1d49cb8d5b728 100644 (file)
@@ -2050,8 +2050,14 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
                if (!rc)
                        rc = apply_table(cxt, tab, MNT_ITER_BACKWARD);
        }
-       if (rc)
-               DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mtab"));
+       if (rc) {
+               DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mtab [rc=%d]: %m", rc));
+
+               /* force to "not found in fstab/mtab" error, the details why
+                * not found are not so important and may be misinterpreted by
+                * applications... */
+               rc = -MNT_ERR_NOFSTAB;
+       }
        return rc;
 }