]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add MNT_ERR_MOUNTOPT
authorKarel Zak <kzak@redhat.com>
Mon, 28 May 2012 10:49:55 +0000 (12:49 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 28 May 2012 10:49:55 +0000 (12:49 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_loopdev.c
libmount/src/context_mount.c
libmount/src/libmount.h.in
libmount/src/utils.c
sys-utils/mount.c

index 0dcf5803e01dea2ff57a9cff291efc494550c159..290e0d3d26eaceb1026b2523f948f17aac7825c5 100644 (file)
@@ -181,8 +181,10 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
        if (rc == 0 && (cxt->user_mountflags & MNT_MS_OFFSET) &&
            mnt_optstr_get_option(optstr, "offset", &val, &len) == 0) {
                rc = mnt_parse_offset(val, len, &offset);
-               if (rc)
+               if (rc) {
                        DBG(CXT, mnt_debug_h(cxt, "failed to parse offset="));
+                       rc = -MNT_ERR_MOUNTOPT;
+               }
        }
 
        /*
@@ -191,8 +193,10 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
        if (rc == 0 && (cxt->user_mountflags & MNT_MS_SIZELIMIT) &&
            mnt_optstr_get_option(optstr, "sizelimit", &val, &len) == 0) {
                rc = mnt_parse_offset(val, len, &sizelimit);
-               if (rc)
+               if (rc) {
                        DBG(CXT, mnt_debug_h(cxt, "failed to parse sizelimit="));
+                       rc = -MNT_ERR_MOUNTOPT;
+               }
        }
 
        /*
index 63091b7f88f32a930920360270b56bd81dafb918..3f0001dd40c46eaeb0da6a259466257d7a166d1f 100644 (file)
@@ -141,6 +141,9 @@ done:
        DBG(CXT, mnt_debug_h(cxt, "fixed options [rc=%d]: "
                "vfs: '%s' fs: '%s' user: '%s', optstr: '%s'", rc,
                fs->vfs_optstr, fs->fs_optstr, fs->user_optstr, fs->optstr));
+
+       if (rc)
+               rc = -MNT_ERR_MOUNTOPT;
        return rc;
 }
 
index 5161cf7c9d603544046303d9d65a64d2a82ec9f1..e12243962056840ae8512369d2b7c550649e194e 100644 (file)
@@ -127,6 +127,7 @@ enum {
 #define MNT_ERR_NOFSTYPE     5001      /* failed to detect filesystem type */
 #define MNT_ERR_NOSOURCE     5002      /* required mount source undefined */
 #define MNT_ERR_LOOPDEV             5003       /* loopdev setup failed, errno set by libc */
+#define MNT_ERR_MOUNTOPT     5004      /* failed to parse/use userspace mount options */
 
 /* init.c */
 extern void mnt_init_debug(int mask);
index 336fe8de8c61db225a62a86b5169b627f98a1d3e..d4cc0b3ede959a9126342e703c30c7cd7386a182 100644 (file)
@@ -539,6 +539,7 @@ int mnt_get_uid(const char *username, uid_t *uid)
        } else {
                DBG(UTILS, mnt_debug(
                        "cannot convert '%s' username to UID", username));
+               rc = errno ? -errno : -EINVAL;
        }
 
        free(buf);
@@ -566,6 +567,7 @@ int mnt_get_gid(const char *groupname, gid_t *gid)
        } else {
                DBG(UTILS, mnt_debug(
                        "cannot convert '%s' groupname to GID", groupname));
+               rc = errno ? -errno : -EINVAL;
        }
 
        free(buf);
index 9be8cb8a973d5d829ebcaa432ff54225726b9f8d..a4fbd9b8fcbae7bddf1c81b9d6792f0bfaa09e55 100644 (file)
@@ -367,6 +367,12 @@ try_readonly:
                        else
                                warnx(_("mount source not defined"));
                        return MOUNT_EX_USAGE;
+               case -MNT_ERR_MOUNTOPT:
+                       if (errno)
+                               warn(_("failed to parse mount options"));
+                       else
+                               warnx(_("failed to parse mount options"));
+                       return MOUNT_EX_USAGE;
                case -MNT_ERR_LOOPDEV:
                        if (errno == ENOENT
                            && (uflags & MNT_MS_ENCRYPTION)