summaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorKarel Zak2014-03-21 12:34:39 +0100
committerKarel Zak2014-03-21 12:34:39 +0100
commit83a783320b987a0ab9790ea5fad2eb2f77baaf3b (patch)
tree47631a02b043b87e7d07c6b5502bc54325aae707 /libmount/src
parentinclude/debug: add another debug macros (diff)
downloadkernel-qcow2-util-linux-83a783320b987a0ab9790ea5fad2eb2f77baaf3b.tar.gz
kernel-qcow2-util-linux-83a783320b987a0ab9790ea5fad2eb2f77baaf3b.tar.xz
kernel-qcow2-util-linux-83a783320b987a0ab9790ea5fad2eb2f77baaf3b.zip
libmount: use new debug functions
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/cache.c27
-rw-r--r--libmount/src/context.c98
-rw-r--r--libmount/src/context_loopdev.c32
-rw-r--r--libmount/src/context_mount.c62
-rw-r--r--libmount/src/context_umount.c76
-rw-r--r--libmount/src/fs.c16
-rw-r--r--libmount/src/init.c4
-rw-r--r--libmount/src/lock.c30
-rw-r--r--libmount/src/mountP.h59
-rw-r--r--libmount/src/optstr.c20
-rw-r--r--libmount/src/tab.c64
-rw-r--r--libmount/src/tab_diff.c12
-rw-r--r--libmount/src/tab_parse.c48
-rw-r--r--libmount/src/tab_update.c56
-rw-r--r--libmount/src/utils.c30
-rw-r--r--libmount/src/version.c5
16 files changed, 291 insertions, 348 deletions
diff --git a/libmount/src/cache.c b/libmount/src/cache.c
index 92f469456..2fe41b3a4 100644
--- a/libmount/src/cache.c
+++ b/libmount/src/cache.c
@@ -72,7 +72,7 @@ struct libmnt_cache *mnt_new_cache(void)
struct libmnt_cache *cache = calloc(1, sizeof(*cache));
if (!cache)
return NULL;
- DBG(CACHE, mnt_debug_h(cache, "alloc"));
+ DBG(CACHE, ul_debugobj(cache, "alloc"));
cache->refcount = 1;
return cache;
}
@@ -91,8 +91,7 @@ void mnt_free_cache(struct libmnt_cache *cache)
if (!cache)
return;
- DBG(CACHE, mnt_debug_h(cache, "free"));
- WARN_REFCOUNT(CACHE, cache, cache->refcount);
+ DBG(CACHE, ul_debugobj(cache, "free [refcount=%d]", cache->refcount));
for (i = 0; i < cache->nents; i++) {
struct mnt_cache_entry *e = &cache->ents[i];
@@ -116,7 +115,7 @@ void mnt_ref_cache(struct libmnt_cache *cache)
{
if (cache) {
cache->refcount++;
- /*DBG(CACHE, mnt_debug_h(cache, "ref=%d", cache->refcount));*/
+ /*DBG(CACHE, ul_debugobj(cache, "ref=%d", cache->refcount));*/
}
}
@@ -131,7 +130,7 @@ void mnt_unref_cache(struct libmnt_cache *cache)
{
if (cache) {
cache->refcount--;
- /*DBG(CACHE, mnt_debug_h(cache, "unref=%d", cache->refcount));*/
+ /*DBG(CACHE, ul_debugobj(cache, "unref=%d", cache->refcount));*/
if (cache->refcount <= 0)
mnt_free_cache(cache);
}
@@ -164,7 +163,7 @@ static int cache_add_entry(struct libmnt_cache *cache, char *key,
e->flag = flag;
cache->nents++;
- DBG(CACHE, mnt_debug_h(cache, "add entry [%2zd] (%s): %s: %s",
+ DBG(CACHE, ul_debugobj(cache, "add entry [%2zd] (%s): %s: %s",
cache->nents,
(flag & MNT_CACHE_ISPATH) ? "path" : "tag",
value, key));
@@ -304,7 +303,7 @@ int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname)
if (!cache || !devname)
return -EINVAL;
- DBG(CACHE, mnt_debug_h(cache, "tags for %s requested", devname));
+ DBG(CACHE, ul_debugobj(cache, "tags for %s requested", devname));
/* check if device is already cached */
for (i = 0; i < cache->nents; i++) {
@@ -332,14 +331,14 @@ int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname)
if (rc)
goto error;
- DBG(CACHE, mnt_debug_h(cache, "reading tags for: %s", devname));
+ DBG(CACHE, ul_debugobj(cache, "reading tags for: %s", devname));
for (i = 0; i < ARRAY_SIZE(tags); i++) {
const char *data;
char *dev;
if (cache_find_tag_value(cache, devname, tags[i])) {
- DBG(CACHE, mnt_debug_h(cache,
+ DBG(CACHE, ul_debugobj(cache,
"\ntag %s already cached", tags[i]));
continue;
}
@@ -356,7 +355,7 @@ int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname)
ntags++;
}
- DBG(CACHE, mnt_debug_h(cache, "\tread %zd tags", ntags));
+ DBG(CACHE, ul_debugobj(cache, "\tread %zd tags", ntags));
blkid_free_probe(pr);
return ntags ? 0 : 1;
error:
@@ -435,7 +434,7 @@ char *mnt_get_fstype(const char *devname, int *ambi, struct libmnt_cache *cache)
char *type = NULL;
int rc;
- DBG(CACHE, mnt_debug_h(cache, "get %s FS type", devname));
+ DBG(CACHE, ul_debugobj(cache, "get %s FS type", devname));
if (cache) {
char *val = NULL;
@@ -457,7 +456,7 @@ char *mnt_get_fstype(const char *devname, int *ambi, struct libmnt_cache *cache)
rc = blkid_do_safeprobe(pr);
- DBG(CACHE, mnt_debug_h(cache, "libblkid rc=%d", rc));
+ DBG(CACHE, ul_debugobj(cache, "libblkid rc=%d", rc));
if (!rc && !blkid_probe_lookup_value(pr, "TYPE", &data, NULL))
type = strdup(data);
@@ -487,7 +486,7 @@ char *mnt_resolve_path(const char *path, struct libmnt_cache *cache)
char *key = NULL;
char *value = NULL;
- /*DBG(CACHE, mnt_debug_h(cache, "resolving path %s", path));*/
+ /*DBG(CACHE, ul_debugobj(cache, "resolving path %s", path));*/
if (!path)
return NULL;
@@ -582,7 +581,7 @@ char *mnt_resolve_tag(const char *token, const char *value,
assert(token);
assert(value);
- /*DBG(CACHE, mnt_debug_h(cache, "resolving tag token=%s value=%s",
+ /*DBG(CACHE, ul_debugobj(cache, "resolving tag token=%s value=%s",
token, value));*/
if (!token || !value)
diff --git a/libmount/src/context.c b/libmount/src/context.c
index f1077968f..2d9795e23 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -61,7 +61,7 @@ struct libmnt_context *mnt_new_context(void)
/* if we're really root and aren't running setuid */
cxt->restricted = (uid_t) 0 == ruid && ruid == euid ? 0 : 1;
- DBG(CXT, mnt_debug_h(cxt, "----> allocate %s",
+ DBG(CXT, ul_debugobj(cxt, "----> allocate %s",
cxt->restricted ? "[RESTRICTED]" : ""));
mnt_has_regular_mtab(&cxt->mtab_path, &cxt->mtab_writable);
@@ -98,7 +98,7 @@ void mnt_free_context(struct libmnt_context *cxt)
free(cxt->children);
- DBG(CXT, mnt_debug_h(cxt, "<---- free"));
+ DBG(CXT, ul_debugobj(cxt, "<---- free"));
free(cxt);
}
@@ -129,7 +129,7 @@ int mnt_reset_context(struct libmnt_context *cxt)
if (!cxt)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "<---- reset [status=%d] ---->",
+ DBG(CXT, ul_debugobj(cxt, "<---- reset [status=%d] ---->",
mnt_context_get_status(cxt)));
fl = cxt->flags;
@@ -210,10 +210,10 @@ static int set_flag(struct libmnt_context *cxt, int flag, int enable)
if (!cxt)
return -EINVAL;
if (enable) {
- DBG(CXT, mnt_debug_h(cxt, "enabling flag %04x", flag));
+ DBG(CXT, ul_debugobj(cxt, "enabling flag %04x", flag));
cxt->flags |= flag;
} else {
- DBG(CXT, mnt_debug_h(cxt, "disabling flag %04x", flag));
+ DBG(CXT, ul_debugobj(cxt, "disabling flag %04x", flag));
cxt->flags &= ~flag;
}
return 0;
@@ -997,7 +997,7 @@ int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
if (tb)
*tb = cxt->mtab;
- DBG(CXT, mnt_debug_h(cxt, "mtab requested [nents=%d]",
+ DBG(CXT, ul_debugobj(cxt, "mtab requested [nents=%d]",
mnt_table_get_nents(cxt->mtab)));
return 0;
}
@@ -1022,7 +1022,7 @@ int mnt_context_set_tabfilter(struct libmnt_context *cxt,
cxt->table_fltrcb,
cxt->table_fltrcb_data);
- DBG(CXT, mnt_debug_h(cxt, "tabfilter %s", fltr ? "ENABLED!" : "disabled"));
+ DBG(CXT, ul_debugobj(cxt, "tabfilter %s", fltr ? "ENABLED!" : "disabled"));
return 0;
}
@@ -1394,7 +1394,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
if (!cxt || !cxt->fs)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "preparing source path"));
+ DBG(CXT, ul_debugobj(cxt, "preparing source path"));
src = mnt_fs_get_source(cxt->fs);
@@ -1408,7 +1408,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
if (!src || mnt_fs_is_netfs(cxt->fs))
return 0;
- DBG(CXT, mnt_debug_h(cxt, "srcpath '%s'", src));
+ DBG(CXT, ul_debugobj(cxt, "srcpath '%s'", src));
cache = mnt_context_get_cache(cxt);
@@ -1431,7 +1431,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
}
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "failed to prepare srcpath [rc=%d]", rc));
+ DBG(CXT, ul_debugobj(cxt, "failed to prepare srcpath [rc=%d]", rc));
return rc;
}
@@ -1440,7 +1440,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
if ((cxt->mountflags & (MS_BIND | MS_MOVE | MS_REMOUNT))
|| mnt_fs_is_pseudofs(cxt->fs)) {
- DBG(CXT, mnt_debug_h(cxt, "REMOUNT/BIND/MOVE/pseudo FS source: %s", path));
+ DBG(CXT, ul_debugobj(cxt, "REMOUNT/BIND/MOVE/pseudo FS source: %s", path));
return rc;
}
@@ -1453,7 +1453,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
return rc;
}
- DBG(CXT, mnt_debug_h(cxt, "final srcpath '%s'",
+ DBG(CXT, ul_debugobj(cxt, "final srcpath '%s'",
mnt_fs_get_source(cxt->fs)));
return 0;
}
@@ -1482,7 +1482,7 @@ static int mkdir_target(const char *tgt, struct libmnt_fs *fs)
mode = strtol(mstr, &end, 8);
if (errno || !end || mstr + mstr_sz != end) {
- DBG(CXT, mnt_debug("failed to parse mkdir mode '%s'", mstr));
+ DBG(CXT, ul_debug("failed to parse mkdir mode '%s'", mstr));
return -MNT_ERR_MOUNTOPT;
}
}
@@ -1494,7 +1494,7 @@ static int mkdir_target(const char *tgt, struct libmnt_fs *fs)
rc = mkdir_p(tgt, mode);
if (rc)
- DBG(CXT, mnt_debug("mkdir %s failed: %m", tgt));
+ DBG(CXT, ul_debug("mkdir %s failed: %m", tgt));
return rc;
}
@@ -1512,7 +1512,7 @@ int mnt_context_prepare_target(struct libmnt_context *cxt)
if (!cxt || !cxt->fs)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "preparing target path"));
+ DBG(CXT, ul_debugobj(cxt, "preparing target path"));
tgt = mnt_fs_get_target(cxt->fs);
if (!tgt)
@@ -1537,9 +1537,9 @@ int mnt_context_prepare_target(struct libmnt_context *cxt)
}
if (rc)
- DBG(CXT, mnt_debug_h(cxt, "failed to prepare target '%s'", tgt));
+ DBG(CXT, ul_debugobj(cxt, "failed to prepare target '%s'", tgt));
else
- DBG(CXT, mnt_debug_h(cxt, "final target '%s'",
+ DBG(CXT, ul_debugobj(cxt, "final target '%s'",
mnt_fs_get_target(cxt->fs)));
return 0;
}
@@ -1595,7 +1595,7 @@ int mnt_context_guess_fstype(struct libmnt_context *cxt)
if (ambi)
rc = -MNT_ERR_AMBIFS;
} else {
- DBG(CXT, mnt_debug_h(cxt, "access(%s) failed [%m]", dev));
+ DBG(CXT, ul_debugobj(cxt, "access(%s) failed [%m]", dev));
if (strchr(dev, ':') != NULL)
rc = mnt_fs_set_fstype(cxt->fs, "nfs");
else if (!strncmp(dev, "//", 2))
@@ -1603,7 +1603,7 @@ int mnt_context_guess_fstype(struct libmnt_context *cxt)
}
done:
- DBG(CXT, mnt_debug_h(cxt, "FS type: %s [rc=%d]",
+ DBG(CXT, ul_debugobj(cxt, "FS type: %s [rc=%d]",
mnt_fs_get_fstype(cxt->fs), rc));
return rc;
none:
@@ -1662,7 +1662,7 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
rc = stat(helper, &st);
}
- DBG(CXT, mnt_debug_h(cxt, "%-25s ... %s", helper,
+ DBG(CXT, ul_debugobj(cxt, "%-25s ... %s", helper,
rc ? "not found" : "found"));
if (rc)
continue;
@@ -1684,7 +1684,7 @@ int mnt_context_merge_mflags(struct libmnt_context *cxt)
assert(cxt);
- DBG(CXT, mnt_debug_h(cxt, "merging mount flags"));
+ DBG(CXT, ul_debugobj(cxt, "merging mount flags"));
rc = mnt_context_get_mflags(cxt, &fl);
if (rc)
@@ -1697,7 +1697,7 @@ int mnt_context_merge_mflags(struct libmnt_context *cxt)
return rc;
cxt->user_mountflags = fl;
- DBG(CXT, mnt_debug_h(cxt, "final flags: VFS=%08lx user=%08lx",
+ DBG(CXT, ul_debugobj(cxt, "final flags: VFS=%08lx user=%08lx",
cxt->mountflags, cxt->user_mountflags));
cxt->flags |= MNT_FL_MOUNTFLAGS_MERGED;
@@ -1717,10 +1717,10 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
assert(cxt->action);
assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
- DBG(CXT, mnt_debug_h(cxt, "prepare update"));
+ DBG(CXT, ul_debugobj(cxt, "prepare update"));
if (mnt_context_propagation_only(cxt)) {
- DBG(CXT, mnt_debug_h(cxt, "skip update: only MS_PROPAGATION"));
+ DBG(CXT, ul_debugobj(cxt, "skip update: only MS_PROPAGATION"));
return 0;
}
@@ -1731,16 +1731,16 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
mnt_context_disable_mtab(cxt, TRUE);
if (mnt_context_is_nomtab(cxt)) {
- DBG(CXT, mnt_debug_h(cxt, "skip update: NOMTAB flag"));
+ DBG(CXT, ul_debugobj(cxt, "skip update: NOMTAB flag"));
return 0;
}
if (!cxt->mtab_writable && !cxt->utab_writable) {
- DBG(CXT, mnt_debug_h(cxt, "skip update: no writable destination"));
+ DBG(CXT, ul_debugobj(cxt, "skip update: no writable destination"));
return 0;
}
/* 0 = success, 1 = not called yet */
if (cxt->syscall_status != 1 && cxt->syscall_status != 0) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"skip update: syscall failed [status=%d]",
cxt->syscall_status));
return 0;
@@ -1750,7 +1750,7 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
const char *name = cxt->mtab_writable ? cxt->mtab_path : cxt->utab_path;
if (cxt->action == MNT_ACT_UMOUNT && is_file_empty(name)) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"skip update: umount, no table"));
return 0;
}
@@ -1779,11 +1779,11 @@ int mnt_context_update_tabs(struct libmnt_context *cxt)
assert(cxt);
if (mnt_context_is_nomtab(cxt)) {
- DBG(CXT, mnt_debug_h(cxt, "don't update: NOMTAB flag"));
+ DBG(CXT, ul_debugobj(cxt, "don't update: NOMTAB flag"));
return 0;
}
if (!cxt->update || !mnt_update_is_ready(cxt->update)) {
- DBG(CXT, mnt_debug_h(cxt, "don't update: no update prepared"));
+ DBG(CXT, ul_debugobj(cxt, "don't update: no update prepared"));
return 0;
}
@@ -1793,11 +1793,11 @@ int mnt_context_update_tabs(struct libmnt_context *cxt)
&& cxt->utab_writable) {
if (mnt_update_already_done(cxt->update, cxt->lock)) {
- DBG(CXT, mnt_debug_h(cxt, "don't update: error evaluate or already updated"));
+ DBG(CXT, ul_debugobj(cxt, "don't update: error evaluate or already updated"));
return 0;
}
} else if (cxt->helper) {
- DBG(CXT, mnt_debug_h(cxt, "don't update: external helper"));
+ DBG(CXT, ul_debugobj(cxt, "don't update: external helper"));
return 0;
}
@@ -1805,7 +1805,7 @@ int mnt_context_update_tabs(struct libmnt_context *cxt)
&& !(mnt_context_helper_executed(cxt) &&
mnt_context_get_helper_status(cxt) == 0)) {
- DBG(CXT, mnt_debug_h(cxt, "don't update: syscall/helper failed/not called"));
+ DBG(CXT, ul_debugobj(cxt, "don't update: syscall/helper failed/not called"));
return 0;
}
@@ -1863,7 +1863,7 @@ static int apply_table(struct libmnt_context *cxt, struct libmnt_table *tb,
if (!fs)
return -MNT_ERR_NOFSTAB; /* not found */
- DBG(CXT, mnt_debug_h(cxt, "apply entry:"));
+ DBG(CXT, ul_debugobj(cxt, "apply entry:"));
DBG(CXT, mnt_fs_print_debug(fs, stderr));
/* copy from tab to our FS description
@@ -1918,10 +1918,10 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
return 0;
if (mnt_context_is_restricted(cxt)) {
- DBG(CXT, mnt_debug_h(cxt, "force fstab usage for non-root users!"));
+ DBG(CXT, ul_debugobj(cxt, "force fstab usage for non-root users!"));
cxt->optsmode = MNT_OMODE_USER;
} else if (cxt->optsmode == 0) {
- DBG(CXT, mnt_debug_h(cxt, "use default optsmode"));
+ DBG(CXT, ul_debugobj(cxt, "use default optsmode"));
cxt->optsmode = MNT_OMODE_AUTO;
} else if (cxt->optsmode & MNT_OMODE_NOTAB) {
cxt->optsmode &= ~MNT_OMODE_FSTAB;
@@ -1934,7 +1934,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
tgt = mnt_fs_get_target(cxt->fs);
}
- DBG(CXT, mnt_debug_h(cxt, "OPTSMODE: ignore=%d, append=%d, prepend=%d, "
+ DBG(CXT, ul_debugobj(cxt, "OPTSMODE: ignore=%d, append=%d, prepend=%d, "
"replace=%d, force=%d, fstab=%d, mtab=%d",
cxt->optsmode & MNT_OMODE_IGNORE ? 1 : 0,
cxt->optsmode & MNT_OMODE_APPEND ? 1 : 0,
@@ -1946,19 +1946,19 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
/* fstab is not required if source and target are specified */
if (src && tgt && !(cxt->optsmode & MNT_OMODE_FORCE)) {
- DBG(CXT, mnt_debug_h(cxt, "fstab not required -- skip"));
+ DBG(CXT, ul_debugobj(cxt, "fstab not required -- skip"));
return 0;
}
if (!src && tgt
&& !(cxt->optsmode & MNT_OMODE_FSTAB)
&& !(cxt->optsmode & MNT_OMODE_MTAB)) {
- DBG(CXT, mnt_debug_h(cxt, "only target; fstab/mtab not required "
+ DBG(CXT, ul_debugobj(cxt, "only target; fstab/mtab not required "
"-- skip, probably MS_PROPAGATION"));
return 0;
}
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"trying to apply fstab (src=%s, target=%s)", src, tgt));
/* let's initialize cxt->fs */
@@ -1973,13 +1973,13 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
/* try mtab */
if (rc < 0 && (cxt->optsmode & MNT_OMODE_MTAB)) {
- DBG(CXT, mnt_debug_h(cxt, "trying to apply from mtab"));
+ DBG(CXT, ul_debugobj(cxt, "trying to apply from mtab"));
rc = mnt_context_get_mtab(cxt, &tab);
if (!rc)
rc = apply_table(cxt, tab, MNT_ITER_BACKWARD);
}
if (rc)
- DBG(CXT, mnt_debug_h(cxt, "failed to find entry in fstab/mtab"));
+ DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mtab"));
return rc;
}
@@ -2109,7 +2109,7 @@ int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status)
if (!cxt)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "syscall status set to: %d", status));
+ DBG(CXT, ul_debugobj(cxt, "syscall status set to: %d", status));
cxt->syscall_status = status;
return 0;
}
@@ -2162,7 +2162,7 @@ int mnt_context_init_helper(struct libmnt_context *cxt, int action,
if (!rc)
cxt->action = action;
- DBG(CXT, mnt_debug_h(cxt, "initialized for [u]mount.<type> helper [rc=%d]", rc));
+ DBG(CXT, ul_debugobj(cxt, "initialized for [u]mount.<type> helper [rc=%d]", rc));
return rc;
}
@@ -2231,7 +2231,7 @@ static int mnt_context_add_child(struct libmnt_context *cxt, pid_t pid)
if (!pids)
return -ENOMEM;
- DBG(CXT, mnt_debug_h(cxt, "add new child %d", pid));
+ DBG(CXT, ul_debugobj(cxt, "add new child %d", pid));
cxt->children = pids;
cxt->children[cxt->nchildren++] = pid;
@@ -2247,7 +2247,7 @@ int mnt_fork_context(struct libmnt_context *cxt)
if (!mnt_context_is_parent(cxt))
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "forking context"));
+ DBG(CXT, ul_debugobj(cxt, "forking context"));
DBG_FLUSH;
@@ -2255,13 +2255,13 @@ int mnt_fork_context(struct libmnt_context *cxt)
switch (pid) {
case -1: /* error */
- DBG(CXT, mnt_debug_h(cxt, "fork failed %m"));
+ DBG(CXT, ul_debugobj(cxt, "fork failed %m"));
return -errno;
case 0: /* child */
cxt->pid = getpid();
mnt_context_enable_fork(cxt, FALSE);
- DBG(CXT, mnt_debug_h(cxt, "child created"));
+ DBG(CXT, ul_debugobj(cxt, "child created"));
break;
default:
@@ -2290,7 +2290,7 @@ int mnt_context_wait_for_children(struct libmnt_context *cxt,
if (!pid)
continue;
do {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"waiting for child (%d/%d): %d",
i + 1, cxt->nchildren, pid));
errno = 0;
diff --git a/libmount/src/context_loopdev.c b/libmount/src/context_loopdev.c
index 44a7216b8..e8f637b29 100644
--- a/libmount/src/context_loopdev.c
+++ b/libmount/src/context_loopdev.c
@@ -36,7 +36,7 @@ int mnt_context_is_loopdev(struct libmnt_context *cxt)
MNT_MS_OFFSET |
MNT_MS_SIZELIMIT)) {
- DBG(CXT, mnt_debug_h(cxt, "loopdev specific options detected"));
+ DBG(CXT, ul_debugobj(cxt, "loopdev specific options detected"));
return 1;
}
@@ -62,7 +62,7 @@ int mnt_context_is_loopdev(struct libmnt_context *cxt)
if (stat(src, &st) == 0 && S_ISREG(st.st_mode) &&
st.st_size > 1024) {
- DBG(CXT, mnt_debug_h(cxt, "automatically enabling loop= option"));
+ DBG(CXT, ul_debugobj(cxt, "automatically enabling loop= option"));
cxt->user_mountflags |= MNT_MS_LOOP;
mnt_optstr_append_option(&cxt->fs->user_optstr, "loop", NULL);
return 1;
@@ -96,7 +96,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
if (!target || !backing_file || mnt_context_get_mtab(cxt, &tb))
return 0;
- DBG(CXT, mnt_debug_h(cxt, "checking if %s mounted on %s",
+ DBG(CXT, ul_debugobj(cxt, "checking if %s mounted on %s",
backing_file, target));
cache = mnt_context_get_cache(cxt);
@@ -130,7 +130,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
}
}
if (rc)
- DBG(CXT, mnt_debug_h(cxt, "%s already mounted", backing_file));
+ DBG(CXT, ul_debugobj(cxt, "%s already mounted", backing_file));
return rc;
}
@@ -153,10 +153,10 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
if (!backing_file)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "trying to setup loopdev for %s", backing_file));
+ DBG(CXT, ul_debugobj(cxt, "trying to setup loopdev for %s", backing_file));
if (cxt->mountflags & MS_RDONLY) {
- DBG(CXT, mnt_debug_h(cxt, "enabling READ-ONLY flag"));
+ DBG(CXT, ul_debugobj(cxt, "enabling READ-ONLY flag"));
lo_flags |= LO_FLAGS_READ_ONLY;
}
@@ -189,7 +189,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
mnt_optstr_get_option(optstr, "offset", &val, &len) == 0) {
rc = mnt_parse_offset(val, len, &offset);
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "failed to parse offset="));
+ DBG(CXT, ul_debugobj(cxt, "failed to parse offset="));
rc = -MNT_ERR_MOUNTOPT;
}
}
@@ -201,7 +201,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
mnt_optstr_get_option(optstr, "sizelimit", &val, &len) == 0) {
rc = mnt_parse_offset(val, len, &sizelimit);
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "failed to parse sizelimit="));
+ DBG(CXT, ul_debugobj(cxt, "failed to parse sizelimit="));
rc = -MNT_ERR_MOUNTOPT;
}
}
@@ -211,7 +211,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
*/
if (rc == 0 && (cxt->user_mountflags & MNT_MS_ENCRYPTION) &&
mnt_optstr_get_option(optstr, "encryption", &val, &len) == 0) {
- DBG(CXT, mnt_debug_h(cxt, "encryption no longer supported"));
+ DBG(CXT, ul_debugobj(cxt, "encryption no longer supported"));
rc = -MNT_ERR_MOUNTOPT;
}
@@ -228,7 +228,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
*/
if (get_linux_version() >= KERNEL_VERSION(2, 6, 37) ||
!cxt->mtab_writable) {
- DBG(CXT, mnt_debug_h(cxt, "enabling AUTOCLEAR flag"));
+ DBG(CXT, ul_debugobj(cxt, "enabling AUTOCLEAR flag"));
lo_flags |= LO_FLAGS_AUTOCLEAR;
}
@@ -238,7 +238,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
rc = loopcxt_find_unused(&lc);
if (rc)
goto done;
- DBG(CXT, mnt_debug_h(cxt, "trying to use %s",
+ DBG(CXT, ul_debugobj(cxt, "trying to use %s",
loopcxt_get_device(&lc)));
}
@@ -254,7 +254,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
if (!rc)
loopcxt_set_flags(&lc, lo_flags);
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "failed to set loopdev attributes"));
+ DBG(CXT, ul_debugobj(cxt, "failed to set loopdev attributes"));
goto done;
}
@@ -264,11 +264,11 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
break; /* success */
if (loopdev || rc != -EBUSY) {
- DBG(CXT, mnt_debug_h(cxt, "failed to setup device"));
+ DBG(CXT, ul_debugobj(cxt, "failed to setup device"));
rc = -MNT_ERR_LOOPDEV;
goto done;
}
- DBG(CXT, mnt_debug_h(cxt, "loopdev stolen...trying again"));
+ DBG(CXT, ul_debugobj(cxt, "loopdev stolen...trying again"));
} while (1);
if (!rc)
@@ -332,7 +332,7 @@ int mnt_context_delete_loopdev(struct libmnt_context *cxt)
cxt->flags &= ~MNT_FL_LOOPDEV_READY;
cxt->loopdev_fd = -1;
- DBG(CXT, mnt_debug_h(cxt, "loopdev deleted [rc=%d]", rc));
+ DBG(CXT, ul_debugobj(cxt, "loopdev deleted [rc=%d]", rc));
return rc;
}
@@ -358,7 +358,7 @@ int mnt_context_clear_loopdev(struct libmnt_context *cxt)
/*
* mount(2) success, close the device
*/
- DBG(CXT, mnt_debug_h(cxt, "closing loopdev FD"));
+ DBG(CXT, ul_debugobj(cxt, "closing loopdev FD"));
close(cxt->loopdev_fd);
}
cxt->loopdev_fd = -1;
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index e249ff13e..dcfdabfd2 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -55,7 +55,7 @@ static int mnt_context_append_additional_mount(struct libmnt_context *cxt,
assert(cxt);
assert(ad);
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"mount: add additional flag: 0x%08lx",
ad->mountflags));
@@ -73,7 +73,7 @@ static int init_propagation(struct libmnt_context *cxt)
if (!opts)
return 0;
- DBG(CXT, mnt_debug_h(cxt, "mount: initialize additional propagation mounts"));
+ DBG(CXT, ul_debugobj(cxt, "mount: initialize additional propagation mounts"));
maps[0] = mnt_get_builtin_optmap(MNT_LINUX_MAP);
@@ -167,7 +167,7 @@ static int fix_optstr(struct libmnt_context *cxt)
if (!cxt->fs || (cxt->flags & MNT_FL_MOUNTOPTS_FIXED))
return 0;
- DBG(CXT, mnt_debug_h(cxt, "mount: fixing optstr"));
+ DBG(CXT, ul_debugobj(cxt, "mount: fixing optstr"));
fs = cxt->fs;
@@ -192,13 +192,13 @@ static int fix_optstr(struct libmnt_context *cxt)
/*
* Sync mount options with mount flags
*/
- DBG(CXT, mnt_debug_h(cxt, "mount: fixing vfs optstr"));
+ DBG(CXT, ul_debugobj(cxt, "mount: fixing vfs optstr"));
rc = mnt_optstr_apply_flags(&fs->vfs_optstr, cxt->mountflags,
mnt_get_builtin_optmap(MNT_LINUX_MAP));
if (rc)
goto done;
- DBG(CXT, mnt_debug_h(cxt, "mount: fixing user optstr"));
+ DBG(CXT, ul_debugobj(cxt, "mount: fixing user optstr"));
rc = mnt_optstr_apply_flags(&fs->user_optstr, cxt->user_mountflags,
mnt_get_builtin_optmap(MNT_USERSPACE_MAP));
if (rc)
@@ -296,7 +296,7 @@ static int fix_optstr(struct libmnt_context *cxt)
done:
cxt->flags |= MNT_FL_MOUNTOPTS_FIXED;
- DBG(CXT, mnt_debug_h(cxt, "fixed options [rc=%d]: "
+ DBG(CXT, ul_debugobj(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));
@@ -320,7 +320,7 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
assert(cxt->fs);
assert(optstr);
- DBG(CXT, mnt_debug_h(cxt, "mount: generate helper mount options"));
+ DBG(CXT, ul_debugobj(cxt, "mount: generate helper mount options"));
*optstr = mnt_fs_strdup_options(cxt->fs);
if (!*optstr)
@@ -398,7 +398,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
if (!cxt->fs)
return 0;
- DBG(CXT, mnt_debug_h(cxt, "mount: evaluating permissions"));
+ DBG(CXT, ul_debugobj(cxt, "mount: evaluating permissions"));
mnt_context_get_user_mflags(cxt, &u_flags);
@@ -414,7 +414,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
*/
if (!mnt_context_tab_applied(cxt))
{
- DBG(CXT, mnt_debug_h(cxt, "perms: fstab not applied, ignore user mount"));
+ DBG(CXT, ul_debugobj(cxt, "perms: fstab not applied, ignore user mount"));
return -EPERM;
}
@@ -431,7 +431,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
if (!mnt_optstr_get_option(cxt->fs->user_optstr,
"user", NULL, &valsz) && valsz) {
- DBG(CXT, mnt_debug_h(cxt, "perms: user=<name> detected, ignore"));
+ DBG(CXT, ul_debugobj(cxt, "perms: user=<name> detected, ignore"));
cxt->user_mountflags &= ~MNT_MS_USER;
}
}
@@ -457,7 +457,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
srcpath = xsrc;
}
if (!srcpath) {
- DBG(CXT, mnt_debug_h(cxt, "perms: src undefined"));
+ DBG(CXT, ul_debugobj(cxt, "perms: src undefined"));
return -EPERM;
}
@@ -473,7 +473,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
}
if (!(cxt->user_mountflags & (MNT_MS_USER | MNT_MS_USERS))) {
- DBG(CXT, mnt_debug_h(cxt, "permissions evaluation ends with -EPERMS"));
+ DBG(CXT, ul_debugobj(cxt, "permissions evaluation ends with -EPERMS"));
return -EPERM;
}
}
@@ -542,7 +542,7 @@ static int exec_helper(struct libmnt_context *cxt)
assert(cxt->helper);
assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
- DBG(CXT, mnt_debug_h(cxt, "mount: executing helper %s", cxt->helper));
+ DBG(CXT, ul_debugobj(cxt, "mount: executing helper %s", cxt->helper));
rc = generate_helper_optstr(cxt, &o);
if (rc)
@@ -585,11 +585,9 @@ static int exec_helper(struct libmnt_context *cxt)
args[i++] = type; /* 11 */
}
args[i] = NULL; /* 12 */
-#ifdef CONFIG_LIBMOUNT_DEBUG
for (i = 0; args[i]; i++)
- DBG(CXT, mnt_debug_h(cxt, "argv[%d] = \"%s\"",
+ DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
i, args[i]));
-#endif
DBG_FLUSH;
execv(cxt->helper, (char * const *) args);
exit(EXIT_FAILURE);
@@ -600,7 +598,7 @@ static int exec_helper(struct libmnt_context *cxt)
wait(&st);
cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
- DBG(CXT, mnt_debug_h(cxt, "%s executed [status=%d]",
+ DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",
cxt->helper, cxt->helper_status));
cxt->helper_exec_status = rc = 0;
break;
@@ -608,7 +606,7 @@ static int exec_helper(struct libmnt_context *cxt)
case -1:
cxt->helper_exec_status = rc = -errno;
- DBG(CXT, mnt_debug_h(cxt, "fork() failed"));
+ DBG(CXT, ul_debugobj(cxt, "fork() failed"));
break;
}
@@ -634,7 +632,7 @@ static int do_mount_additional(struct libmnt_context *cxt,
struct libmnt_addmount *ad =
list_entry(p, struct libmnt_addmount, mounts);
- DBG(CXT, mnt_debug_h(cxt, "mount(2) changing flag: 0x%08lx %s",
+ DBG(CXT, ul_debugobj(cxt, "mount(2) changing flag: 0x%08lx %s",
ad->mountflags,
ad->mountflags & MS_REC ? " (recursive)" : ""));
@@ -643,7 +641,7 @@ static int do_mount_additional(struct libmnt_context *cxt,
if (rc) {
if (syserr)
*syserr = -errno;
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"mount(2) failed [errno=%d %m]",
errno));
return rc;
@@ -698,7 +696,7 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
if (!src) {
/* unnecessary, should be already resolved in
* mnt_context_prepare_srcpath(), but to be sure... */
- DBG(CXT, mnt_debug_h(cxt, "WARNING: source is NULL -- using \"none\"!"));
+ DBG(CXT, ul_debugobj(cxt, "WARNING: source is NULL -- using \"none\"!"));
src = "none";
}
type = try_type ? : mnt_fs_get_fstype(cxt->fs);
@@ -708,7 +706,7 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
if (try_type)
flags |= MS_SILENT;
- DBG(CXT, mnt_debug_h(cxt, "%smount(2) "
+ DBG(CXT, ul_debugobj(cxt, "%smount(2) "
"[source=%s, target=%s, type=%s, "
" mountflags=0x%08lx, mountdata=%s]",
mnt_context_is_fake(cxt) ? "(FAKE) " : "",
@@ -733,11 +731,11 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
*/
if (mount(src, target, type, flags, cxt->mountdata)) {
cxt->syscall_status = -errno;
- DBG(CXT, mnt_debug_h(cxt, "mount(2) failed [errno=%d %m]",
+ DBG(CXT, ul_debugobj(cxt, "mount(2) failed [errno=%d %m]",
-cxt->syscall_status));
return -cxt->syscall_status;
}
- DBG(CXT, mnt_debug_h(cxt, "mount(2) success"));
+ DBG(CXT, ul_debugobj(cxt, "mount(2) success"));
cxt->syscall_status = 0;
/*
@@ -775,7 +773,7 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
*/
char *p, *p0;
- DBG(CXT, mnt_debug_h(cxt, "trying to mount by FS pattern list"));
+ DBG(CXT, ul_debugobj(cxt, "trying to mount by FS pattern list"));
p0 = p = strdup(pattern);
if (!p)
@@ -798,7 +796,7 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
/*
* try /etc/filesystems and /proc/filesystems
*/
- DBG(CXT, mnt_debug_h(cxt, "trying to mount by filesystems lists"));
+ DBG(CXT, ul_debugobj(cxt, "trying to mount by filesystems lists"));
rc = mnt_get_filesystems(&filesystems, neg ? pattern : NULL);
if (rc)
@@ -845,7 +843,7 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
cxt->action = MNT_ACT_MOUNT;
- DBG(CXT, mnt_debug_h(cxt, "mount: preparing"));
+ DBG(CXT, ul_debugobj(cxt, "mount: preparing"));
rc = mnt_context_apply_fstab(cxt);
if (!rc)
@@ -863,7 +861,7 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
if (!rc)
rc = mnt_context_prepare_helper(cxt, "mount", NULL);
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "mount: preparing failed"));
+ DBG(CXT, ul_debugobj(cxt, "mount: preparing failed"));
return rc;
}
cxt->flags |= MNT_FL_PREPARED;
@@ -905,7 +903,7 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
assert((cxt->flags & MNT_FL_PREPARED));
assert((cxt->action == MNT_ACT_MOUNT));
- DBG(CXT, mnt_debug_h(cxt, "mount: do mount"));
+ DBG(CXT, ul_debugobj(cxt, "mount: do mount"));
if (!(cxt->flags & MNT_FL_MOUNTDATA))
cxt->mountdata = (char *) mnt_fs_get_fs_options(cxt->fs);
@@ -1087,7 +1085,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
o = mnt_fs_get_user_options(*fs);
tgt = mnt_fs_get_target(*fs);
- DBG(CXT, mnt_debug_h(cxt, "next-mount: trying %s", tgt));
+ DBG(CXT, ul_debugobj(cxt, "next-mount: trying %s", tgt));
/* ignore swap */
if (mnt_fs_is_swaparea(*fs) ||
@@ -1107,7 +1105,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
cxt->optstr_pattern))) {
if (ignored)
*ignored = 1;
- DBG(CXT, mnt_debug_h(cxt, "next-mount: not-match "
+ DBG(CXT, ul_debugobj(cxt, "next-mount: not-match "
"[fstype: %s, t-pattern: %s, options: %s, O-pattern: %s]",
mnt_fs_get_fstype(*fs),
cxt->fstype_pattern,
@@ -1146,7 +1144,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
}
if (mnt_context_is_child(cxt)) {
- DBG(CXT, mnt_debug_h(cxt, "next-mount: child exit [rc=%d]", rc));
+ DBG(CXT, ul_debugobj(cxt, "next-mount: child exit [rc=%d]", rc));
DBG_FLUSH;
exit(rc);
}
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
index 2e22389f4..7df4c2cca 100644
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -77,7 +77,7 @@ int mnt_context_find_umount_fs(struct libmnt_context *cxt,
if (!cxt || !tgt || !pfs)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "umount: lookup FS for '%s'", tgt));
+ DBG(CXT, ul_debugobj(cxt, "umount: lookup FS for '%s'", tgt));
if (!*tgt)
return 1; /* empty string is not an error */
@@ -113,12 +113,12 @@ int mnt_context_find_umount_fs(struct libmnt_context *cxt,
}
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "umount: failed to read mtab"));
+ DBG(CXT, ul_debugobj(cxt, "umount: failed to read mtab"));
return rc;
}
if (mnt_table_get_nents(mtab) == 0) {
- DBG(CXT, mnt_debug_h(cxt, "umount: mtab empty"));
+ DBG(CXT, ul_debugobj(cxt, "umount: mtab empty"));
return 1;
}
@@ -136,14 +136,14 @@ try_loopdev:
mnt_fs_get_target(fs),
MNT_ITER_BACKWARD);
if (!fs1) {
- DBG(CXT, mnt_debug_h(cxt, "mtab is broken?!?!"));
+ DBG(CXT, ul_debugobj(cxt, "mtab is broken?!?!"));
rc = -EINVAL;
goto err;
}
if (fs != fs1) {
/* Something was stacked over `file' on the
* same mount point. */
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: %s: %s is mounted "
"over it on the same point",
tgt, mnt_fs_get_source(fs1)));
@@ -165,13 +165,13 @@ try_loopdev:
count = loopdev_count_by_backing_file(bf, &loopdev);
if (count == 1) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: %s --> %s (retry)", tgt, loopdev));
tgt = loopdev;
goto try_loopdev;
} else if (count > 1)
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: warning: %s is associated "
"with more than one loopdev", tgt));
}
@@ -181,7 +181,7 @@ try_loopdev:
*pfs = fs;
free(loopdev);
- DBG(CXT, mnt_debug_h(cxt, "umount fs: %s", fs ? mnt_fs_get_target(fs) :
+ DBG(CXT, ul_debugobj(cxt, "umount fs: %s", fs ? mnt_fs_get_target(fs) :
"<not found>"));
return fs ? 0 : 1;
err:
@@ -241,7 +241,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
tgt = mnt_fs_get_target(cxt->fs);
if (!tgt) {
- DBG(CXT, mnt_debug_h(cxt, "umount: undefined target"));
+ DBG(CXT, ul_debugobj(cxt, "umount: undefined target"));
return -EINVAL;
}
@@ -282,7 +282,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
}
}
if (type) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: mountinfo unnecessary [type=%s]", type));
return 0;
}
@@ -293,7 +293,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
return rc;
if (rc == 1 || !fs) {
- DBG(CXT, mnt_debug_h(cxt, "umount: cannot find '%s' in mtab", tgt));
+ DBG(CXT, ul_debugobj(cxt, "umount: cannot find '%s' in mtab", tgt));
return 0; /* this is correct! */
}
@@ -304,10 +304,10 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
mnt_fs_set_target(cxt->fs, NULL);
if (!mnt_copy_fs(cxt->fs, fs)) {
- DBG(CXT, mnt_debug_h(cxt, "umount: failed to copy FS"));
+ DBG(CXT, ul_debugobj(cxt, "umount: failed to copy FS"));
return -errno;
}
- DBG(CXT, mnt_debug_h(cxt, "umount: mtab applied"));
+ DBG(CXT, ul_debugobj(cxt, "umount: mtab applied"));
}
cxt->flags |= MNT_FL_TAB_APPLIED;
@@ -368,7 +368,7 @@ static int prepare_helper_from_options(struct libmnt_context *cxt,
if (!suffix)
return -ENOMEM;
- DBG(CXT, mnt_debug_h(cxt, "umount: umount.%s %s requested", suffix, name));
+ DBG(CXT, ul_debugobj(cxt, "umount: umount.%s %s requested", suffix, name));
return mnt_context_prepare_helper(cxt, "umount", suffix);
}
@@ -394,10 +394,10 @@ static int evaluate_permissions(struct libmnt_context *cxt)
if (!mnt_context_is_restricted(cxt))
return 0; /* superuser mount */
- DBG(CXT, mnt_debug_h(cxt, "umount: evaluating permissions"));
+ DBG(CXT, ul_debugobj(cxt, "umount: evaluating permissions"));
if (!mnt_context_tab_applied(cxt)) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"cannot find %s in mtab and you are not root",
mnt_fs_get_target(cxt->fs)));
goto eperm;
@@ -424,7 +424,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
if (mnt_fs_get_bindsrc(cxt->fs)) {
src = mnt_fs_get_bindsrc(cxt->fs);
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: using bind source: %s", src));
}
@@ -451,7 +451,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
fs = NULL;
}
if (!fs) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount %s: mtab disagrees with fstab",
tgt));
goto eperm;
@@ -477,7 +477,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
goto eperm;
if (u_flags & MNT_MS_USERS) {
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: promiscuous setting ('users') in fstab"));
return 0;
}
@@ -491,13 +491,13 @@ static int evaluate_permissions(struct libmnt_context *cxt)
char *mtab_user = NULL;
size_t sz;
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount: checking user=<username> from mtab"));
curr_user = mnt_get_username(getuid());
if (!curr_user) {
- DBG(CXT, mnt_debug_h(cxt, "umount %s: cannot "
+ DBG(CXT, ul_debugobj(cxt, "umount %s: cannot "
"convert %d to username", tgt, getuid()));
goto eperm;
}
@@ -512,11 +512,11 @@ static int evaluate_permissions(struct libmnt_context *cxt)
}
if (ok) {
- DBG(CXT, mnt_debug_h(cxt, "umount %s is allowed", tgt));
+ DBG(CXT, ul_debugobj(cxt, "umount %s is allowed", tgt));
return 0;
}
eperm:
- DBG(CXT, mnt_debug_h(cxt, "umount is not allowed for you"));
+ DBG(CXT, ul_debugobj(cxt, "umount is not allowed for you"));
return -EPERM;
}
@@ -565,11 +565,9 @@ static int exec_helper(struct libmnt_context *cxt)
}
args[i] = NULL; /* 10 */
-#ifdef CONFIG_LIBMOUNT_DEBUG
for (i = 0; args[i]; i++)
- DBG(CXT, mnt_debug_h(cxt, "argv[%d] = \"%s\"",
+ DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
i, args[i]));
-#endif
DBG_FLUSH;
execv(cxt->helper, (char * const *) args);
exit(EXIT_FAILURE);
@@ -580,7 +578,7 @@ static int exec_helper(struct libmnt_context *cxt)
wait(&st);
cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
- DBG(CXT, mnt_debug_h(cxt, "%s executed [status=%d]",
+ DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",
cxt->helper, cxt->helper_status));
cxt->helper_exec_status = rc = 0;
break;
@@ -588,7 +586,7 @@ static int exec_helper(struct libmnt_context *cxt)
case -1:
cxt->helper_exec_status = rc = -errno;
- DBG(CXT, mnt_debug_h(cxt, "fork() failed"));
+ DBG(CXT, ul_debugobj(cxt, "fork() failed"));
break;
}
@@ -673,7 +671,7 @@ static int do_umount(struct libmnt_context *cxt)
if (!target)
return -EINVAL;
- DBG(CXT, mnt_debug_h(cxt, "do umount"));
+ DBG(CXT, ul_debugobj(cxt, "do umount"));
if (cxt->restricted && !mnt_context_is_fake(cxt)) {
/*
@@ -696,7 +694,7 @@ static int do_umount(struct libmnt_context *cxt)
else if (mnt_context_is_force(cxt))
flags |= MNT_FORCE;
- DBG(CXT, mnt_debug_h(cxt, "umount(2) [target='%s', flags=0x%08x]%s",
+ DBG(CXT, ul_debugobj(cxt, "umount(2) [target='%s', flags=0x%08x]%s",
target, flags,
mnt_context_is_fake(cxt) ? " (FAKE)" : ""));
@@ -721,7 +719,7 @@ static int do_umount(struct libmnt_context *cxt)
MS_REMOUNT | MS_RDONLY));
mnt_context_enable_loopdel(cxt, FALSE);
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"umount(2) failed [errno=%d] -- trying to remount read-only",
-cxt->syscall_status));
@@ -729,25 +727,25 @@ static int do_umount(struct libmnt_context *cxt)
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (rc < 0) {
cxt->syscall_status = -errno;
- DBG(CXT, mnt_debug_h(cxt,
+ DBG(CXT, ul_debugobj(cxt,
"read-only re-mount(2) failed [errno=%d]",
-cxt->syscall_status));
return -cxt->syscall_status;
}
cxt->syscall_status = 0;
- DBG(CXT, mnt_debug_h(cxt, "read-only re-mount(2) success"));
+ DBG(CXT, ul_debugobj(cxt, "read-only re-mount(2) success"));
return 0;
}
if (rc < 0) {
- DBG(CXT, mnt_debug_h(cxt, "umount(2) failed [errno=%d]",
+ DBG(CXT, ul_debugobj(cxt, "umount(2) failed [errno=%d]",
-cxt->syscall_status));
return -cxt->syscall_status;
}
cxt->syscall_status = 0;
- DBG(CXT, mnt_debug_h(cxt, "umount(2) success"));
+ DBG(CXT, ul_debugobj(cxt, "umount(2) success"));
return 0;
}
@@ -808,7 +806,7 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt)
}
if (rc) {
- DBG(CXT, mnt_debug_h(cxt, "umount: preparing failed"));
+ DBG(CXT, ul_debugobj(cxt, "umount: preparing failed"));
return rc;
}
cxt->flags |= MNT_FL_PREPARED;
@@ -932,7 +930,7 @@ int mnt_context_umount(struct libmnt_context *cxt)
assert(cxt->helper_exec_status == 1);
assert(cxt->syscall_status == 1);
- DBG(CXT, mnt_debug_h(cxt, "umount: %s", mnt_context_get_target(cxt)));
+ DBG(CXT, ul_debugobj(cxt, "umount: %s", mnt_context_get_target(cxt)));
rc = mnt_context_prepare_umount(cxt);
if (!rc)
@@ -1007,7 +1005,7 @@ int mnt_context_next_umount(struct libmnt_context *cxt,
tgt = mnt_fs_get_target(*fs);
} while (!tgt);
- DBG(CXT, mnt_debug_h(cxt, "next-umount: trying %s", tgt));
+ DBG(CXT, ul_debugobj(cxt, "next-umount: trying %s", tgt));
/* ignore filesystems which don't match options patterns */
if ((cxt->fstype_pattern && !mnt_fs_match_fstype(*fs,
@@ -1018,7 +1016,7 @@ int mnt_context_next_umount(struct libmnt_context *cxt,
cxt->optstr_pattern))) {
if (ignored)
*ignored = 1;
- DBG(CXT, mnt_debug_h(cxt, "next-umount: not-match "
+ DBG(CXT, ul_debugobj(cxt, "next-umount: not-match "
"[fstype: %s, t-pattern: %s, options: %s, O-pattern: %s]",
mnt_fs_get_fstype(*fs),
cxt->fstype_pattern,
diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index 3ab614503..cae7ce648 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -34,7 +34,7 @@ struct libmnt_fs *mnt_new_fs(void)
fs->refcount = 1;
INIT_LIST_HEAD(&fs->ents);
- /*DBG(FS, mnt_debug_h(fs, "alloc"));*/
+ /*DBG(FS, ul_debugobj(fs, "alloc"));*/
return fs;
}
@@ -52,9 +52,7 @@ void mnt_free_fs(struct libmnt_fs *fs)
if (!fs)
return;
list_del(&fs->ents);
-
- /*DBG(FS, mnt_debug_h(fs, "free"));*/
- WARN_REFCOUNT(FS, fs, fs->refcount);
+ DBG(FS, ul_debugobj(fs, "free [refcount=%d]", fs->refcount));
free(fs->source);
free(fs->bindsrc);
@@ -104,7 +102,7 @@ void mnt_ref_fs(struct libmnt_fs *fs)
{
if (fs) {
fs->refcount++;
- /*DBG(FS, mnt_debug_h(fs, "ref=%d", fs->refcount));*/
+ /*DBG(FS, ul_debugobj(fs, "ref=%d", fs->refcount));*/
}
}
@@ -119,7 +117,7 @@ void mnt_unref_fs(struct libmnt_fs *fs)
{
if (fs) {
fs->refcount--;
- /*DBG(FS, mnt_debug_h(fs, "unref=%d", fs->refcount));*/
+ /*DBG(FS, ul_debugobj(fs, "unref=%d", fs->refcount));*/
if (fs->refcount <= 0)
mnt_free_fs(fs);
}
@@ -184,7 +182,7 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest,
return NULL;
}
- /*DBG(FS, mnt_debug_h(dest, "copy from %p", src));*/
+ /*DBG(FS, ul_debugobj(dest, "copy from %p", src));*/
dest->id = src->id;
dest->parent = src->parent;
@@ -301,7 +299,7 @@ void *mnt_fs_get_userdata(struct libmnt_fs *fs)
if (!fs)
return NULL;
- /*DBG(FS, mnt_debug_h(fs, "get userdata [%p]", fs->userdata));*/
+ /*DBG(FS, ul_debugobj(fs, "get userdata [%p]", fs->userdata));*/
return fs->userdata;
}
@@ -320,7 +318,7 @@ int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data)
if (!fs)
return -EINVAL;
- /*DBG(FS, mnt_debug_h(fs, "set userdata [%p]", fs->userdata));*/
+ /*DBG(FS, ul_debugobj(fs, "set userdata [%p]", fs->userdata));*/
fs->userdata = data;
return 0;
}
diff --git a/libmount/src/init.c b/libmount/src/init.c
index d3aef7fa0..b3d10df44 100644
--- a/libmount/src/init.c
+++ b/libmount/src/init.c
@@ -38,9 +38,9 @@ void mnt_init_debug(int mask)
mnt_get_library_version(&ver);
mnt_get_library_features(&features);
- DBG(INIT, mnt_debug("library version: %s", ver));
+ DBG(INIT, ul_debug("library version: %s", ver));
p = features;
while (p && *p)
- DBG(INIT, mnt_debug(" feature: %s", *p++));
+ DBG(INIT, ul_debug(" feature: %s", *p++));
}
}
diff --git a/libmount/src/lock.c b/libmount/src/lock.c
index 734757d81..8667db999 100644
--- a/libmount/src/lock.c
+++ b/libmount/src/lock.c
@@ -79,7 +79,7 @@ struct libmnt_lock *mnt_new_lock(const char *datafile, pid_t id)
ml->linkfile = ln;
ml->lockfile = lo;
- DBG(LOCKS, mnt_debug_h(ml, "alloc: default linkfile=%s, lockfile=%s", ln, lo));
+ DBG(LOCKS, ul_debugobj(ml, "alloc: default linkfile=%s, lockfile=%s", ln, lo));
return ml;
err:
free(lo);
@@ -99,7 +99,7 @@ void mnt_free_lock(struct libmnt_lock *ml)
{
if (!ml)
return;
- DBG(LOCKS, mnt_debug_h(ml, "free%s", ml->locked ? " !!! LOCKED !!!" : ""));
+ DBG(LOCKS, ul_debugobj(ml, "free%s", ml->locked ? " !!! LOCKED !!!" : ""));
free(ml->lockfile);
free(ml->linkfile);
free(ml);
@@ -119,7 +119,7 @@ int mnt_lock_block_signals(struct libmnt_lock *ml, int enable)
{
if (!ml)
return -EINVAL;
- DBG(LOCKS, mnt_debug_h(ml, "signals: %s", enable ? "BLOCKED" : "UNBLOCKED"));
+ DBG(LOCKS, ul_debugobj(ml, "signals: %s", enable ? "BLOCKED" : "UNBLOCKED"));
ml->sigblock = enable ? 1 : 0;
return 0;
}
@@ -135,7 +135,7 @@ int mnt_lock_use_simplelock(struct libmnt_lock *ml, int enable)
assert(ml->lockfile);
- DBG(LOCKS, mnt_debug_h(ml, "flock: %s", enable ? "ENABLED" : "DISABLED"));
+ DBG(LOCKS, ul_debugobj(ml, "flock: %s", enable ? "ENABLED" : "DISABLED"));
ml->simplelock = enable ? 1 : 0;
sz = strlen(ml->lockfile);
@@ -155,7 +155,7 @@ int mnt_lock_use_simplelock(struct libmnt_lock *ml, int enable)
else if (!ml->simplelock && endswith(ml->lockfile, ".lock"))
memcpy(ml->lockfile + sz - 5, "~", 2);
- DBG(LOCKS, mnt_debug_h(ml, "new lock filename: '%s'", ml->lockfile));
+ DBG(LOCKS, ul_debugobj(ml, "new lock filename: '%s'", ml->lockfile));
return 0;
}
@@ -187,7 +187,7 @@ static void unlock_simplelock(struct libmnt_lock *ml)
assert(ml->simplelock);
if (ml->lockfile_fd >= 0) {
- DBG(LOCKS, mnt_debug_h(ml, "%s: unflocking",
+ DBG(LOCKS, ul_debugobj(ml, "%s: unflocking",
mnt_lock_get_lockfile(ml)));
close(ml->lockfile_fd);
}
@@ -203,7 +203,7 @@ static int lock_simplelock(struct libmnt_lock *ml)
lfile = mnt_lock_get_lockfile(ml);
- DBG(LOCKS, mnt_debug_h(ml, "%s: locking", lfile));
+ DBG(LOCKS, ul_debugobj(ml, "%s: locking", lfile));
if (ml->sigblock) {
sigset_t sigs;
@@ -270,7 +270,7 @@ static int mnt_wait_mtab_lock(struct libmnt_lock *ml, struct flock *fl, time_t m
sigaction(SIGALRM, &sa, &osa);
- DBG(LOCKS, mnt_debug_h(ml, "(%d) waiting for F_SETLKW", getpid()));
+ DBG(LOCKS, ul_debugobj(ml, "(%d) waiting for F_SETLKW", getpid()));
alarm(maxtime - now.tv_sec);
if (fcntl(ml->lockfile_fd, F_SETLKW, fl) == -1)
@@ -280,7 +280,7 @@ static int mnt_wait_mtab_lock(struct libmnt_lock *ml, struct flock *fl, time_t m
/* restore old sigaction */
sigaction(SIGALRM, &osa, NULL);
- DBG(LOCKS, mnt_debug_h(ml, "(%d) leaving mnt_wait_setlkw(), rc=%d",
+ DBG(LOCKS, ul_debugobj(ml, "(%d) leaving mnt_wait_setlkw(), rc=%d",
getpid(), ret));
return ret;
}
@@ -360,7 +360,7 @@ static void unlock_mtab(struct libmnt_lock *ml)
close(ml->lockfile_fd);
if (ml->locked && ml->lockfile) {
unlink(ml->lockfile);
- DBG(LOCKS, mnt_debug_h(ml, "unlink %s", ml->lockfile));
+ DBG(LOCKS, ul_debugobj(ml, "unlink %s", ml->lockfile));
}
}
@@ -452,7 +452,7 @@ static int lock_mtab(struct libmnt_lock *ml)
if (ml->locked) {
/* We made the link. Now claim the lock. */
if (fcntl (ml->lockfile_fd, F_SETLK, &flock) == -1) {
- DBG(LOCKS, mnt_debug_h(ml,
+ DBG(LOCKS, ul_debugobj(ml,
"%s: can't F_SETLK lockfile, errno=%d\n",
lockfile, errno));
/* proceed, since it was us who created the lockfile anyway */
@@ -463,7 +463,7 @@ static int lock_mtab(struct libmnt_lock *ml)
int err = mnt_wait_mtab_lock(ml, &flock, maxtime.tv_sec);
if (err == 1) {
- DBG(LOCKS, mnt_debug_h(ml,
+ DBG(LOCKS, ul_debugobj(ml,
"%s: can't create link: time out (perhaps "
"there is a stale lock file?)", lockfile));
rc = -ETIMEDOUT;
@@ -478,7 +478,7 @@ static int lock_mtab(struct libmnt_lock *ml)
ml->lockfile_fd = -1;
}
}
- DBG(LOCKS, mnt_debug_h(ml, "%s: (%d) successfully locked",
+ DBG(LOCKS, ul_debugobj(ml, "%s: (%d) successfully locked",
lockfile, getpid()));
unlink(linkfile);
return 0;
@@ -531,7 +531,7 @@ void mnt_unlock_file(struct libmnt_lock *ml)
if (!ml)
return;
- DBG(LOCKS, mnt_debug_h(ml, "(%d) %s", getpid(),
+ DBG(LOCKS, ul_debugobj(ml, "(%d) %s", getpid(),
ml->locked ? "unlocking" : "cleaning"));
if (ml->simplelock)
@@ -543,7 +543,7 @@ void mnt_unlock_file(struct libmnt_lock *ml)
ml->lockfile_fd = -1;
if (ml->sigblock) {
- DBG(LOCKS, mnt_debug_h(ml, "restoring sigmask"));
+ DBG(LOCKS, ul_debugobj(ml, "restoring sigmask"));
sigprocmask(SIG_SETMASK, &ml->oldsigmask, NULL);
}
}
diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h
index e703f9bb7..eaaffa281 100644
--- a/libmount/src/mountP.h
+++ b/libmount/src/mountP.h
@@ -17,6 +17,8 @@
#include <sys/types.h>
#include <sys/vfs.h>
#include <unistd.h>
+#include <stdio.h>
+#include <stdarg.h>
#include "c.h"
#include "list.h"
@@ -25,7 +27,6 @@
/* features */
#define CONFIG_LIBMOUNT_ASSERT
-#define CONFIG_LIBMOUNT_DEBUG
#ifdef CONFIG_LIBMOUNT_ASSERT
# include <assert.h>
@@ -36,10 +37,6 @@
/*
* Debug
*/
-#if defined(TEST_PROGRAM) && !defined(LIBMOUNT_DEBUG)
-#define CONFIG_LIBMOUNT_DEBUG
-#endif
-
#define MNT_DEBUG_INIT (1 << 1)
#define MNT_DEBUG_CACHE (1 << 2)
#define MNT_DEBUG_OPTIONS (1 << 3)
@@ -53,56 +50,10 @@
#define MNT_DEBUG_DIFF (1 << 11)
#define MNT_DEBUG_ALL 0xFFFF
-#define MNT_DEF_FLAG(m) UL_DEFINE_FLAG(MNT_DEBUG_, m)
-
-# include <stdio.h>
-# include <stdarg.h>
-
-#define DBG(m, x) do { __UL_DBG(libmount, MNT_DEBUG_, m, x); } while (0)
-
-# define WARN_REFCOUNT(m, o, r) \
- do { \
- if ((MNT_DEBUG_ ## m) & libmount_debug_mask && r != 0) \
- fprintf(stderr, "%d: libmount: %8s: [%p]: *** deallocates with refcount=%d\n", \
- getpid(), # m, o, r); \
- } while (0)
-
-# define ON_DBG(m, x) do { \
- if ((MNT_DEBUG_ ## m) & libmount_debug_mask) { \
- x; \
- } \
- } while (0)
-
-# define DBG_FLUSH do { \
- if (libmount_debug_mask && \
- libmount_debug_mask != MNT_DEBUG_INIT) \
- fflush(stderr); \
- } while(0)
-
UL_DEBUG_DECLARE_MASK(libmount);
-
-static inline void __attribute__ ((__format__ (__printf__, 1, 2)))
-mnt_debug(const char *mesg, ...)
-{
- va_list ap;
- va_start(ap, mesg);
- vfprintf(stderr, mesg, ap);
- va_end(ap);
- fputc('\n', stderr);
-}
-
-static inline void __attribute__ ((__format__ (__printf__, 2, 3)))
-mnt_debug_h(void *handler, const char *mesg, ...)
-{
- va_list ap;
-
- if (handler)
- fprintf(stderr, "[%p]: ", handler);
- va_start(ap, mesg);
- vfprintf(stderr, mesg, ap);
- va_end(ap);
- fputc('\n', stderr);
-}
+#define DBG(m, x) __UL_DBG(libmount, MNT_DEBUG_, m, x)
+#define ON_DBG(m, x) __UL_DBG_CALL(libmount, MNT_DEBUG_, m, x)
+#define DBG_FLUSH __UL_DBG_FLUSH(libmount, MNT_DEBUG_)
/* extension for files in the directory */
#define MNT_MNTTABDIR_EXT ".fstab"
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index 2cd55685e..b1ac254ac 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -106,7 +106,7 @@ static int mnt_optstr_parse_next(char **optstr, char **name, size_t *namesz,
return 1; /* end of optstr */
error:
- DBG(OPTIONS, mnt_debug("parse error: \"%s\"", optstr0));
+ DBG(OPTIONS, ul_debug("parse error: \"%s\"", optstr0));
return -EINVAL;
}
@@ -268,7 +268,7 @@ int mnt_optstr_prepend_option(char **optstr, const char *name, const char *value
free(*optstr);
*optstr = tmp;
- DBG(OPTIONS, mnt_debug("failed to prepend '%s[=%s]' to '%s'",
+ DBG(OPTIONS, ul_debug("failed to prepend '%s[=%s]' to '%s'",
name, value, *optstr));
return rc;
}
@@ -746,7 +746,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
if (!optstr || !map)
return -EINVAL;
- DBG(CXT, mnt_debug("applying 0x%08lu flags to '%s'", flags, *optstr));
+ DBG(CXT, ul_debug("applying 0x%08lu flags to '%s'", flags, *optstr));
maps[0] = map;
next = *optstr;
@@ -845,10 +845,10 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
}
}
- DBG(CXT, mnt_debug("new optstr '%s'", *optstr));
+ DBG(CXT, ul_debug("new optstr '%s'", *optstr));
return rc;
err:
- DBG(CXT, mnt_debug("failed to apply flags [rc=%d]", rc));
+ DBG(CXT, ul_debug("failed to apply flags [rc=%d]", rc));
return rc;
}
@@ -887,7 +887,7 @@ int mnt_optstr_fix_secontext(char **optstr,
if (!optstr || !*optstr || !value || !valsz)
return -EINVAL;
- DBG(CXT, mnt_debug("fixing SELinux context"));
+ DBG(CXT, ul_debug("fixing SELinux context"));
begin = value;
end = value + valsz;
@@ -908,7 +908,7 @@ int mnt_optstr_fix_secontext(char **optstr,
/* translate the context */
rc = selinux_trans_to_raw_context((security_context_t) p, &raw);
- DBG(CXT, mnt_debug("SELinux context '%s' translated to '%s'",
+ DBG(CXT, ul_debug("SELinux context '%s' translated to '%s'",
p, rc == -1 ? "FAILED" : (char *) raw));
free(p);
@@ -974,7 +974,7 @@ 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"));
+ DBG(CXT, ul_debug("fixing uid"));
end = value + valsz;
@@ -1021,7 +1021,7 @@ 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"));
+ DBG(CXT, ul_debug("fixing gid"));
end = value + valsz;
@@ -1060,7 +1060,7 @@ int mnt_optstr_fix_user(char **optstr)
struct libmnt_optloc ol;
int rc = 0;
- DBG(CXT, mnt_debug("fixing user"));
+ DBG(CXT, ul_debug("fixing user"));
mnt_init_optloc(&ol);
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 332312b68..33e0eb835 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -79,7 +79,7 @@ struct libmnt_table *mnt_new_table(void)
if (!tb)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "alloc"));
+ DBG(TAB, ul_debugobj(tb, "alloc"));
tb->refcount = 1;
INIT_LIST_HEAD(&tb->ents);
return tb;
@@ -99,7 +99,7 @@ int mnt_reset_table(struct libmnt_table *tb)
if (!tb)
return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "reset"));
+ DBG(TAB, ul_debugobj(tb, "reset"));
while (!list_empty(&tb->ents)) {
struct libmnt_fs *fs = list_entry(tb->ents.next,
@@ -121,7 +121,7 @@ void mnt_ref_table(struct libmnt_table *tb)
{
if (tb) {
tb->refcount++;
- /*DBG(FS, mnt_debug_h(tb, "ref=%d", tb->refcount));*/
+ /*DBG(FS, ul_debugobj(tb, "ref=%d", tb->refcount));*/
}
}
@@ -136,7 +136,7 @@ void mnt_unref_table(struct libmnt_table *tb)
{
if (tb) {
tb->refcount--;
- /*DBG(FS, mnt_debug_h(tb, "unref=%d", tb->refcount));*/
+ /*DBG(FS, ul_debugobj(tb, "unref=%d", tb->refcount));*/
if (tb->refcount <= 0)
mnt_free_table(tb);
}
@@ -159,9 +159,7 @@ void mnt_free_table(struct libmnt_table *tb)
return;
mnt_reset_table(tb);
-
- WARN_REFCOUNT(TAB, tb, tb->refcount);
- DBG(TAB, mnt_debug_h(tb, "free"));
+ DBG(TAB, ul_debugobj(tb, "free [refcount=%d]", tb->refcount));
mnt_unref_cache(tb->cache);
free(tb->comm_intro);
@@ -446,7 +444,7 @@ int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
list_add_tail(&fs->ents, &tb->ents);
tb->nents++;
- DBG(TAB, mnt_debug_h(tb, "add entry: %s %s",
+ DBG(TAB, ul_debugobj(tb, "add entry: %s %s",
mnt_fs_get_source(fs), mnt_fs_get_target(fs)));
return 0;
}
@@ -508,7 +506,7 @@ int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
if (!tb || !root || !is_mountinfo(tb))
return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "lookup root fs"));
+ DBG(TAB, ul_debugobj(tb, "lookup root fs"));
*root = NULL;
@@ -546,7 +544,7 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
if (!tb || !itr || !parent || !is_mountinfo(tb))
return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "lookup next child of '%s'",
+ DBG(TAB, ul_debugobj(tb, "lookup next child of '%s'",
mnt_fs_get_target(parent)));
parent_id = mnt_fs_get_id(parent);
@@ -690,7 +688,7 @@ int mnt_table_find_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
if (!tb || !itr || !fs || !match_func)
return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "lookup next fs"));
+ DBG(TAB, ul_debugobj(tb, "lookup next fs"));
if (!itr->head)
MNT_ITER_INIT(itr, &tb->ents);
@@ -721,7 +719,7 @@ static int mnt_table_move_parent(struct libmnt_table *tb, int oldid, int newid)
if (list_empty(&tb->ents))
return 0;
- DBG(TAB, mnt_debug_h(tb, "moving parent ID from %d -> %d", oldid, newid));
+ DBG(TAB, ul_debugobj(tb, "moving parent ID from %d -> %d", oldid, newid));
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
@@ -769,7 +767,7 @@ int mnt_table_uniq_fs(struct libmnt_table *tb, int flags,
if (flags & MNT_UNIQ_FORWARD)
direction = MNT_ITER_FORWARD;
- DBG(TAB, mnt_debug_h(tb, "de-duplicate"));
+ DBG(TAB, ul_debugobj(tb, "de-duplicate"));
mnt_reset_iter(&itr, direction);
if ((flags & MNT_UNIQ_KEEPTREE) && !is_mountinfo(tb))
@@ -792,7 +790,7 @@ int mnt_table_uniq_fs(struct libmnt_table *tb, int flags,
mnt_table_move_parent(tb, mnt_fs_get_id(fs),
mnt_fs_get_parent_id(fs));
- DBG(TAB, mnt_debug_h(tb, "remove duplicate %s",
+ DBG(TAB, ul_debugobj(tb, "remove duplicate %s",
mnt_fs_get_target(fs)));
mnt_table_remove_fs(tb, fs);
}
@@ -848,7 +846,7 @@ struct libmnt_fs *mnt_table_find_mountpoint(struct libmnt_table *tb,
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup MOUNTPOINT: '%s'", path));
+ DBG(TAB, ul_debugobj(tb, "lookup MOUNTPOINT: '%s'", path));
mnt = strdup(path);
if (!mnt)
@@ -900,7 +898,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup TARGET: '%s'", path));
+ DBG(TAB, ul_debugobj(tb, "lookup TARGET: '%s'", path));
/* native @target */
mnt_reset_iter(&itr, direction);
@@ -911,7 +909,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
if (!tb->cache || !(cn = mnt_resolve_path(path, tb->cache)))
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup canonical TARGET: '%s'", cn));
+ DBG(TAB, ul_debugobj(tb, "lookup canonical TARGET: '%s'", cn));
/* canonicalized paths in struct libmnt_table */
mnt_reset_iter(&itr, direction);
@@ -974,7 +972,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup SRCPATH: '%s'", path));
+ DBG(TAB, ul_debugobj(tb, "lookup SRCPATH: '%s'", path));
/* native paths */
mnt_reset_iter(&itr, direction);
@@ -988,7 +986,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
if (!path || !tb->cache || !(cn = mnt_resolve_path(path, tb->cache)))
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup canonical SRCPATH: '%s'", cn));
+ DBG(TAB, ul_debugobj(tb, "lookup canonical SRCPATH: '%s'", cn));
nents = mnt_table_get_nents(tb);
@@ -1084,7 +1082,7 @@ struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag,
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup by TAG: %s %s", tag, val));
+ DBG(TAB, ul_debugobj(tb, "lookup by TAG: %s %s", tag, val));
/* look up by TAG */
mnt_reset_iter(&itr, direction);
@@ -1129,7 +1127,7 @@ struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb,
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: '%s'", source));
+ DBG(TAB, ul_debugobj(tb, "lookup SOURCE: '%s'", source));
if (blkid_parse_tag_string(source, &t, &v) || !mnt_valid_tagname(t))
fs = mnt_table_find_srcpath(tb, source, direction);
@@ -1169,7 +1167,7 @@ struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *sourc
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s TARGET: %s", source, target));
+ DBG(TAB, ul_debugobj(tb, "lookup SOURCE: %s TARGET: %s", source, target));
mnt_reset_iter(&itr, direction);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
@@ -1206,7 +1204,7 @@ struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb,
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup DEVNO: %d", (int) devno));
+ DBG(TAB, ul_debugobj(tb, "lookup DEVNO: %d", (int) devno));
mnt_reset_iter(&itr, direction);
@@ -1244,7 +1242,7 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
assert(fs);
assert(fsroot);
- DBG(TAB, mnt_debug("lookup fs-root for '%s'", mnt_fs_get_source(fs)));
+ DBG(TAB, ul_debug("lookup fs-root for '%s'", mnt_fs_get_source(fs)));
fstype = mnt_fs_get_fstype(fs);
@@ -1252,7 +1250,7 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
const char *src, *src_root;
char *xsrc = NULL;
- DBG(TAB, mnt_debug("fs-root for bind"));
+ DBG(TAB, ul_debug("fs-root for bind"));
src = xsrc = mnt_resolve_spec(mnt_fs_get_source(fs), tb->cache);
if (src)
@@ -1269,7 +1267,7 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
src_fs = mnt_table_find_target(tb, mnt, MNT_ITER_BACKWARD);
if (!src_fs) {
- DBG(TAB, mnt_debug("not found '%s' in mountinfo -- using default", mnt));
+ DBG(TAB, ul_debug("not found '%s' in mountinfo -- using default", mnt));
goto dflt;
}
@@ -1301,7 +1299,7 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
if (mnt_fs_get_option(fs, "subvol", &vol, &volsz))
goto dflt;
- DBG(TAB, mnt_debug("setting FS root: btrfs subvol"));
+ DBG(TAB, ul_debug("setting FS root: btrfs subvol"));
sz = volsz;
if (*vol != '/')
@@ -1323,7 +1321,7 @@ dflt:
}
*fsroot = root;
- DBG(TAB, mnt_debug("FS root result: %s", root));
+ DBG(TAB, ul_debug("FS root result: %s", root));
free(mnt);
return src_fs;
@@ -1367,11 +1365,11 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
assert(tb);
assert(fstab_fs);
- DBG(FS, mnt_debug_h(fstab_fs, "is FS mounted? [target=%s]",
+ DBG(FS, ul_debugobj(fstab_fs, "is FS mounted? [target=%s]",
mnt_fs_get_target(fstab_fs)));
if (mnt_fs_is_swaparea(fstab_fs) || mnt_table_is_empty(tb)) {
- DBG(FS, mnt_debug_h(fstab_fs, "- ignore (swap or no data)"));
+ DBG(FS, ul_debugobj(fstab_fs, "- ignore (swap or no data)"));
return 0;
}
@@ -1405,7 +1403,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
tgt = mnt_fs_get_target(fstab_fs);
if (!tgt || !src) {
- DBG(FS, mnt_debug_h(fstab_fs, "- ignore (no source/target)"));
+ DBG(FS, ul_debugobj(fstab_fs, "- ignore (no source/target)"));
goto done;
}
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
@@ -1433,7 +1431,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
if (mnt_fs_get_option(fstab_fs, "offset", &val, &len) == 0 &&
mnt_parse_offset(val, len, &offset)) {
- DBG(FS, mnt_debug_h(fstab_fs, "failed to parse offset="));
+ DBG(FS, ul_debugobj(fstab_fs, "failed to parse offset="));
continue;
} else
flags = LOOPDEV_FL_OFFSET;
@@ -1468,7 +1466,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
done:
free(root);
- DBG(TAB, mnt_debug_h(tb, "mnt_table_is_fs_mounted: %s [rc=%d]", src, rc));
+ DBG(TAB, ul_debugobj(tb, "mnt_table_is_fs_mounted: %s [rc=%d]", src, rc));
return rc;
}
diff --git a/libmount/src/tab_diff.c b/libmount/src/tab_diff.c
index 052278233..970664bd8 100644
--- a/libmount/src/tab_diff.c
+++ b/libmount/src/tab_diff.c
@@ -42,7 +42,7 @@ struct libmnt_tabdiff *mnt_new_tabdiff(void)
if (!df)
return NULL;
- DBG(DIFF, mnt_debug_h(df, "alloc"));
+ DBG(DIFF, ul_debugobj(df, "alloc"));
INIT_LIST_HEAD(&df->changes);
INIT_LIST_HEAD(&df->unused);
@@ -70,7 +70,7 @@ void mnt_free_tabdiff(struct libmnt_tabdiff *df)
if (!df)
return;
- DBG(DIFF, mnt_debug_h(df, "free"));
+ DBG(DIFF, ul_debugobj(df, "free"));
while (!list_empty(&df->changes)) {
struct tabdiff_entry *de = list_entry(df->changes.next,
@@ -126,7 +126,7 @@ static int tabdiff_reset(struct libmnt_tabdiff *df)
{
assert(df);
- DBG(DIFF, mnt_debug_h(df, "resetting"));
+ DBG(DIFF, ul_debugobj(df, "resetting"));
/* zeroize all entries and move them to the list of unused
*/
@@ -155,7 +155,7 @@ static int tabdiff_add_entry(struct libmnt_tabdiff *df, struct libmnt_fs *old,
assert(df);
- DBG(DIFF, mnt_debug_h(df, "add change on %s",
+ DBG(DIFF, ul_debugobj(df, "add change on %s",
mnt_fs_get_target(new ? new : old)));
if (!list_empty(&df->unused)) {
@@ -240,7 +240,7 @@ int mnt_diff_tables(struct libmnt_tabdiff *df, struct libmnt_table *old_tab,
if (!no && !nn) /* both tables are empty */
return 0;
- DBG(DIFF, mnt_debug_h(df, "analyze new=%p (%d entries), "
+ DBG(DIFF, ul_debugobj(df, "analyze new=%p (%d entries), "
"old=%p (%d entries)",
new_tab, nn, old_tab, no));
@@ -300,7 +300,7 @@ int mnt_diff_tables(struct libmnt_tabdiff *df, struct libmnt_table *old_tab,
}
}
done:
- DBG(DIFF, mnt_debug_h(df, "%d changes detected", df->nchanges));
+ DBG(DIFF, ul_debugobj(df, "%d changes detected", df->nchanges));
return df->nchanges;
}
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 7c73cc553..06c5bd469 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -87,7 +87,7 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
free(optstr);
optstr = NULL;
} else {
- DBG(TAB, mnt_debug("tab parse error: [sscanf rc=%d]: '%s'", rc, s));
+ DBG(TAB, ul_debug("tab parse error: [sscanf rc=%d]: '%s'", rc, s));
rc = -EINVAL;
}
@@ -95,7 +95,7 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
free(src);
free(fstype);
free(optstr);
- DBG(TAB, mnt_debug("tab parse error: [set vars, rc=%d]\n", rc));
+ DBG(TAB, ul_debug("tab parse error: [set vars, rc=%d]\n", rc));
return rc; /* error */
}
@@ -106,11 +106,11 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
if (xrc == 4 && *s) {
if (next_number(&s, &fs->freq) != 0) {
if (*s) {
- DBG(TAB, mnt_debug("tab parse error: [freq]"));
+ DBG(TAB, ul_debug("tab parse error: [freq]"));
rc = -EINVAL;
}
} else if (next_number(&s, &fs->passno) != 0 && *s) {
- DBG(TAB, mnt_debug("tab parse error: [passno]"));
+ DBG(TAB, ul_debug("tab parse error: [passno]"));
rc = -EINVAL;
}
}
@@ -149,7 +149,7 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
/* (7) optional fields, terminated by " - " */
p = strstr(s, " - ");
if (!p) {
- DBG(TAB, mnt_debug("mountinfo parse error: separator not found"));
+ DBG(TAB, ul_debug("mountinfo parse error: separator not found"));
return -EINVAL;
}
if (p > s + 1)
@@ -201,7 +201,7 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
} else {
free(fstype);
free(src);
- DBG(TAB, mnt_debug(
+ DBG(TAB, ul_debug(
"mountinfo parse error [sscanf rc=%d]: '%s'", rc, s));
rc = -EINVAL;
}
@@ -268,7 +268,7 @@ static int mnt_parse_utab_line(struct libmnt_fs *fs, const char *s)
return 0;
enomem:
- DBG(TAB, mnt_debug("utab parse error: ENOMEM"));
+ DBG(TAB, ul_debug("utab parse error: ENOMEM"));
return -ENOMEM;
}
@@ -314,7 +314,7 @@ static int mnt_parse_swaps_line(struct libmnt_fs *fs, char *s)
mnt_fs_set_fstype(fs, "swap");
free(src);
} else {
- DBG(TAB, mnt_debug("tab parse error: [sscanf rc=%d]: '%s'", rc, s));
+ DBG(TAB, ul_debug("tab parse error: [sscanf rc=%d]: '%s'", rc, s));
rc = -EINVAL;
}
@@ -335,7 +335,7 @@ static int guess_table_format(char *line)
{
unsigned int a, b;
- DBG(TAB, mnt_debug("trying to guess table type"));
+ DBG(TAB, ul_debug("trying to guess table type"));
if (sscanf(line, "%u %u", &a, &b) == 2)
return MNT_FMT_MOUNTINFO;
@@ -400,7 +400,7 @@ static int append_comment(struct libmnt_table *tb,
if (intro && is_terminated_by_blank(mnt_table_get_intro_comment(tb)))
intro = 0;
- DBG(TAB, mnt_debug_h(tb, "appending %s comment",
+ DBG(TAB, ul_debugobj(tb, "appending %s comment",
intro ? "intro" :
eof ? "trailing" : "fs"));
if (intro)
@@ -443,11 +443,11 @@ next_line:
/* Missing final newline? Otherwise an extremely */
/* long line - assume file was corrupted */
if (feof(f)) {
- DBG(TAB, mnt_debug_h(tb,
+ DBG(TAB, ul_debugobj(tb,
"%s: no final newline", filename));
s = strchr (buf, '\0');
} else {
- DBG(TAB, mnt_debug_h(tb,
+ DBG(TAB, ul_debugobj(tb,
"%s:%d: missing newline at line",
filename, *nlines));
goto err;
@@ -508,7 +508,7 @@ next_line:
if (rc == 0)
return 0;
err:
- DBG(TAB, mnt_debug_h(tb, "%s:%d: %s parse error", filename, *nlines,
+ DBG(TAB, ul_debugobj(tb, "%s:%d: %s parse error", filename, *nlines,
tb->fmt == MNT_FMT_MOUNTINFO ? "mountinfo" :
tb->fmt == MNT_FMT_SWAPS ? "swaps" :
tb->fmt == MNT_FMT_FSTAB ? "tab" : "utab"));
@@ -542,7 +542,7 @@ static pid_t path_to_tid(const char *filename)
tid = 0;
goto done;
}
- DBG(TAB, mnt_debug("TID for %s is %d", filename, tid));
+ DBG(TAB, ul_debug("TID for %s is %d", filename, tid));
done:
free(path);
return tid;
@@ -570,11 +570,11 @@ static int kernel_fs_postparse(struct libmnt_table *tb,
char *spec = mnt_get_kernel_cmdline_option("root=");
char *real = NULL;
- DBG(TAB, mnt_debug_h(tb, "root FS: %s", spec));
+ DBG(TAB, ul_debugobj(tb, "root FS: %s", spec));
if (spec)
real = mnt_resolve_spec(spec, tb->cache);
if (real) {
- DBG(TAB, mnt_debug_h(tb, "canonical root FS: %s", real));
+ DBG(TAB, ul_debugobj(tb, "canonical root FS: %s", real));
rc = mnt_fs_set_source(fs, real);
if (!tb->cache)
free(real);
@@ -604,7 +604,7 @@ int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filenam
assert(f);
assert(filename);
- DBG(TAB, mnt_debug_h(tb, "%s: start parsing [entries=%d, filter=%s]",
+ DBG(TAB, ul_debugobj(tb, "%s: start parsing [entries=%d, filter=%s]",
filename, mnt_table_get_nents(tb),
tb->fltrcb ? "yes" : "not"));
@@ -643,11 +643,11 @@ int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filenam
}
}
- DBG(TAB, mnt_debug_h(tb, "%s: stop parsing (%d entries)",
+ DBG(TAB, ul_debugobj(tb, "%s: stop parsing (%d entries)",
filename, mnt_table_get_nents(tb)));
return 0;
err:
- DBG(TAB, mnt_debug_h(tb, "%s: parse error (rc=%d)", filename, rc));
+ DBG(TAB, ul_debugobj(tb, "%s: parse error (rc=%d)", filename, rc));
return rc;
}
@@ -906,7 +906,7 @@ int mnt_table_set_parser_fltrcb(struct libmnt_table *tb,
if (!tb)
return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "%s table parser filter", cb ? "set" : "unset"));
+ DBG(TAB, ul_debugobj(tb, "%s table parser filter", cb ? "set" : "unset"));
tb->fltrcb = cb;
tb->fltrcb_data = data;
return 0;
@@ -998,7 +998,7 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
if (!tb || !uf)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "merging user fs"));
+ DBG(TAB, ul_debugobj(tb, "merging user fs"));
src = mnt_fs_get_srcpath(uf);
target = mnt_fs_get_target(uf);
@@ -1024,13 +1024,13 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
}
if (fs) {
- DBG(TAB, mnt_debug_h(tb, "found fs -- appending user optstr"));
+ DBG(TAB, ul_debugobj(tb, "found fs -- appending user optstr"));
mnt_fs_append_options(fs, optstr);
mnt_fs_append_attributes(fs, attrs);
mnt_fs_set_bindsrc(fs, mnt_fs_get_bindsrc(uf));
fs->flags |= MNT_FS_MERGED;
- DBG(TAB, mnt_debug_h(tb, "found fs:"));
+ DBG(TAB, ul_debugobj(tb, "found fs:"));
DBG(TAB, mnt_fs_print_debug(fs, stderr));
}
return fs;
@@ -1045,7 +1045,7 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
if (mnt_has_regular_mtab(&filename, NULL)) {
- DBG(TAB, mnt_debug_h(tb, "force %s usage", filename));
+ DBG(TAB, ul_debugobj(tb, "force %s usage", filename));
rc = mnt_table_parse_file(tb, filename);
if (!rc)
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
index bbe0cb2d7..27b41abb0 100644
--- a/libmount/src/tab_update.c
+++ b/libmount/src/tab_update.c
@@ -53,7 +53,7 @@ struct libmnt_update *mnt_new_update(void)
if (!upd)
return NULL;
- DBG(UPDATE, mnt_debug_h(upd, "allocate"));
+ DBG(UPDATE, ul_debugobj(upd, "allocate"));
return upd;
}
@@ -68,7 +68,7 @@ void mnt_free_update(struct libmnt_update *upd)
if (!upd)
return;
- DBG(UPDATE, mnt_debug_h(upd, "free"));
+ DBG(UPDATE, ul_debugobj(upd, "free"));
mnt_unref_fs(upd->fs);
mnt_unref_table(upd->mountinfo);
@@ -172,11 +172,11 @@ int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
if (target && fs)
return -EINVAL;
- DBG(UPDATE, mnt_debug_h(upd,
+ DBG(UPDATE, ul_debugobj(upd,
"resetting FS [fs=0x%p, target=%s, flags=0x%08lx]",
fs, target, mountflags));
if (fs) {
- DBG(UPDATE, mnt_debug_h(upd, "FS template:"));
+ DBG(UPDATE, ul_debugobj(upd, "FS template:"));
DBG(UPDATE, mnt_fs_print_debug(fs, stderr));
}
@@ -194,7 +194,7 @@ int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
rc = mnt_update_set_filename(upd, NULL, 0);
if (rc) {
- DBG(UPDATE, mnt_debug_h(upd, "no writable file available [rc=%d]", rc));
+ DBG(UPDATE, ul_debugobj(upd, "no writable file available [rc=%d]", rc));
return rc; /* error or no file available (rc = 1) */
}
if (target) {
@@ -216,7 +216,7 @@ int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
}
- DBG(UPDATE, mnt_debug_h(upd, "ready"));
+ DBG(UPDATE, ul_debugobj(upd, "ready"));
upd->ready = TRUE;
return 0;
}
@@ -306,7 +306,7 @@ static int utab_new_entry(struct libmnt_update *upd, struct libmnt_fs *fs,
assert(upd->fs == NULL);
assert(!(mountflags & MS_MOVE));
- DBG(UPDATE, mnt_debug("prepare utab entry"));
+ DBG(UPDATE, ul_debug("prepare utab entry"));
o = mnt_fs_get_user_options(fs);
a = mnt_fs_get_attributes(fs);
@@ -322,7 +322,7 @@ static int utab_new_entry(struct libmnt_update *upd, struct libmnt_fs *fs,
}
if (!u && !a) {
- DBG(UPDATE, mnt_debug("utab entry unnecessary (no options)"));
+ DBG(UPDATE, ul_debug("utab entry unnecessary (no options)"));
return 1;
}
@@ -347,7 +347,7 @@ static int utab_new_entry(struct libmnt_update *upd, struct libmnt_fs *fs,
}
free(u);
- DBG(UPDATE, mnt_debug("utab entry OK"));
+ DBG(UPDATE, ul_debug("utab entry OK"));
return 0;
err:
free(u);
@@ -369,7 +369,7 @@ static int set_fs_root(struct libmnt_update *upd, struct libmnt_fs *fs,
const char *src;
int rc = 0;
- DBG(UPDATE, mnt_debug("setting FS root"));
+ DBG(UPDATE, ul_debug("setting FS root"));
assert(upd);
assert(upd->fs);
@@ -518,7 +518,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
if (!tb || !upd->filename)
return -EINVAL;
- DBG(UPDATE, mnt_debug_h(upd, "%s: updating", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: updating", upd->filename));
fd = mnt_open_uniq_filename(upd->filename, &uq);
if (fd < 0)
@@ -541,7 +541,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
else
rc = fprintf_mtab_fs(f, fs);
if (rc) {
- DBG(UPDATE, mnt_debug_h(upd,
+ DBG(UPDATE, ul_debugobj(upd,
"%s: write entry failed: %m", uq));
goto leave;
}
@@ -551,7 +551,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
if (fflush(f) != 0) {
rc = -errno;
- DBG(UPDATE, mnt_debug_h(upd, "%s: fflush failed: %m", uq));
+ DBG(UPDATE, ul_debugobj(upd, "%s: fflush failed: %m", uq));
goto leave;
}
@@ -610,7 +610,7 @@ int mnt_table_write_file(struct libmnt_table *tb, FILE *file)
if (fflush(file) != 0)
rc = -errno;
- DBG(TAB, mnt_debug_h(tb, "write file done [rc=%d]", rc));
+ DBG(TAB, ul_debugobj(tb, "write file done [rc=%d]", rc));
return rc;
}
@@ -629,7 +629,7 @@ int mnt_table_replace_file(struct libmnt_table *tb, const char *filename)
FILE *f;
char *uq = NULL;
- DBG(TAB, mnt_debug_h(tb, "%s: replacing", filename));
+ DBG(TAB, ul_debugobj(tb, "%s: replacing", filename));
fd = mnt_open_uniq_filename(filename, &uq);
if (fd < 0)
@@ -643,7 +643,7 @@ int mnt_table_replace_file(struct libmnt_table *tb, const char *filename)
if (fflush(f) != 0) {
rc = -errno;
- DBG(UPDATE, mnt_debug("%s: fflush failed: %m", uq));
+ DBG(UPDATE, ul_debug("%s: fflush failed: %m", uq));
goto leave;
}
@@ -669,7 +669,7 @@ leave:
unlink(uq);
free(uq);
- DBG(TAB, mnt_debug_h(tb, "replace done [rc=%d]", rc));
+ DBG(TAB, ul_debugobj(tb, "replace done [rc=%d]", rc));
return rc;
}
@@ -697,7 +697,7 @@ static int update_add_entry(struct libmnt_update *upd, struct libmnt_lock *lc)
assert(upd);
assert(upd->fs);
- DBG(UPDATE, mnt_debug_h(upd, "%s: add entry", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: add entry", upd->filename));
if (lc)
rc = mnt_lock_file(lc);
@@ -723,7 +723,7 @@ static int update_remove_entry(struct libmnt_update *upd, struct libmnt_lock *lc
assert(upd);
assert(upd->target);
- DBG(UPDATE, mnt_debug_h(upd, "%s: remove entry", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: remove entry", upd->filename));
if (lc)
rc = mnt_lock_file(lc);
@@ -752,7 +752,7 @@ static int update_modify_target(struct libmnt_update *upd, struct libmnt_lock *l
int rc = 0;
assert(upd);
- DBG(UPDATE, mnt_debug_h(upd, "%s: modify target", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: modify target", upd->filename));
if (lc)
rc = mnt_lock_file(lc);
@@ -787,7 +787,7 @@ static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock *
assert(upd);
assert(upd->fs);
- DBG(UPDATE, mnt_debug_h(upd, "%s: modify options", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: modify options", upd->filename));
fs = upd->fs;
@@ -845,7 +845,7 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc)
if (!upd->ready)
return 0;
- DBG(UPDATE, mnt_debug_h(upd, "%s: update tab", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: update tab", upd->filename));
if (upd->fs) {
DBG(UPDATE, mnt_fs_print_debug(upd->fs, stderr));
}
@@ -867,7 +867,7 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc)
rc = update_add_entry(upd, lc); /* mount */
upd->ready = FALSE;
- DBG(UPDATE, mnt_debug_h(upd, "%s: update tab: done [rc=%d]",
+ DBG(UPDATE, ul_debugobj(upd, "%s: update tab: done [rc=%d]",
upd->filename, rc));
if (lc != lc0)
mnt_free_lock(lc);
@@ -883,7 +883,7 @@ int mnt_update_already_done(struct libmnt_update *upd, struct libmnt_lock *lc)
if (!upd || !upd->filename || (!upd->fs && !upd->target))
return -EINVAL;
- DBG(UPDATE, mnt_debug_h(upd, "%s: checking for previous update", upd->filename));
+ DBG(UPDATE, ul_debugobj(upd, "%s: checking for previous update", upd->filename));
if (!lc) {
lc = mnt_new_lock(upd->filename, 0);
@@ -912,14 +912,14 @@ int mnt_update_already_done(struct libmnt_update *upd, struct libmnt_lock *lc)
mnt_fs_get_source(upd->fs);
if (mnt_table_find_pair(tb, src, tgt, MNT_ITER_BACKWARD)) {
- DBG(UPDATE, mnt_debug_h(upd, "%s: found %s %s",
+ DBG(UPDATE, ul_debugobj(upd, "%s: found %s %s",
upd->filename, src, tgt));
rc = 1;
}
} else if (upd->target) {
/* umount */
if (!mnt_table_find_target(tb, upd->target, MNT_ITER_BACKWARD)) {
- DBG(UPDATE, mnt_debug_h(upd, "%s: not-found (umounted) %s",
+ DBG(UPDATE, ul_debugobj(upd, "%s: not-found (umounted) %s",
upd->filename, upd->target));
rc = 1;
}
@@ -929,7 +929,7 @@ int mnt_update_already_done(struct libmnt_update *upd, struct libmnt_lock *lc)
done:
if (lc && lc != lc0)
mnt_free_lock(lc);
- DBG(UPDATE, mnt_debug_h(upd, "%s: previous update check done [rc=%d]",
+ DBG(UPDATE, ul_debugobj(upd, "%s: previous update check done [rc=%d]",
upd->filename, rc));
return rc;
}
@@ -942,7 +942,7 @@ static int update(const char *target, struct libmnt_fs *fs, unsigned long mountf
int rc;
struct libmnt_update *upd;
- DBG(UPDATE, mnt_debug("update test"));
+ DBG(UPDATE, ul_debug("update test"));
upd = mnt_new_update();
if (!upd)
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index b8b77472e..d82920905 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -143,7 +143,7 @@ int mnt_chdir_to_parent(const char *target, char **filename)
if (!target || *target != '/')
return -EINVAL;
- DBG(UTILS, mnt_debug("moving to %s parent", target));
+ DBG(UTILS, ul_debug("moving to %s parent", target));
buf = strdup(target);
if (!buf)
@@ -158,22 +158,22 @@ int mnt_chdir_to_parent(const char *target, char **filename)
parent = buf && *buf ? buf : "/";
if (chdir(parent) == -1) {
- DBG(UTILS, mnt_debug("failed to chdir to %s: %m", parent));
+ DBG(UTILS, ul_debug("failed to chdir to %s: %m", parent));
rc = -errno;
goto err;
}
if (!getcwd(cwd, sizeof(cwd))) {
- DBG(UTILS, mnt_debug("failed to obtain current directory: %m"));
+ DBG(UTILS, ul_debug("failed to obtain current directory: %m"));
rc = -errno;
goto err;
}
if (strcmp(cwd, parent) != 0) {
- DBG(UTILS, mnt_debug(
+ DBG(UTILS, ul_debug(
"unexpected chdir (expected=%s, cwd=%s)", parent, cwd));
goto err;
}
- DBG(CXT, mnt_debug(
+ DBG(CXT, ul_debug(
"current directory moved to %s [last_component='%s']",
parent, last));
@@ -582,7 +582,7 @@ static int get_filesystems(const char *filename, char ***filesystems, const char
if (!f)
return 1;
- DBG(UTILS, mnt_debug("reading filesystems list from: %s", filename));
+ DBG(UTILS, ul_debug("reading filesystems list from: %s", filename));
while (fgets(line, sizeof(line), f)) {
char name[sizeof(line)];
@@ -687,7 +687,7 @@ int mnt_get_uid(const char *username, uid_t *uid)
*uid= pw->pw_uid;
rc = 0;
} else {
- DBG(UTILS, mnt_debug(
+ DBG(UTILS, ul_debug(
"cannot convert '%s' username to UID", username));
rc = errno ? -errno : -EINVAL;
}
@@ -715,7 +715,7 @@ int mnt_get_gid(const char *groupname, gid_t *gid)
*gid= gr->gr_gid;
rc = 0;
} else {
- DBG(UTILS, mnt_debug(
+ DBG(UTILS, ul_debug(
"cannot convert '%s' groupname to GID", groupname));
rc = errno ? -errno : -EINVAL;
}
@@ -791,7 +791,7 @@ int mnt_has_regular_mtab(const char **mtab, int *writable)
if (mtab && !*mtab)
*mtab = filename;
- DBG(UTILS, mnt_debug("mtab: %s", filename));
+ DBG(UTILS, ul_debug("mtab: %s", filename));
rc = lstat(filename, &st);
@@ -813,7 +813,7 @@ int mnt_has_regular_mtab(const char **mtab, int *writable)
}
done:
- DBG(UTILS, mnt_debug("%s: irregular/non-writable", filename));
+ DBG(UTILS, ul_debug("%s: irregular/non-writable", filename));
return 0;
}
@@ -837,7 +837,7 @@ int mnt_has_regular_utab(const char **utab, int *writable)
if (utab && !*utab)
*utab = filename;
- DBG(UTILS, mnt_debug("utab: %s", filename));
+ DBG(UTILS, ul_debug("utab: %s", filename));
rc = lstat(filename, &st);
@@ -871,7 +871,7 @@ int mnt_has_regular_utab(const char **utab, int *writable)
return 1;
}
done:
- DBG(UTILS, mnt_debug("%s: irregular/non-writable file", filename));
+ DBG(UTILS, ul_debug("%s: irregular/non-writable file", filename));
return 0;
}
@@ -1011,7 +1011,7 @@ char *mnt_get_mountpoint(const char *path)
memcpy(mnt, "/", 2);
done:
- DBG(UTILS, mnt_debug("%s mountpoint is %s", path, mnt));
+ DBG(UTILS, ul_debug("%s mountpoint is %s", path, mnt));
return mnt;
err:
free(mnt);
@@ -1036,7 +1036,7 @@ char *mnt_get_fs_root(const char *path, const char *mnt)
free(m);
res = *p ? strdup(p) : strdup("/");
- DBG(UTILS, mnt_debug("%s fs-root is %s", path, res));
+ DBG(UTILS, ul_debug("%s fs-root is %s", path, res));
return res;
}
@@ -1141,7 +1141,7 @@ int mkdir_p(const char *path, mode_t mode)
p = e + 1;
}
- DBG(UTILS, mnt_debug("%s mkdir %s", path, rc ? "FAILED" : "SUCCESS"));
+ DBG(UTILS, ul_debug("%s mkdir %s", path, rc ? "FAILED" : "SUCCESS"));
free(dir);
return rc;
diff --git a/libmount/src/version.c b/libmount/src/version.c
index b72956230..1a1213419 100644
--- a/libmount/src/version.c
+++ b/libmount/src/version.c
@@ -22,12 +22,13 @@ static const char *lib_features[] = {
#ifdef HAVE_LIBSELINUX
"selinux",
#endif
-#ifdef CONFIG_LIBMOUNT_DEBUG
- "debug",
+#ifdef HAVE_SMACK
+ "smack",
#endif
#ifdef CONFIG_LIBMOUNT_ASSERT
"assert",
#endif
+ "debug", /* always enabled */
NULL
};