]> err.no Git - util-linux/commitdiff
libmount: add DBG() to optstr.c
authorKarel Zak <kzak@redhat.com>
Mon, 27 Sep 2010 14:25:01 +0000 (16:25 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:43 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/optstr.c

index bb361324734f143d76f9f2f973d51ac8b9a40eb4..507a7b53b618d1ac69f34c368a4ccd4c2ee264db 100644 (file)
@@ -622,6 +622,8 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
        if (!optstr || !map)
                return -EINVAL;
 
+       DBG(CXT, mnt_debug("appling 0x%08lu flags '%s'", flags, *optstr));
+
        maps[0] = map;
        next = *optstr;
        fl = flags;
@@ -638,7 +640,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
                                next = name;
                                rc = mnt_optstr_remove_option_at(optstr, name, end);
                                if (rc)
-                                       return rc;
+                                       goto err;
                        }
                        if (!(ent->mask & MNT_INVERT))
                                fl &= ~ent->id;
@@ -662,14 +664,20 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
                        /* prepare name for value with optional value (e.g. loop[=%s]) */
                        if (p) {
                                p = strndup(ent->name, p - ent->name);
-                               if (!p)
-                                       return -ENOMEM;
+                               if (!p) {
+                                       rc = -ENOMEM;
+                                       goto err;
+                               }
                                mnt_optstr_append_option(optstr, p, NULL);
                                free(p);
                        } else
                                mnt_optstr_append_option(optstr, ent->name, NULL);
                }
        }
+
+       return rc;
+err:
+       DBG(CXT, mnt_debug("failed to apply flags [rc=%d]", rc));
        return rc;
 }
 
@@ -698,6 +706,8 @@ int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **ne
        if (!optstr || !*optstr || !value || !valsz)
                return -EINVAL;
 
+       DBG(CXT, mnt_debug("fixing SELinux context"));
+
        begin = value;
        end = value + valsz;
 
@@ -713,12 +723,18 @@ int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **ne
        if (!p)
                return -ENOMEM;
 
+
        /* translate the context */
        rc = selinux_trans_to_raw_context((security_context_t) p, &raw);
+
+       DBG(CXT, mnt_debug("SELinux context '%s' translated to '%s'",
+                       p, rc == -1 ? "FAILED" : (char *) raw));
+
        free(p);
        if (rc == -1 || !raw)
                return -EINVAL;
 
+
        /* create quoted string from the raw context */
        sz = strlen((char *) raw);
        if (!sz)
@@ -777,6 +793,8 @@ int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
        if (!optstr || !*optstr || !value || !valsz)
                return -EINVAL;
 
+       DBG(CXT, mnt_debug("fixing uid"));
+
        end = value + valsz;
 
        if (valsz == 7 && !strncmp(value, "useruid", 7) &&
@@ -823,6 +841,8 @@ int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
        if (!optstr || !*optstr || !value || !valsz)
                return -EINVAL;
 
+       DBG(CXT, mnt_debug("fixing gid"));
+
        end = value + valsz;
 
        if (valsz == 7 && !strncmp(value, "usergid", 7) &&
@@ -871,6 +891,8 @@ int mnt_optstr_fix_user(char **optstr, char *value, size_t valsz, char **next)
        if (!optstr || !value)
                return -EINVAL;
 
+       DBG(CXT, mnt_debug("fixing user"));
+
        username = mnt_get_username(getuid());
        if (!username)
                return -ENOMEM;