summaryrefslogtreecommitdiff
path: root/shlibs/mount/src/optstr.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-09-27 16:25:01 +0200
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:43 +0100
commit39dd1e5087397c25e0eaeb491346a27cf14c77ac (patch)
treea93a4ef9a17261fda30e5ade5aeaadf281173934 /shlibs/mount/src/optstr.c
parenta5106adb7647b421f9a42e0b972d5a1f5e3a554c (diff)
downloadutil-linux-old-39dd1e5087397c25e0eaeb491346a27cf14c77ac.tar.gz
libmount: add DBG() to optstr.c
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/optstr.c')
-rw-r--r--shlibs/mount/src/optstr.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c
index bb361324..507a7b53 100644
--- a/shlibs/mount/src/optstr.c
+++ b/shlibs/mount/src/optstr.c
@@ -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;