]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
debug: Introduce __UL_DBG_OBJ
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 20 Mar 2026 09:39:06 +0000 (10:39 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 31 Mar 2026 11:11:02 +0000 (13:11 +0200)
Merges debugobj.h into debug.c and increases flexibility in output:
Just like __UL_DBG any debug output function can be supplied.
Throughout the code, this is always ul_debug by today.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
81 files changed:
include/Makemodule.am
include/debug.h
include/debugobj.h [deleted file]
lib/debug.c
lib/fileeq.c
lib/loopdev.c
lib/netaddrq.c
lib/netlink.c
lib/path.c
lib/procfs.c
lib/pty-session.c
lib/sysfs.c
libblkid/src/blkidP.h
libblkid/src/cache.c
libblkid/src/dev.c
libblkid/src/tag.c
libfdisk/src/alignment.c
libfdisk/src/ask.c
libfdisk/src/context.c
libfdisk/src/fdiskP.h
libfdisk/src/item.c
libfdisk/src/label.c
libfdisk/src/partition.c
libfdisk/src/parttype.c
libfdisk/src/script.c
libfdisk/src/table.c
libfdisk/src/utils.c
libfdisk/src/wipe.c
libmount/src/cache.c
libmount/src/context.c
libmount/src/context_mount.c
libmount/src/context_umount.c
libmount/src/fs.c
libmount/src/fs_statmount.c
libmount/src/hook_idmap.c
libmount/src/hook_loopdev.c
libmount/src/hook_mkdir.c
libmount/src/hook_mount.c
libmount/src/hook_mount_legacy.c
libmount/src/hook_owner.c
libmount/src/hook_selinux.c
libmount/src/hook_subdir.c
libmount/src/hook_veritydev.c
libmount/src/hooks.c
libmount/src/lock.c
libmount/src/monitor.c
libmount/src/monitor_fanotify.c
libmount/src/monitor_mountinfo.c
libmount/src/monitor_utab.c
libmount/src/mountP.h
libmount/src/optlist.c
libmount/src/tab.c
libmount/src/tab_diff.c
libmount/src/tab_listmount.c
libmount/src/tab_parse.c
libmount/src/tab_update.c
libsmartcols/src/calculate.c
libsmartcols/src/cell.c
libsmartcols/src/column.c
libsmartcols/src/filter-expr.c
libsmartcols/src/filter-param.c
libsmartcols/src/filter.c
libsmartcols/src/grouping.c
libsmartcols/src/line.c
libsmartcols/src/print-api.c
libsmartcols/src/print.c
libsmartcols/src/smartcolsP.h
libsmartcols/src/table.c
libsmartcols/src/walk.c
misc-utils/lsblk-devtree.c
misc-utils/lsblk-properties.c
misc-utils/lsblk.c
misc-utils/lsblk.h
misc-utils/whereis.c
sys-utils/lscpu-cpu.c
sys-utils/lscpu-cputype.c
sys-utils/lscpu-topology.c
sys-utils/lscpu-virt.c
sys-utils/lscpu.c
sys-utils/lscpu.h
sys-utils/lsns.c

index 143677c8b9fed68bc4577ab2fa471bb3ec2866c5..8a9d6be00b0df649a41c44553df8eff282d13d3e 100644 (file)
@@ -21,7 +21,6 @@ dist_noinst_HEADERS += \
        include/crc64.h \
        include/c_strtod.h \
        include/debug.h \
-       include/debugobj.h \
        include/encode.h \
        include/env.h \
        include/exec_shell.h \
index 2881910a9971b3ec9009d1bb43f3936ac710ea1e..1af2799cf277f1bfa88321f37f3b4ce27634ff21 100644 (file)
@@ -58,15 +58,19 @@ struct ul_debug_maskname {
 #define __UL_DEBUG_FL_NOADDR   (1 << 24)       /* Don't print object address */
 
 
-/* l - library name, p - flag prefix, m - flag postfix, x - function */
-#define __UL_DBG(l, p, m, x) \
+/* l - library name, p - flag prefix, m - flag postfix, h - handle, x - function */
+#define __UL_DBG_OBJ(l, p, m, h, x) \
        do { \
                if ((p ## m) & l ## _debug_mask) { \
-                       fprintf(stderr, "%d: %s: %8s: ", getpid(), # l, # m); \
+                       ul_debug_prefix(# l, # m, h, l ## _debug_mask); \
                        x; \
                } \
        } while (0)
 
+/* l - library name, p - flag prefix, m - flag postfix, x - function */
+#define __UL_DBG(l, p, m, x) \
+       __UL_DBG_OBJ(l, p, m, NULL, x)
+
 #define __UL_DBG_CALL(l, p, m, x) \
        do { \
                if ((p ## m) & l ## _debug_mask) { \
@@ -108,6 +112,9 @@ struct ul_debug_maskname {
 
 extern void ul_debug(const char *mesg, ...)
                __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void ul_debugobj(const void *handler, int mask);
+extern void ul_debug_prefix(const char *lib, const char *flag,
+                           const void *handler, int mask);
 extern int ul_debug_parse_mask(const struct ul_debug_maskname flagnames[],
                               const char *mask);
 extern void ul_debug_print_masks(const char *env,
diff --git a/include/debugobj.h b/include/debugobj.h
deleted file mode 100644 (file)
index dbeaf8d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * No copyright is claimed.  This code is in the public domain; do with
- * it what you wish.
- */
-#ifndef UTIL_LINUX_DEBUGOBJ_H
-#define UTIL_LINUX_DEBUGOBJ_H
-
-/*
- * Include *after* debug.h and after UL_DEBUG_CURRENT_MASK define.
- */
-
-static inline void __attribute__ ((__format__ (__printf__, 2, 3)))
-ul_debugobj(const void *handler, const char *mesg, ...)
-{
-       va_list ap;
-
-       if (handler && !(UL_DEBUG_CURRENT_MASK & __UL_DEBUG_FL_NOADDR))
-               fprintf(stderr, "[%p]: ", handler);
-
-       va_start(ap, mesg);
-       vfprintf(stderr, mesg, ap);
-       va_end(ap);
-       fputc('\n', stderr);
-}
-
-#endif /* UTIL_LINUX_DEBUGOBJ_H */
index a56506c02ba7caa1603236cbcb025e24d0975de7..4ec79a0e82250c715825f3635829c11d8cc9e014 100644 (file)
@@ -20,6 +20,19 @@ void ul_debug(const char *mesg, ...)
        fputc('\n', stderr);
 }
 
+void ul_debugobj(const void *handler, int mask)
+{
+       if (handler && !(mask & __UL_DEBUG_FL_NOADDR))
+               fprintf(stderr, "[%p]: ", handler);
+}
+
+void ul_debug_prefix(const char *lib, const char *flag,
+                    const void *handler, int mask)
+{
+       fprintf(stderr, "%d: %s: %8s: ", getpid(), lib, flag);
+       ul_debugobj(handler, mask);
+}
+
 int ul_debug_parse_mask(const struct ul_debug_maskname flagnames[],
                        const char *mask)
 {
index 5a56b4753de8e3f3a4560d350d98d3e4af776f25..92c0c2c4b423ed64baae9d8a2ac3a0bda8830e42 100644 (file)
@@ -58,11 +58,9 @@ UL_DEBUG_DEFINE_MASKNAMES(ulfileeq) = UL_DEBUG_EMPTY_MASKNAMES;
 #define ULFILEEQ_DEBUG_DATA    (1 << 3)
 #define ULFILEEQ_DEBUG_EQ      (1 << 4)
 
-#define DBG(m, x)       __UL_DBG(ulfileeq, ULFILEEQ_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(ulfileeq, ULFILEEQ_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(ulfileeq)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(ulfileeq, ULFILEEQ_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(ulfileeq, ULFILEEQ_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(ulfileeq, ULFILEEQ_DEBUG_, m, x)
 
 static void ul_fileeq_init_debug(void)
 {
@@ -112,7 +110,7 @@ static void deinit_crypto_api(struct ul_fileeq *eq)
        if (!eq)
                return;
 
-       DBG(CRYPTO, ul_debugobj(eq, "deinit"));
+       DBG_OBJ(CRYPTO, eq, ul_debug("deinit"));
 
        if (eq->fd_cip >= 0)
                close(eq->fd_cip);
@@ -135,7 +133,7 @@ static int init_crypto_api(struct ul_fileeq *eq)
        assert(eq->fd_api == -1);
        assert(eq->fd_cip == -1);
 
-       DBG(CRYPTO, ul_debugobj(eq, "init [%s]", eq->method->kname));
+       DBG_OBJ(CRYPTO, eq, ul_debug("init [%s]", eq->method->kname));
 
        assert(sizeof(sa.salg_name) > strlen(eq->method->kname) + 1);
        memcpy(&sa.salg_name, eq->method->kname, strlen(eq->method->kname) + 1);
@@ -158,7 +156,7 @@ int ul_fileeq_init(struct ul_fileeq *eq, const char *method)
        size_t i;
 
        ul_fileeq_init_debug();
-       DBG(EQ, ul_debugobj(eq, "init [%s]", method));
+       DBG_OBJ(EQ, eq, ul_debug("init [%s]", method));
 
        memset(eq, 0, sizeof(*eq));
        eq->fd_api = -1;
@@ -195,7 +193,7 @@ void ul_fileeq_deinit(struct ul_fileeq *eq)
        if (!eq)
                return;
 
-       DBG(EQ, ul_debugobj(eq, "deinit"));
+       DBG_OBJ(EQ, eq, ul_debug("deinit"));
 #ifdef USE_FILEEQ_CRYPTOAPI
        deinit_crypto_api(eq);
 #endif
@@ -207,7 +205,7 @@ void ul_fileeq_data_close_file(struct ul_fileeq_data *data)
        assert(data);
 
        if (data->fd >= 0) {
-               DBG(DATA, ul_debugobj(data, "close"));
+               DBG_OBJ(DATA, data, ul_debug("close"));
                close(data->fd);
        }
        data->fd = -1;
@@ -215,7 +213,7 @@ void ul_fileeq_data_close_file(struct ul_fileeq_data *data)
 
 void ul_fileeq_data_init(struct ul_fileeq_data *data)
 {
-       DBG(DATA, ul_debugobj(data, "init"));
+       DBG_OBJ(DATA, data, ul_debug("init"));
        memset(data, 0, sizeof(*data));
        data->fd = -1;
 }
@@ -224,7 +222,7 @@ void ul_fileeq_data_deinit(struct ul_fileeq_data *data)
 {
        assert(data);
 
-       DBG(DATA, ul_debugobj(data, "deinit"));
+       DBG_OBJ(DATA, data, ul_debug("deinit"));
        free(data->blocks);
        data->blocks = NULL;
        data->nblocks = 0;
@@ -245,7 +243,7 @@ void ul_fileeq_data_set_file(struct ul_fileeq_data *data, const char *name)
        assert(data);
        assert(name);
 
-       DBG(DATA, ul_debugobj(data, "set file: %s", name));
+       DBG_OBJ(DATA, data, ul_debug("set file: %s", name));
        ul_fileeq_data_init(data);
        data->name = name;
 }
@@ -298,7 +296,7 @@ bool ul_fileeq_set_size(struct ul_fileeq *eq, int64_t st_size,
        eq->readsiz = readsiz;
        eq->blocksmax = (filesiz + readsiz - 1) / readsiz;
 
-       DBG(EQ, ul_debugobj(eq, "set sizes: filesiz=%" PRIu64 ", blocksmax=%" PRIu64 ", readsiz=%zu",
+       DBG_OBJ(EQ, eq, ul_debug("set sizes: filesiz=%" PRIu64 ", blocksmax=%" PRIu64 ", readsiz=%zu",
                                eq->filesiz, eq->blocksmax, eq->readsiz));
 
        reset_fileeq_bufs(eq);
@@ -342,7 +340,7 @@ static int get_fd(struct ul_fileeq *eq, struct ul_fileeq_data *data, off_t *off)
 
 
        if (data->fd < 0) {
-               DBG(DATA, ul_debugobj(data, "open: %s", data->name));
+               DBG_OBJ(DATA, data, ul_debug("open: %s", data->name));
                data->fd = open(data->name, O_RDONLY);
                if (data->fd < 0)
                        return data->fd;
@@ -351,7 +349,7 @@ static int get_fd(struct ul_fileeq *eq, struct ul_fileeq_data *data, off_t *off)
                ignore_result( posix_fadvise(data->fd, o, 0, POSIX_FADV_SEQUENTIAL) );
 #endif
                if (o) {
-                       DBG(DATA, ul_debugobj(data, "lseek off=%ju", (uintmax_t) o));
+                       DBG_OBJ(DATA, data, ul_debug("lseek off=%ju", (uintmax_t) o));
                        lseek(data->fd, o, SEEK_SET);
                }
        }
@@ -390,7 +388,7 @@ static ssize_t read_block(struct ul_fileeq *eq, struct ul_fileeq_data *data,
        if (fd < 0)
                return fd;
 
-       DBG(DATA, ul_debugobj(data, " read block off=%ju", (uintmax_t) off));
+       DBG_OBJ(DATA, data, ul_debug(" read block off=%ju", (uintmax_t) off));
 
        *block = get_buffer(eq);
        if (!*block)
@@ -398,7 +396,7 @@ static ssize_t read_block(struct ul_fileeq *eq, struct ul_fileeq_data *data,
 
        rsz = read_all(data->fd, (char *) *block, eq->readsiz);
        if (rsz < 0) {
-               DBG(DATA, ul_debugobj(data, "  read failed"));
+               DBG_OBJ(DATA, data, ul_debug("  read failed"));
                return rsz;
        }
        off += rsz;
@@ -409,7 +407,7 @@ static ssize_t read_block(struct ul_fileeq *eq, struct ul_fileeq_data *data,
                ul_fileeq_data_close_file(data);
        }
 
-       DBG(DATA, ul_debugobj(data, "  read sz=%zd", rsz));
+       DBG_OBJ(DATA, data, ul_debug("  read sz=%zd", rsz));
        return rsz;
 }
 
@@ -424,14 +422,14 @@ static ssize_t get_digest(struct ul_fileeq *eq, struct ul_fileeq_data *data,
 
        /* return already cached if available */
        if (n < get_cached_nblocks(data)) {
-               DBG(DATA, ul_debugobj(data, " digest cached"));
+               DBG_OBJ(DATA, data, ul_debug(" digest cached"));
                assert(data->blocks);
                *block = data->blocks + (n * eq->method->digsiz);
                return eq->method->digsiz;
        }
 
        if (data->is_eof) {
-               DBG(DATA, ul_debugobj(data, " file EOF"));
+               DBG_OBJ(DATA, data, ul_debug(" file EOF"));
                return 0;
        }
 
@@ -443,19 +441,19 @@ static ssize_t get_digest(struct ul_fileeq *eq, struct ul_fileeq_data *data,
        if (fd < 0)
                return fd;
 
-       DBG(DATA, ul_debugobj(data, " read digest off=%ju", (uintmax_t) off));
+       DBG_OBJ(DATA, data, ul_debug(" read digest off=%ju", (uintmax_t) off));
 
        sz = eq->method->digsiz;
 
        if (!data->blocks) {
-               DBG(DATA, ul_debugobj(data, "  alloc cache %" PRIu64, eq->blocksmax * sz));
+               DBG_OBJ(DATA, data, ul_debug("  alloc cache %" PRIu64, eq->blocksmax * sz));
                data->blocks = malloc(eq->blocksmax * sz);
                if (!data->blocks)
                        return -ENOMEM;
        }
 
        rsz = sendfile(eq->fd_cip, data->fd, NULL, eq->readsiz);
-       DBG(DATA, ul_debugobj(data, "  sent %zd [%zu wanted] to cipher", rsz, eq->readsiz));
+       DBG_OBJ(DATA, data, ul_debug("  sent %zd [%zu wanted] to cipher", rsz, eq->readsiz));
 
        if (rsz < 0)
                return rsz;
@@ -472,7 +470,7 @@ static ssize_t get_digest(struct ul_fileeq *eq, struct ul_fileeq_data *data,
                data->is_eof = 1;
                ul_fileeq_data_close_file(data);
        }
-       DBG(DATA, ul_debugobj(data, "  get %zdB digest", rsz));
+       DBG_OBJ(DATA, data, ul_debug("  get %zdB digest", rsz));
        return rsz;
 }
 #endif
@@ -487,13 +485,13 @@ static ssize_t get_intro(struct ul_fileeq *eq, struct ul_fileeq_data *data,
                if (fd < 0)
                        return -1;
                rsz = read_all(fd, (char *) data->intro, sizeof(data->intro));
-               DBG(DATA, ul_debugobj(data, " read %zd bytes [%zu wanted] intro", rsz, sizeof(data->intro)));
+               DBG_OBJ(DATA, data, ul_debug(" read %zd bytes [%zu wanted] intro", rsz, sizeof(data->intro)));
                if (rsz < 0)
                        return -1;
                data->nblocks = 1;
        }
 
-       DBG(DATA, ul_debugobj(data, " return intro"));
+       DBG_OBJ(DATA, data, ul_debug(" return intro"));
        *block = data->intro;
        return sizeof(data->intro);
 }
@@ -527,7 +525,7 @@ int ul_fileeq(struct ul_fileeq *eq,
        int cmp;
        uint64_t n = 0;
 
-       DBG(EQ, ul_debugobj(eq, "--> compare %s %s", a->name, b->name));
+       DBG_OBJ(EQ, eq, ul_debug("--> compare %s %s", a->name, b->name));
 
        if (eq->method->id == UL_FILEEQ_MEMCMP) {
                memcmp_reset(eq, a);
@@ -538,7 +536,7 @@ int ul_fileeq(struct ul_fileeq *eq,
                unsigned char *da, *db;
                ssize_t ca, cb;
 
-               DBG(EQ, ul_debugobj(eq, "compare block #%" PRIu64, n));
+               DBG_OBJ(EQ, eq, ul_debug("compare block #%" PRIu64, n));
 
                ca = get_cmp_data(eq, a, n, &da);
                if (ca < 0)
@@ -552,7 +550,7 @@ int ul_fileeq(struct ul_fileeq *eq,
 
                }
                cmp = memcmp(da, db, ca);
-               DBG(EQ, ul_debugobj(eq, "#%" PRIu64 "=%s", n, cmp == 0 ? "match" : "not-match"));
+               DBG_OBJ(EQ, eq, ul_debug("#%" PRIu64 "=%s", n, cmp == 0 ? "match" : "not-match"));
                n++;
        } while (cmp == 0);
 
@@ -560,11 +558,11 @@ int ul_fileeq(struct ul_fileeq *eq,
                if (!a->is_eof || !b->is_eof)
                        goto done; /* filesize changed? */
 
-               DBG(EQ, ul_debugobj(eq, "<-- MATCH"));
+               DBG_OBJ(EQ, eq, ul_debug("<-- MATCH"));
                return 1;
        }
 done:
-       DBG(EQ, ul_debugobj(eq, " <-- NOT-MATCH"));
+       DBG_OBJ(EQ, eq, ul_debug(" <-- NOT-MATCH"));
        return 0;
 }
 
index 6b27e451f83719b60102b6bd3cfcdb540b808a82..baa736890aa8ceaee83c12a24fec59d762ad6c66 100644 (file)
@@ -56,11 +56,9 @@ UL_DEBUG_DEFINE_MASKNAMES(loopdev) = UL_DEBUG_EMPTY_MASKNAMES;
 #define LOOPDEV_DEBUG_ITER     (1 << 3)
 #define LOOPDEV_DEBUG_SETUP    (1 << 4)
 
-#define DBG(m, x)       __UL_DBG(loopdev, LOOPDEV_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(loopdev, LOOPDEV_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(loopdev)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(loopdev, LOOPDEV_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(loopdev, LOOPDEV_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(loopdev, LOOPDEV_DEBUG_, m, x)
 
 static void loopdev_init_debug(void)
 {
@@ -113,7 +111,7 @@ int loopcxt_set_device(struct loopdev_cxt *lc, const char *device)
 
        if (lc->fd >= 0) {
                close(lc->fd);
-               DBG(CXT, ul_debugobj(lc, "closing old open fd"));
+               DBG_OBJ(CXT, lc, ul_debug("closing old open fd"));
        }
        lc->fd = -1;
        lc->is_lost = 0;
@@ -142,7 +140,7 @@ int loopcxt_set_device(struct loopdev_cxt *lc, const char *device)
                } else
                        xstrncpy(lc->device, device, sizeof(lc->device));
 
-               DBG(CXT, ul_debugobj(lc, "%s name assigned", device));
+               DBG_OBJ(CXT, lc, ul_debug("%s name assigned", device));
        }
 
        ul_unref_path(lc->sysfs);
@@ -201,7 +199,7 @@ int loopcxt_init(struct loopdev_cxt *lc, int flags)
                return -EINVAL;
 
        loopdev_init_debug();
-       DBG(CXT, ul_debugobj(lc, "initialize context"));
+       DBG_OBJ(CXT, lc, ul_debug("initialize context"));
 
        memcpy(lc, &dummy, sizeof(dummy));
        lc->flags = flags;
@@ -213,7 +211,7 @@ int loopcxt_init(struct loopdev_cxt *lc, int flags)
        if (stat(_PATH_SYS_BLOCK, &st) || !S_ISDIR(st.st_mode)) {
                lc->flags |= LOOPDEV_FL_NOSYSFS;
                lc->flags &= ~LOOPDEV_FL_NOIOCTL;
-               DBG(CXT, ul_debugobj(lc, "init: disable /sys usage"));
+               DBG_OBJ(CXT, lc, ul_debug("init: disable /sys usage"));
        }
 
        if (!(lc->flags & LOOPDEV_FL_NOSYSFS) &&
@@ -222,12 +220,12 @@ int loopcxt_init(struct loopdev_cxt *lc, int flags)
                 * Use only sysfs for basic information about loop devices
                 */
                lc->flags |= LOOPDEV_FL_NOIOCTL;
-               DBG(CXT, ul_debugobj(lc, "init: ignore ioctls"));
+               DBG_OBJ(CXT, lc, ul_debug("init: ignore ioctls"));
        }
 
        if (!(lc->flags & LOOPDEV_FL_CONTROL) && !stat(_PATH_DEV_LOOPCTL, &st)) {
                lc->flags |= LOOPDEV_FL_CONTROL;
-               DBG(CXT, ul_debugobj(lc, "init: loop-control detected "));
+               DBG_OBJ(CXT, lc, ul_debug("init: loop-control detected "));
        }
 
        return 0;
@@ -245,7 +243,7 @@ void loopcxt_deinit(struct loopdev_cxt *lc)
        if (!lc)
                return;
 
-       DBG(CXT, ul_debugobj(lc, "de-initialize"));
+       DBG_OBJ(CXT, lc, ul_debug("de-initialize"));
 
        free(lc->filename);
        lc->filename = NULL;
@@ -291,13 +289,13 @@ static struct path_cxt *loopcxt_get_sysfs(struct loopdev_cxt *lc)
        if (!lc->sysfs) {
                dev_t devno = loopcxt_get_devno(lc);
                if (!devno) {
-                       DBG(CXT, ul_debugobj(lc, "sysfs: failed devname to devno"));
+                       DBG_OBJ(CXT, lc, ul_debug("sysfs: failed devname to devno"));
                        return NULL;
                }
 
                lc->sysfs = ul_new_sysfs_path(devno, NULL, NULL);
                if (!lc->sysfs)
-                       DBG(CXT, ul_debugobj(lc, "sysfs: init failed"));
+                       DBG_OBJ(CXT, lc, ul_debug("sysfs: init failed"));
        }
 
        return lc->sysfs;
@@ -316,7 +314,7 @@ static int __loopcxt_get_fd(struct loopdev_cxt *lc, mode_t mode)
         * (O_RDONLY is a widely usable default.)
         */
        if (lc->fd >= 0 && mode == O_RDWR && lc->mode == O_RDONLY) {
-               DBG(CXT, ul_debugobj(lc, "closing already open device (mode mismatch)"));
+               DBG_OBJ(CXT, lc, ul_debug("closing already open device (mode mismatch)"));
                old = lc->fd;
                lc->fd = -1;
        }
@@ -324,7 +322,7 @@ static int __loopcxt_get_fd(struct loopdev_cxt *lc, mode_t mode)
        if (lc->fd < 0) {
                lc->mode = mode;
                lc->fd = open(lc->device, lc->mode | O_CLOEXEC);
-               DBG(CXT, ul_debugobj(lc, "open %s [%s]: %m", lc->device,
+               DBG_OBJ(CXT, lc, ul_debug("open %s [%s]: %m", lc->device,
                                mode == O_RDONLY ? "ro" :
                                mode == O_RDWR ? "rw" : "??"));
 
@@ -364,7 +362,7 @@ int loopcxt_init_iterator(struct loopdev_cxt *lc, int flags)
 
 
        iter = &lc->iter;
-       DBG(ITER, ul_debugobj(iter, "initialize"));
+       DBG_OBJ(ITER, iter, ul_debug("initialize"));
 
        /* always zeroize
         */
@@ -399,7 +397,7 @@ int loopcxt_deinit_iterator(struct loopdev_cxt *lc)
                return -EINVAL;
 
        iter = &lc->iter;
-       DBG(ITER, ul_debugobj(iter, "de-initialize"));
+       DBG_OBJ(ITER, iter, ul_debug("de-initialize"));
 
        free(iter->minors);
        if (iter->proc)
@@ -438,7 +436,7 @@ static int loopiter_set_device(struct loopdev_cxt *lc, const char *device)
        if ((lc->iter.flags & LOOPITER_FL_FREE) && !used)
                return 0;
 
-       DBG(ITER, ul_debugobj(&lc->iter, "failed to use %s device", lc->device));
+       DBG_OBJ(ITER, &lc->iter, ul_debug("failed to use %s device", lc->device));
 
        ignore_result( loopcxt_set_device(lc, NULL) );
        return 1;
@@ -531,7 +529,7 @@ static int loopcxt_next_from_proc(struct loopdev_cxt *lc)
        struct loopdev_iter *iter = &lc->iter;
        char buf[BUFSIZ];
 
-       DBG(ITER, ul_debugobj(iter, "scan /proc/partitions"));
+       DBG_OBJ(ITER, iter, ul_debug("scan /proc/partitions"));
 
        if (!iter->proc)
                iter->proc = fopen(_PATH_PROC_PARTITIONS, "r" UL_CLOEXECSTR);
@@ -547,7 +545,7 @@ static int loopcxt_next_from_proc(struct loopdev_cxt *lc)
                           &m, name) != 2 || m != LOOPDEV_MAJOR)
                        continue;
 
-               DBG(ITER, ul_debugobj(iter, "checking %s", name));
+               DBG_OBJ(ITER, iter, ul_debug("checking %s", name));
 
                if (loopiter_set_device(lc, name) == 0)
                        return 0;
@@ -568,7 +566,7 @@ static int loopcxt_next_from_sysfs(struct loopdev_cxt *lc)
        struct dirent *d;
        int fd;
 
-       DBG(ITER, ul_debugobj(iter, "scanning /sys/block"));
+       DBG_OBJ(ITER, iter, ul_debug("scanning /sys/block"));
 
        if (!iter->sysblock)
                iter->sysblock = opendir(_PATH_SYS_BLOCK);
@@ -582,7 +580,7 @@ static int loopcxt_next_from_sysfs(struct loopdev_cxt *lc)
                char name[NAME_MAX + 18 + 1];
                struct stat st;
 
-               DBG(ITER, ul_debugobj(iter, "check %s", d->d_name));
+               DBG_OBJ(ITER, iter, ul_debug("check %s", d->d_name));
 
                if (is_dotdir_dirent(d) || strncmp(d->d_name, "loop", 4) != 0)
                        continue;
@@ -617,7 +615,7 @@ int loopcxt_next(struct loopdev_cxt *lc)
        if (iter->done)
                return 1;
 
-       DBG(ITER, ul_debugobj(iter, "next"));
+       DBG_OBJ(ITER, iter, ul_debug("next"));
 
        /* A) Look for used loop devices in /proc/partitions ("losetup -a" only)
         */
@@ -637,7 +635,7 @@ int loopcxt_next(struct loopdev_cxt *lc)
         *    of loop devices). This is enough for 99% of all cases.
         */
        if (iter->default_check) {
-               DBG(ITER, ul_debugobj(iter, "next: default check"));
+               DBG_OBJ(ITER, iter, ul_debug("next: default check"));
                for (++iter->ncur; iter->ncur < LOOPDEV_DEFAULT_NNODES;
                                                        iter->ncur++) {
                        char name[16];
@@ -652,7 +650,7 @@ int loopcxt_next(struct loopdev_cxt *lc)
        /* C) the worst possibility, scan whole /dev or /dev/loop/<N>
         */
        if (!iter->minors) {
-               DBG(ITER, ul_debugobj(iter, "next: scanning /dev"));
+               DBG_OBJ(ITER, iter, ul_debug("next: scanning /dev"));
                iter->nminors = (lc->flags & LOOPDEV_FL_DEVSUBDIR) ?
                        loop_scandir(_PATH_DEV_LOOP, &iter->minors, 0) :
                        loop_scandir(_PATH_DEV, &iter->minors, 1);
@@ -726,12 +724,12 @@ struct loop_info64 *loopcxt_get_info(struct loopdev_cxt *lc)
        if (ioctl(fd, LOOP_GET_STATUS64, &lc->config.info) == 0) {
                lc->has_info = 1;
                lc->info_failed = 0;
-               DBG(CXT, ul_debugobj(lc, "reading loop_info64 OK"));
+               DBG_OBJ(CXT, lc, ul_debug("reading loop_info64 OK"));
                return &lc->config.info;
        }
 
        lc->info_failed = 1;
-       DBG(CXT, ul_debugobj(lc, "reading loop_info64 FAILED"));
+       DBG_OBJ(CXT, lc, ul_debug("reading loop_info64 FAILED"));
 
        return NULL;
 }
@@ -764,7 +762,7 @@ char *loopcxt_get_backing_file(struct loopdev_cxt *lc)
                }
        }
 
-       DBG(CXT, ul_debugobj(lc, "get_backing_file [%s]", res));
+       DBG_OBJ(CXT, lc, ul_debug("get_backing_file [%s]", res));
        return res;
 }
 
@@ -784,7 +782,7 @@ char *loopcxt_get_refname(struct loopdev_cxt *lc)
                res = strdup((char *) lo->lo_file_name);
        }
 
-       DBG(CXT, ul_debugobj(lc, "get_refname [%s]", res));
+       DBG_OBJ(CXT, lc, ul_debug("get_refname [%s]", res));
        return res;
 }
 
@@ -813,7 +811,7 @@ int loopcxt_get_offset(struct loopdev_cxt *lc, uint64_t *offset)
                        rc = -errno;
        }
 
-       DBG(CXT, ul_debugobj(lc, "get_offset [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("get_offset [rc=%d]", rc));
        return rc;
 }
 
@@ -846,7 +844,7 @@ int loopcxt_get_blocksize(struct loopdev_cxt *lc, uint64_t *blocksize)
                *blocksize = sz;
        }
 
-       DBG(CXT, ul_debugobj(lc, "get_blocksize [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("get_blocksize [rc=%d]", rc));
        return rc;
 }
 
@@ -875,7 +873,7 @@ int loopcxt_get_sizelimit(struct loopdev_cxt *lc, uint64_t *size)
                        rc = -errno;
        }
 
-       DBG(CXT, ul_debugobj(lc, "get_sizelimit [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("get_sizelimit [rc=%d]", rc));
        return rc;
 }
 
@@ -900,7 +898,7 @@ int loopcxt_get_encrypt_type(struct loopdev_cxt *lc, uint32_t *type)
        } else
                rc = -errno;
 
-       DBG(CXT, ul_debugobj(lc, "get_encrypt_type [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("get_encrypt_type [rc=%d]", rc));
        return rc;
 }
 
@@ -918,7 +916,7 @@ const char *loopcxt_get_crypt_name(struct loopdev_cxt *lc)
        if (lo)
                return (char *) lo->lo_crypt_name;
 
-       DBG(CXT, ul_debugobj(lc, "get_crypt_name failed"));
+       DBG_OBJ(CXT, lc, ul_debug("get_crypt_name failed"));
        return NULL;
 }
 
@@ -940,7 +938,7 @@ int loopcxt_get_backing_devno(struct loopdev_cxt *lc, dev_t *devno)
        } else
                rc = -errno;
 
-       DBG(CXT, ul_debugobj(lc, "get_backing_devno [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("get_backing_devno [rc=%d]", rc));
        return rc;
 }
 
@@ -962,7 +960,7 @@ int loopcxt_get_backing_inode(struct loopdev_cxt *lc, ino_t *ino)
        } else
                rc = -errno;
 
-       DBG(CXT, ul_debugobj(lc, "get_backing_inode [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("get_backing_inode [rc=%d]", rc));
        return rc;
 }
 
@@ -1119,7 +1117,7 @@ int loopcxt_is_used(struct loopdev_cxt *lc,
        if (!lc)
                return 0;
 
-       DBG(CXT, ul_debugobj(lc, "checking %s vs. %s",
+       DBG_OBJ(CXT, lc, ul_debug("checking %s vs. %s",
                                loopcxt_get_device(lc),
                                backing_file));
 
@@ -1169,7 +1167,7 @@ int loopcxt_set_offset(struct loopdev_cxt *lc, uint64_t offset)
                return -EINVAL;
        lc->config.info.lo_offset = offset;
 
-       DBG(CXT, ul_debugobj(lc, "set offset=%jd", offset));
+       DBG_OBJ(CXT, lc, ul_debug("set offset=%jd", offset));
        return 0;
 }
 
@@ -1182,7 +1180,7 @@ int loopcxt_set_sizelimit(struct loopdev_cxt *lc, uint64_t sizelimit)
                return -EINVAL;
        lc->config.info.lo_sizelimit = sizelimit;
 
-       DBG(CXT, ul_debugobj(lc, "set sizelimit=%jd", sizelimit));
+       DBG_OBJ(CXT, lc, ul_debug("set sizelimit=%jd", sizelimit));
        return 0;
 }
 
@@ -1198,7 +1196,7 @@ int loopcxt_set_blocksize(struct loopdev_cxt *lc, uint64_t blocksize)
                return -EINVAL;
        lc->blocksize = blocksize;
 
-       DBG(CXT, ul_debugobj(lc, "set blocksize=%jd", blocksize));
+       DBG_OBJ(CXT, lc, ul_debug("set blocksize=%jd", blocksize));
        return 0;
 }
 
@@ -1216,7 +1214,7 @@ int loopcxt_set_flags(struct loopdev_cxt *lc, uint32_t flags)
                return -EINVAL;
        lc->config.info.lo_flags = flags;
 
-       DBG(CXT, ul_debugobj(lc, "set flags=%u", (unsigned) flags));
+       DBG_OBJ(CXT, lc, ul_debug("set flags=%u", (unsigned) flags));
        return 0;
 }
 
@@ -1238,7 +1236,7 @@ int loopcxt_set_refname(struct loopdev_cxt *lc, const char *refname)
        if (refname)
                xstrncpy((char *)lc->config.info.lo_file_name, refname, LO_NAME_SIZE);
 
-       DBG(CXT, ul_debugobj(lc, "set refname=%s", (char *)lc->config.info.lo_file_name));
+       DBG_OBJ(CXT, lc, ul_debug("set refname=%s", (char *)lc->config.info.lo_file_name));
        return 0;
 }
 
@@ -1262,7 +1260,7 @@ int loopcxt_set_backing_file(struct loopdev_cxt *lc, const char *filename)
        if (!lc->config.info.lo_file_name[0])
                loopcxt_set_refname(lc, lc->filename);
 
-       DBG(CXT, ul_debugobj(lc, "set backing file=%s", lc->filename));
+       DBG_OBJ(CXT, lc, ul_debug("set backing file=%s", lc->filename));
        return 0;
 }
 
@@ -1289,20 +1287,20 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd)
                return 0;
 
        if (fstat(file_fd, &st)) {
-               DBG(CXT, ul_debugobj(lc, "failed to fstat backing file"));
+               DBG_OBJ(CXT, lc, ul_debug("failed to fstat backing file"));
                return -errno;
        }
        if (S_ISBLK(st.st_mode)) {
                if (blkdev_get_size(file_fd,
                                (unsigned long long *) &expected_size)) {
-                       DBG(CXT, ul_debugobj(lc, "failed to determine device size"));
+                       DBG_OBJ(CXT, lc, ul_debug("failed to determine device size"));
                        return -errno;
                }
        } else
                expected_size = st.st_size;
 
        if (expected_size == 0 || expected_size <= lc->config.info.lo_offset) {
-               DBG(CXT, ul_debugobj(lc, "failed to determine expected size"));
+               DBG_OBJ(CXT, lc, ul_debug("failed to determine expected size"));
                return 0;       /* ignore this error */
        }
 
@@ -1314,23 +1312,23 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd)
 
        dev_fd = loopcxt_get_fd(lc);
        if (dev_fd < 0) {
-               DBG(CXT, ul_debugobj(lc, "failed to get loop FD"));
+               DBG_OBJ(CXT, lc, ul_debug("failed to get loop FD"));
                return -errno;
        }
 
        if (blkdev_get_size(dev_fd, (unsigned long long *) &size)) {
-               DBG(CXT, ul_debugobj(lc, "failed to determine loopdev size"));
+               DBG_OBJ(CXT, lc, ul_debug("failed to determine loopdev size"));
                return -errno;
        }
 
        /* It's block device, so, align to 512-byte sectors */
        if (expected_size % 512) {
-               DBG(CXT, ul_debugobj(lc, "expected size misaligned to 512-byte sectors"));
+               DBG_OBJ(CXT, lc, ul_debug("expected size misaligned to 512-byte sectors"));
                expected_size = (expected_size >> 9) << 9;
        }
 
        if (expected_size != size) {
-               DBG(CXT, ul_debugobj(lc, "warning: loopdev and expected "
+               DBG_OBJ(CXT, lc, ul_debug("warning: loopdev and expected "
                                      "size mismatch (%ju/%ju)",
                                      size, expected_size));
 
@@ -1346,7 +1344,7 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd)
 
                if (expected_size != size) {
                        errno = ERANGE;
-                       DBG(CXT, ul_debugobj(lc, "failed to set loopdev size, "
+                       DBG_OBJ(CXT, lc, ul_debug("failed to set loopdev size, "
                                        "size: %ju, expected: %ju",
                                        size, expected_size));
                        return -errno;
@@ -1386,7 +1384,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
        if (!lc || !*lc->device || !lc->filename)
                return -EINVAL;
 
-       DBG(SETUP, ul_debugobj(lc, "device setup requested"));
+       DBG_OBJ(SETUP, lc, ul_debug("device setup requested"));
 
        /*
         * Open backing file and device
@@ -1402,11 +1400,11 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
                        file_fd = open(lc->filename, (mode = O_RDONLY) | flags);
 
                if (file_fd < 0) {
-                       DBG(SETUP, ul_debugobj(lc, "open backing file failed: %m"));
+                       DBG_OBJ(SETUP, lc, ul_debug("open backing file failed: %m"));
                        return -errno;
                }
        }
-       DBG(SETUP, ul_debugobj(lc, "backing file open: OK"));
+       DBG_OBJ(SETUP, lc, ul_debug("backing file open: OK"));
 
        if (mode == O_RDONLY)
                lc->config.info.lo_flags |= LO_FLAGS_READ_ONLY; /* kernel loopdev mode */
@@ -1432,7 +1430,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
                goto err;
        }
 
-       DBG(SETUP, ul_debugobj(lc, "device open: OK"));
+       DBG_OBJ(SETUP, lc, ul_debug("device open: OK"));
 
        /*
         * Atomic way to configure all by one ioctl call
@@ -1446,12 +1444,12 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
        if (rc != 0) {
                errsv = errno;
                if (errno != EINVAL && errno != ENOTTY && errno != ENOSYS) {
-                       DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
+                       DBG_OBJ(SETUP, lc, ul_debug("LOOP_CONFIGURE failed: %m"));
                        goto err;
                }
                fallback = 1;
        } else {
-               DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE: OK"));
+               DBG_OBJ(SETUP, lc, ul_debug("LOOP_CONFIGURE: OK"));
        }
 
        /*
@@ -1462,11 +1460,11 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
                if (ioctl(dev_fd, LOOP_SET_FD, file_fd) < 0) {
                        rc = -errno;
                        errsv = errno;
-                       DBG(SETUP, ul_debugobj(lc, "LOOP_SET_FD failed: %m"));
+                       DBG_OBJ(SETUP, lc, ul_debug("LOOP_SET_FD failed: %m"));
                        goto err;
                }
 
-               DBG(SETUP, ul_debugobj(lc, "LOOP_SET_FD: OK"));
+               DBG_OBJ(SETUP, lc, ul_debug("LOOP_SET_FD: OK"));
 
                if (lc->blocksize > 0
                        && (rc = loopcxt_ioctl_blocksize(lc, lc->blocksize)) < 0) {
@@ -1489,7 +1487,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
        lc->has_info = 0;
        lc->info_failed = 0;
 
-       DBG(SETUP, ul_debugobj(lc, "success [rc=0]"));
+       DBG_OBJ(SETUP, lc, ul_debug("success [rc=0]"));
        return 0;
 err:
        if (file_fd >= 0)
@@ -1499,7 +1497,7 @@ err:
        if (errsv)
                errno = errsv;
 
-       DBG(SETUP, ul_debugobj(lc, "failed [rc=%d]", rc));
+       DBG_OBJ(SETUP, lc, ul_debug("failed [rc=%d]", rc));
        return rc;
 }
 
@@ -1525,15 +1523,15 @@ int loopcxt_ioctl_status(struct loopdev_cxt *lc)
        if (dev_fd < 0)
                return -errno;
 
-       DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_STATUS64"));
+       DBG_OBJ(SETUP, lc, ul_debug("calling LOOP_SET_STATUS64"));
 
        rc = repeat_on_eagain( ioctl(dev_fd, LOOP_SET_STATUS64, &lc->config.info) );
        if (rc != 0) {
-               DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m"));
+               DBG_OBJ(SETUP, lc, ul_debug("LOOP_SET_STATUS64 failed: %m"));
                return rc;
        }
 
-       DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64: OK"));
+       DBG_OBJ(SETUP, lc, ul_debug("LOOP_SET_STATUS64: OK"));
        return 0;
 }
 
@@ -1544,16 +1542,16 @@ int loopcxt_ioctl_capacity(struct loopdev_cxt *lc)
        if (fd < 0)
                return -EINVAL;
 
-       DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_CAPACITY"));
+       DBG_OBJ(SETUP, lc, ul_debug("calling LOOP_SET_CAPACITY"));
 
        /* Kernels prior to v2.6.30 don't support this ioctl */
        rc = repeat_on_eagain( ioctl(fd, LOOP_SET_CAPACITY, 0) );
        if (rc != 0) {
-               DBG(CXT, ul_debugobj(lc, "LOOP_SET_CAPACITY failed: %m"));
+               DBG_OBJ(CXT, lc, ul_debug("LOOP_SET_CAPACITY failed: %m"));
                return rc;
        }
 
-       DBG(CXT, ul_debugobj(lc, "capacity set"));
+       DBG_OBJ(CXT, lc, ul_debug("capacity set"));
        return 0;
 }
 
@@ -1564,16 +1562,16 @@ int loopcxt_ioctl_dio(struct loopdev_cxt *lc, unsigned long use_dio)
        if (fd < 0)
                return -EINVAL;
 
-       DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_DIRECT_IO"));
+       DBG_OBJ(SETUP, lc, ul_debug("calling LOOP_SET_DIRECT_IO"));
 
        /* Kernels prior to v4.4 don't support this ioctl */
        rc = repeat_on_eagain( ioctl(fd, LOOP_SET_DIRECT_IO, use_dio) );
        if (rc != 0) {
-               DBG(CXT, ul_debugobj(lc, "LOOP_SET_DIRECT_IO failed: %m"));
+               DBG_OBJ(CXT, lc, ul_debug("LOOP_SET_DIRECT_IO failed: %m"));
                return rc;
        }
 
-       DBG(CXT, ul_debugobj(lc, "direct io set"));
+       DBG_OBJ(CXT, lc, ul_debug("direct io set"));
        return 0;
 }
 
@@ -1588,16 +1586,16 @@ int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize)
        if (fd < 0)
                return -EINVAL;
 
-       DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_BLOCK_SIZE"));
+       DBG_OBJ(SETUP, lc, ul_debug("calling LOOP_SET_BLOCK_SIZE"));
 
        rc = repeat_on_eagain(
                ioctl(fd, LOOP_SET_BLOCK_SIZE, (unsigned long) blocksize) );
        if (rc != 0) {
-               DBG(CXT, ul_debugobj(lc, "LOOP_SET_BLOCK_SIZE failed: %m"));
+               DBG_OBJ(CXT, lc, ul_debug("LOOP_SET_BLOCK_SIZE failed: %m"));
                return rc;
        }
 
-       DBG(CXT, ul_debugobj(lc, "logical block size set"));
+       DBG_OBJ(CXT, lc, ul_debug("logical block size set"));
        return 0;
 }
 
@@ -1636,7 +1634,7 @@ static int loopcxt_get_device_nr(struct loopdev_cxt *lc, int *nr)
 done:
        if (rc && !errno)
                errno = -rc;
-       DBG(CXT, ul_debugobj(lc, "get_device_nr [nr=%d]", *nr));
+       DBG_OBJ(CXT, lc, ul_debug("get_device_nr [nr=%d]", *nr));
        return rc;
 }
 
@@ -1647,15 +1645,15 @@ int loopcxt_detach_device(struct loopdev_cxt *lc)
        if (fd < 0)
                return -EINVAL;
 
-       DBG(SETUP, ul_debugobj(lc, "calling LOOP_CLR_FD"));
+       DBG_OBJ(SETUP, lc, ul_debug("calling LOOP_CLR_FD"));
 
        rc = repeat_on_eagain( ioctl(fd, LOOP_CLR_FD, 0) );
        if (rc != 0) {
-               DBG(CXT, ul_debugobj(lc, "LOOP_CLR_FD failed: %m"));
+               DBG_OBJ(CXT, lc, ul_debug("LOOP_CLR_FD failed: %m"));
                return rc;
        }
 
-       DBG(CXT, ul_debugobj(lc, "device removed"));
+       DBG_OBJ(CXT, lc, ul_debug("device removed"));
        return 0;
 }
 
@@ -1675,13 +1673,13 @@ int loopcxt_remove_device(struct loopdev_cxt *lc)
 
        ctl = open(_PATH_DEV_LOOPCTL, O_RDWR|O_CLOEXEC);
        if (ctl >= 0) {
-               DBG(CXT, ul_debugobj(lc, "remove_device %d", nr));
+               DBG_OBJ(CXT, lc, ul_debug("remove_device %d", nr));
                rc = ioctl(ctl, LOOP_CTL_REMOVE, nr);
                close(ctl);
        }
        lc->control_ok = rc >= 0 ? 1 : 0;
 done:
-       DBG(CXT, ul_debugobj(lc, "remove_device done [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("remove_device done [rc=%d]", rc));
        return rc;
 }
 
@@ -1701,13 +1699,13 @@ int loopcxt_add_device(struct loopdev_cxt *lc)
 
        ctl = open(_PATH_DEV_LOOPCTL, O_RDWR|O_CLOEXEC);
        if (ctl >= 0) {
-               DBG(CXT, ul_debugobj(lc, "add_device %d", nr));
+               DBG_OBJ(CXT, lc, ul_debug("add_device %d", nr));
                rc = ioctl(ctl, LOOP_CTL_ADD, nr);
                close(ctl);
        }
        lc->control_ok = rc >= 0 ? 1 : 0;
 done:
-       DBG(CXT, ul_debugobj(lc, "add_device done [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("add_device done [rc=%d]", rc));
        return rc;
 }
 
@@ -1723,12 +1721,12 @@ int loopcxt_find_unused(struct loopdev_cxt *lc)
 {
        int rc = -1;
 
-       DBG(CXT, ul_debugobj(lc, "find_unused requested"));
+       DBG_OBJ(CXT, lc, ul_debug("find_unused requested"));
 
        if (lc->flags & LOOPDEV_FL_CONTROL) {
                int ctl;
 
-               DBG(CXT, ul_debugobj(lc, "using loop-control"));
+               DBG_OBJ(CXT, lc, ul_debug("using loop-control"));
 
                ctl = open(_PATH_DEV_LOOPCTL, O_RDWR|O_CLOEXEC);
                if (ctl >= 0)
@@ -1744,18 +1742,18 @@ int loopcxt_find_unused(struct loopdev_cxt *lc)
                lc->control_ok = ctl >= 0 && rc == 0 ? 1 : 0;
                if (ctl >= 0)
                        close(ctl);
-               DBG(CXT, ul_debugobj(lc, "find_unused by loop-control [rc=%d]", rc));
+               DBG_OBJ(CXT, lc, ul_debug("find_unused by loop-control [rc=%d]", rc));
        }
 
        if (rc < 0 && rc != -EACCES) {
-               DBG(CXT, ul_debugobj(lc, "using loop scan"));
+               DBG_OBJ(CXT, lc, ul_debug("using loop scan"));
                rc = loopcxt_init_iterator(lc, LOOPITER_FL_FREE);
                if (rc)
                        return rc;
 
                rc = loopcxt_next(lc);
                loopcxt_deinit_iterator(lc);
-               DBG(CXT, ul_debugobj(lc, "find_unused by scan [rc=%d]", rc));
+               DBG_OBJ(CXT, lc, ul_debug("find_unused by scan [rc=%d]", rc));
                if (rc)
                        return -ENOENT;
        }
@@ -1902,7 +1900,7 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename,
        if (!filename)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(lc, "find_overlap requested"));
+       DBG_OBJ(CXT, lc, ul_debug("find_overlap requested"));
        hasst = !stat(filename, &st);
 
        rc = loopcxt_init_iterator(lc, LOOPITER_FL_USED);
@@ -1922,25 +1920,25 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename,
                if (rc <= 0)
                        continue;
 
-               DBG(CXT, ul_debugobj(lc, "found %s backed by %s",
+               DBG_OBJ(CXT, lc, ul_debug("found %s backed by %s",
                        loopcxt_get_device(lc), filename));
 
                rc = loopcxt_get_offset(lc, &lc_offset);
                if (rc) {
-                       DBG(CXT, ul_debugobj(lc, "failed to get offset for device %s",
+                       DBG_OBJ(CXT, lc, ul_debug("failed to get offset for device %s",
                                loopcxt_get_device(lc)));
                        continue;
                }
                rc = loopcxt_get_sizelimit(lc, &lc_sizelimit);
                if (rc) {
-                       DBG(CXT, ul_debugobj(lc, "failed to get sizelimit for device %s",
+                       DBG_OBJ(CXT, lc, ul_debug("failed to get sizelimit for device %s",
                                loopcxt_get_device(lc)));
                        continue;
                }
 
                /* full match */
                if (lc_sizelimit == sizelimit && lc_offset == offset) {
-                       DBG(CXT, ul_debugobj(lc, "overlapping loop device %s (full match)",
+                       DBG_OBJ(CXT, lc, ul_debug("overlapping loop device %s (full match)",
                                                loopcxt_get_device(lc)));
                        rc = 2;
                        goto found;
@@ -1952,7 +1950,7 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename,
                if (sizelimit != 0 && offset + sizelimit <= lc_offset)
                        continue;
 
-               DBG(CXT, ul_debugobj(lc, "overlapping loop device %s",
+               DBG_OBJ(CXT, lc, ul_debug("overlapping loop device %s",
                        loopcxt_get_device(lc)));
                        rc = 1;
                        goto found;
@@ -1962,7 +1960,7 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename,
                rc = 0; /* not found */
 found:
        loopcxt_deinit_iterator(lc);
-       DBG(CXT, ul_debugobj(lc, "find_overlap done [rc=%d]", rc));
+       DBG_OBJ(CXT, lc, ul_debug("find_overlap done [rc=%d]", rc));
        return rc;
 }
 
index 3770b50b5684f10ec71897e1d0708bb807a70744..318544c43a27e002cba8c101f21d198cdc2bc113 100644 (file)
@@ -46,11 +46,9 @@ UL_DEBUG_DEFINE_MASKNAMES(netaddrq) =
        { NULL, 0 }
 };
 
-#define DBG(m, x)       __UL_DBG(netaddrq, ULNETADDRQ_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(netaddrq, ULNETADDRQ_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(netaddrq)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(netaddrq, ULNETADDRQ_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(netaddrq, ULNETADDRQ_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(netaddrq, ULNETADDRQ_DEBUG_, m, x)
 
 static void netaddrq_init_debug(void)
 {
@@ -117,14 +115,14 @@ static int callback_addrq(struct ul_nl_data *nl)
        int rc;
        bool *ifaces_change;
 
-       DBG(LIST, ul_debugobj(addrq, "callback_addrq() for %s on %s",
+       DBG_OBJ(LIST, addrq, ul_debug("callback_addrq() for %s on %s",
                              ul_nl_addr_ntop_address(&(nl->addr)),
                              nl->addr.ifname));
        if (addrq->callback_pre)
        {
-               DBG(LIST, ul_debugobj(addrq, "callback_pre"));
+               DBG_OBJ(LIST, addrq, ul_debug("callback_pre"));
                if ((rc = (*(addrq->callback_pre))(nl)))
-                       DBG(LIST, ul_debugobj(nl, "callback_pre rc != 0"));
+                       DBG_OBJ(LIST, nl, ul_debug("callback_pre rc != 0"));
        }
 
        /* Search for interface in ifaces */
@@ -136,7 +134,7 @@ static int callback_addrq(struct ul_nl_data *nl)
                ifaceqq = list_entry(li, struct ul_netaddrq_iface, entry);
                if (ifaceqq->ifa_index == nl->addr.ifa_index) {
                        ifaceq = ifaceqq;
-                       DBG(LIST, ul_debugobj(ifaceq,
+                       DBG_OBJ(LIST, ifaceq, ul_debug(
                                              "%s found in addrq",
                                              nl->addr.ifname));
                        break;
@@ -147,12 +145,12 @@ static int callback_addrq(struct ul_nl_data *nl)
        if (ifaceq == NULL) {
                if (nl->rtm_event) {
                        if (addrq->nifaces >= max_ifaces) {
-                               DBG(LIST, ul_debugobj(addrq,
+                               DBG_OBJ(LIST, addrq, ul_debug(
                                                       "too many interfaces"));
                                addrq->overflow = true;
                                return UL_NL_IFACES_MAX;
                        }
-                       DBG(LIST, ul_debugobj(addrq,
+                       DBG_OBJ(LIST, addrq, ul_debug(
                                               "new ifa_index in addrq"));
                        if (!(ifaceq = malloc(sizeof(struct ul_netaddrq_iface))))
                                return -ENOMEM;
@@ -161,17 +159,17 @@ static int callback_addrq(struct ul_nl_data *nl)
                        ifaceq->ifa_index = nl->addr.ifa_index;
                        if (!(ifaceq->ifname = strdup(nl->addr.ifname)))
                        {
-                               DBG(LIST, ul_debugobj(addrq,
+                               DBG_OBJ(LIST, addrq, ul_debug(
                                                      "malloc() failed"));
                                free(ifaceq);
                                return -ENOMEM;
                        }
                        list_add_tail(&(ifaceq->entry), &(addrq->ifaces));
-                       DBG(LIST, ul_debugobj(ifaceq,
+                       DBG_OBJ(LIST, ifaceq, ul_debug(
                                               "new interface"));
                } else {
                        /* Should never happen. */
-                       DBG(LIST, ul_debugobj(ifaceq,
+                       DBG_OBJ(LIST, ifaceq, ul_debug(
                                               "interface not found"));
                        return UL_NL_SOFT_ERROR;
                }
@@ -193,13 +191,13 @@ static int callback_addrq(struct ul_nl_data *nl)
                        if (!memcmp(ipqq->addr->address, nl->addr.address,
                                   nl->addr.address_len)) {
                                ipq = ipqq;
-                               DBG(LIST, ul_debugobj(ipq,
+                               DBG_OBJ(LIST, ipq, ul_debug(
                                                      "address found in ipq_list"));
                                break;
                        }
        }
        if (ipq == NULL) {
-                       DBG(LIST, ul_debugobj(ipq_list,
+                       DBG_OBJ(LIST, ipq_list, ul_debug(
                                              "address not found in the list"));
        }
 
@@ -222,16 +220,16 @@ static int callback_addrq(struct ul_nl_data *nl)
                        }
                        ipq->addr = addr;
                        list_add_tail(&(ipq->entry), ipq_list);
-                       DBG(LIST, ul_debugobj(ipq, "new address"));
+                       DBG_OBJ(LIST, ipq, ul_debug("new address"));
                        *ifaces_change = true;
                } else {
-                       DBG(LIST, ul_debugobj(addrq, "updating address data"));
+                       DBG_OBJ(LIST, addrq, ul_debug("updating address data"));
                        ul_nl_addr_free(ipq->addr);
                        ipq->addr = addr;
                }
                ipq->quality = evaluate_ip_quality(addr);
-               DBG(ADDRQ,
-                   ul_debugobj(addrq, "%s rating: %s",
+               DBG_OBJ(ADDRQ, addrq,
+                   ul_debug("%s rating: %s",
                                ul_nl_addr_ntop_address(&(nl->addr)),
                                ip_rating_as_string(ipq->quality)));
        } else {
@@ -239,12 +237,12 @@ static int callback_addrq(struct ul_nl_data *nl)
                if (ipq == NULL)
                {
                        /* Should not happen. */
-                       DBG(LIST, ul_debugobj(nl,
+                       DBG_OBJ(LIST, nl, ul_debug(
                                              "UL_NL_RTM_DEL: unknown address"));
                        return UL_NL_SOFT_ERROR;
                }
                /* Delist the address */
-               DBG(LIST, ul_debugobj(ipq, "removing address"));
+               DBG_OBJ(LIST, ipq, ul_debug("removing address"));
                *ifaces_change = true;
                list_del(&(ipq->entry));
                ul_nl_addr_free(ipq->addr);
@@ -252,9 +250,8 @@ static int callback_addrq(struct ul_nl_data *nl)
        error:
                if (list_empty(&(ifaceq->ip_quality_list_4)) &&
                    list_empty(&(ifaceq->ip_quality_list_6))) {
-               DBG(LIST,
-                   ul_debugobj(ifaceq,
-                               "deleted last address, removing interface"));
+               DBG_OBJ(LIST, ifaceq,
+                   ul_debug("deleted last address, removing interface"));
                        list_del(&(ifaceq->entry));
                        addrq->nifaces--;
                        free(ifaceq->ifname);
@@ -263,9 +260,9 @@ static int callback_addrq(struct ul_nl_data *nl)
        }
        if (!rc && addrq->callback_post)
        {
-               DBG(LIST, ul_debugobj(addrq, "callback_post"));
+               DBG_OBJ(LIST, addrq, ul_debug("callback_post"));
                if ((rc = (*(addrq->callback_post))(nl)))
-                       DBG(LIST, ul_debugobj(nl, "callback_post rc != 0"));
+                       DBG_OBJ(LIST, nl, ul_debug("callback_post rc != 0"));
        }
        return rc;
 }
@@ -285,7 +282,7 @@ int ul_netaddrq_init(struct ul_nl_data *nl, ul_nl_callback callback_pre,
        addrq->callback_post = callback_post;
        addrq->callback_data = data;
        INIT_LIST_HEAD(&(addrq->ifaces));
-       DBG(LIST, ul_debugobj(addrq, "callback initialized"));
+       DBG_OBJ(LIST, addrq, ul_debug("callback initialized"));
        return 0;
 }
 
@@ -306,8 +303,8 @@ ul_netaddrq_iface_bestaddr(struct list_head *ipq_list,
                    ipq->addr->ifa_valid >
                    (*best)[ipq->quality]->addr->ifa_valid)
                {
-                       DBG(BEST,
-                           ul_debugobj((*best), "%s -> best[%s]",
+                       DBG_OBJ(BEST, (*best),
+                           ul_debug("%s -> best[%s]",
                                        ul_nl_addr_ntop_address(ipq->addr),
                                        ip_rating_as_string(ipq->quality)));
                        (*best)[ipq->quality] = ipq;
@@ -356,8 +353,8 @@ ul_netaddrq_bestaddr(struct ul_nl_data *nl,
                t = ul_netaddrq_iface_bestaddr(ipq_list, best);
                if (t < threshold)
                {
-                       DBG(BEST,
-                           ul_debugobj(*best, "best iface %s, threshold %hhd",
+                       DBG_OBJ(BEST, *best,
+                           ul_debug("best iface %s, threshold %hhd",
                                        ifaceq->ifname, t));
                        *best_ifaceq = ifaceq;
                        threshold = t;
index 28eb185d51151d840d21ed70a49cb8fc8780cab1..a65852c19774f2c62de08002787aeaf81c05f37d 100644 (file)
@@ -42,11 +42,9 @@ UL_DEBUG_DEFINE_MASKNAMES(netlink) =
        { NULL, 0 }
 };
 
-#define DBG(m, x)       __UL_DBG(netlink, ULNETLINK_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(netlink, ULNETLINK_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(netlink)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(netlink, ULNETLINK_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(netlink, ULNETLINK_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(netlink, ULNETLINK_DEBUG_, m, x)
 
 static void netlink_init_debug(void)
 {
@@ -78,7 +76,7 @@ int ul_nl_request_dump(struct ul_nl_data *nl, uint16_t nlmsg_type)
        req.nh.nlmsg_type = nlmsg_type;
        req.g.rtgen_family = AF_NETLINK;
        nl->dumping = true;
-       DBG(NLMSG, ul_debugobj(nl, "sending dump request"));
+       DBG_OBJ(NLMSG, nl, ul_debug("sending dump request"));
        if (send(nl->fd, &req, req.nh.nlmsg_len, 0) < 0)
                return -1;
        return 0;
@@ -119,7 +117,7 @@ static int process_addr(struct ul_nl_data *nl, struct nlmsghdr *nh)
        static char ifname[IF_NAMESIZE];
        bool has_local_address = false;
 
-       DBG(ADDR, ul_debugobj(nh, "processing nlmsghdr"));
+       DBG_OBJ(ADDR, nh, ul_debug("processing nlmsghdr"));
        memset(&(nl->addr), 0, sizeof(struct ul_nl_addr));
 
        /* Process ifaddrmsg. */
@@ -150,7 +148,7 @@ static int process_addr(struct ul_nl_data *nl, struct nlmsghdr *nh)
        for (attr = IFA_RTA(ifaddr); RTA_OK(attr, len);
             attr = RTA_NEXT(attr, len)) {
                /* Process most common rta attributes */
-               DBG(ADDR, ul_debugobj(attr, "processing rtattr"));
+               DBG_OBJ(ADDR, attr, ul_debug("processing rtattr"));
                switch (attr->rta_type) {
                case IFA_ADDRESS:
                        nl->addr.ifa_address = RTA_DATA(attr);
@@ -199,7 +197,7 @@ static int process_addr(struct ul_nl_data *nl, struct nlmsghdr *nh)
                break;
                }
        }
-       DBG(NLMSG, ul_debugobj(nl, "callback %p", nl->callback_addr));
+       DBG_OBJ(NLMSG, nl, ul_debug("callback %p", nl->callback_addr));
        return (*(nl->callback_addr))(nl);
 }
 
@@ -214,7 +212,7 @@ static int process_msg(struct ul_nl_data *nl, struct nlmsghdr *nh)
                /* fallthrough */
        case RTM_DELADDR:
        /* If callback_addr is not set, skip process_addr */
-               DBG(NLMSG, ul_debugobj(nl, "%s",
+               DBG_OBJ(NLMSG, nl, ul_debug("%s",
                                       (UL_NL_IS_RTM_DEL(nl) ?
                                        "RTM_DELADDR" : "RTM_NEWADDR")));
                if (nl->callback_addr)
@@ -222,7 +220,7 @@ static int process_msg(struct ul_nl_data *nl, struct nlmsghdr *nh)
                break;
        /* More can be implemented in future (RTM_NEWLINK, RTM_DELLINK etc.). */
        default:
-               DBG(NLMSG, ul_debugobj(nl, "nlmsg_type = %hu", nh->nlmsg_type));
+               DBG_OBJ(NLMSG, nl, ul_debug("nlmsg_type = %hu", nh->nlmsg_type));
                break;
 
        }
@@ -252,19 +250,18 @@ int ul_nl_process(struct ul_nl_data *nl, bool async, bool loop)
        };
 
        while (1) {
-               DBG(NLMSG, ul_debugobj(nl, "waiting for message"));
+               DBG_OBJ(NLMSG, nl, ul_debug("waiting for message"));
                rc = recvmsg(nl->fd, &msg, (loop ? 0 :
                                            (async ? MSG_DONTWAIT : 0)));
-               DBG(NLMSG, ul_debugobj(nl, "got message"));
+               DBG_OBJ(NLMSG, nl, ul_debug("got message"));
                if (rc < 0) {
                        if (errno == EWOULDBLOCK || errno == EAGAIN) {
-                               DBG(NLMSG,
-                                   ul_debugobj(nl, "no data"));
+                               DBG_OBJ(NLMSG, nl, ul_debug("no data"));
                                return UL_NL_WOULDBLOCK;
                        }
                        /* Failure, just stop listening for changes */
                        nl->dumping = false;
-                       DBG(NLMSG, ul_debugobj(nl, "error"));
+                       DBG_OBJ(NLMSG, nl, ul_debug("error"));
                        return rc;
                }
                else
@@ -275,13 +272,12 @@ int ul_nl_process(struct ul_nl_data *nl, bool async, bool loop)
                     nh = NLMSG_NEXT(nh, len)) {
 
                        if (nh->nlmsg_type == NLMSG_ERROR) {
-                               DBG(NLMSG, ul_debugobj(nl, "NLMSG_ERROR"));
+                               DBG_OBJ(NLMSG, nl, ul_debug("NLMSG_ERROR"));
                                nl->dumping = false;
                                return -1;
                        }
                        if (nh->nlmsg_type == NLMSG_DONE) {
-                               DBG(NLMSG,
-                                   ul_debugobj(nl, "NLMSG_DONE"));
+                               DBG_OBJ(NLMSG, nl, ul_debug("NLMSG_DONE"));
                                nl->dumping = false;
                                return UL_NL_DONE;
                        }
@@ -289,17 +285,15 @@ int ul_nl_process(struct ul_nl_data *nl, bool async, bool loop)
                        rc = process_msg(nl, nh);
                        if (rc)
                        {
-                               DBG(NLMSG,
-                                   ul_debugobj(nl,
-                                               "process_msg() returned %d",
-                                               rc));
+                               DBG_OBJ(NLMSG, nl,
+                                   ul_debug("process_msg() returned %d", rc));
                                if (rc != UL_NL_SOFT_ERROR)
                                        return rc;
                        }
                }
                if (!loop)
                        return 0;
-               DBG(NLMSG, ul_debugobj(nl, "looping until NLMSG_DONE"));
+               DBG_OBJ(NLMSG, nl, ul_debug("looping until NLMSG_DONE"));
        }
 }
 
@@ -309,7 +303,7 @@ int ul_nl_open(struct ul_nl_data *nl, uint32_t nl_groups)
        int sock;
        int rc;
 
-       DBG(NLMSG, ul_debugobj(nl, "opening socket"));
+       DBG_OBJ(NLMSG, nl, ul_debug("opening socket"));
        sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
        if (sock < 0)
                return sock;
@@ -330,7 +324,7 @@ int ul_nl_open(struct ul_nl_data *nl, uint32_t nl_groups)
 
 int ul_nl_close(struct ul_nl_data *nl)
 {
-       DBG(NLMSG, ul_debugobj(nl, "closing socket"));
+       DBG_OBJ(NLMSG, nl, ul_debug("closing socket"));
        return close(nl->fd);
 }
 
index 6ce8a10d2dd035432a4701e0f38c1120578028f0..ec07e6cd0d2559eacdb15f9e6fe89e61b463673e 100644 (file)
@@ -37,11 +37,9 @@ UL_DEBUG_DEFINE_MASKNAMES(ulpath) = UL_DEBUG_EMPTY_MASKNAMES;
 #define ULPATH_DEBUG_INIT      (1 << 1)
 #define ULPATH_DEBUG_CXT       (1 << 2)
 
-#define DBG(m, x)       __UL_DBG(ulpath, ULPATH_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(ulpath, ULPATH_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(ulpath)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(ulpath, ULPATH_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(ulpath, ULPATH_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(ulpath, ULPATH_DEBUG_, m, x)
 
 void ul_path_init_debug(void)
 {
@@ -57,7 +55,7 @@ struct path_cxt *ul_new_path(const char *dir, ...)
        if (!pc)
                return NULL;
 
-       DBG(CXT, ul_debugobj(pc, "alloc"));
+       DBG_OBJ(CXT, pc, ul_debug("alloc"));
 
        pc->refcount = 1;
        pc->dir_fd = -1;
@@ -93,7 +91,7 @@ void ul_unref_path(struct path_cxt *pc)
        pc->refcount--;
 
        if (pc->refcount <= 0) {
-               DBG(CXT, ul_debugobj(pc, "dealloc"));
+               DBG_OBJ(CXT, pc, ul_debug("dealloc"));
                if (pc->dialect)
                        pc->free_dialect(pc);
                ul_path_close_dirfd(pc);
@@ -117,7 +115,7 @@ int ul_path_set_prefix(struct path_cxt *pc, const char *prefix)
 
        free(pc->prefix);
        pc->prefix = p;
-       DBG(CXT, ul_debugobj(pc, "new prefix: '%s'", p));
+       DBG_OBJ(CXT, pc, ul_debug("new prefix: '%s'", p));
        return 0;
 }
 
@@ -143,7 +141,7 @@ int ul_path_set_dir(struct path_cxt *pc, const char *dir)
 
        free(pc->dir_path);
        pc->dir_path = p;
-       DBG(CXT, ul_debugobj(pc, "new dir: '%s'", p));
+       DBG_OBJ(CXT, pc, ul_debug("new dir: '%s'", p));
        return 0;
 }
 
@@ -156,7 +154,7 @@ int ul_path_set_dialect(struct path_cxt *pc, void *data, void free_data(struct p
 {
        pc->dialect = data;
        pc->free_dialect = free_data;
-       DBG(CXT, ul_debugobj(pc, "(re)set dialect"));
+       DBG_OBJ(CXT, pc, ul_debug("(re)set dialect"));
        return 0;
 }
 
@@ -220,7 +218,7 @@ int ul_path_get_dirfd(struct path_cxt *pc)
                if (!path)
                        return -errno;
 
-               DBG(CXT, ul_debugobj(pc, "opening dir: '%s'", path));
+               DBG_OBJ(CXT, pc, ul_debug("opening dir: '%s'", path));
                pc->dir_fd = open(path, O_RDONLY|O_CLOEXEC);
        }
 
@@ -233,7 +231,7 @@ void ul_path_close_dirfd(struct path_cxt *pc)
        assert(pc);
 
        if (pc->dir_fd >= 0) {
-               DBG(CXT, ul_debugobj(pc, "closing dir"));
+               DBG_OBJ(CXT, pc, ul_debug("closing dir"));
                close(pc->dir_fd);
                pc->dir_fd = -1;
        }
@@ -325,7 +323,7 @@ int ul_path_access(struct path_cxt *pc, int mode, const char *path)
                    && pc->redirect_on_enoent(pc, path, &dir) == 0)
                        rc = faccessat(dir, path, mode, 0);
 
-               DBG(CXT, ul_debugobj(pc, "access: '%s' [rc=%d]", path, rc));
+               DBG_OBJ(CXT, pc, ul_debug("access: '%s' [rc=%d]", path, rc));
        }
        return rc;
 }
@@ -370,7 +368,7 @@ int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *pa
                    && pc->redirect_on_enoent(pc, path, &dir) == 0)
                        rc = fstatat(dir, path, sb, 0);
 
-               DBG(CXT, ul_debugobj(pc, "stat '%s' [rc=%d]", path, rc));
+               DBG_OBJ(CXT, pc, ul_debug("stat '%s' [rc=%d]", path, rc));
        }
        return rc;
 }
@@ -477,7 +475,7 @@ int ul_path_open(struct path_cxt *pc, int flags, const char *path)
                    && pc->redirect_on_enoent(pc, path, &dir) == 0)
                        fd = openat(dir, path, flags);
 
-               DBG(CXT, ul_debugobj(pc, "opening '%s'%s", path, fdx != fd ? " [redirected]" : ""));
+               DBG_OBJ(CXT, pc, ul_debug("opening '%s'%s", path, fdx != fd ? " [redirected]" : ""));
        }
        return fd;
 }
@@ -578,7 +576,7 @@ DIR *ul_path_opendir(struct path_cxt *pc, const char *path)
        else if (pc->dir_path) {
                int dirfd;
 
-               DBG(CXT, ul_debugobj(pc, "duplicate dir path"));
+               DBG_OBJ(CXT, pc, ul_debug("duplicate dir path"));
                dirfd = ul_path_get_dirfd(pc);
                if (dirfd >= 0)
                        fd = dup_fd_cloexec(dirfd, STDERR_FILENO + 1);
index ea677d6bf5c7ee49565ee586664cfe4f6d781375..744c2141f4a3db6715442b1689cf238df81ec345 100644 (file)
@@ -32,11 +32,9 @@ UL_DEBUG_DEFINE_MASKNAMES(ulprocfs) = UL_DEBUG_EMPTY_MASKNAMES;
 #define ULPROCFS_DEBUG_INIT    (1 << 1)
 #define ULPROCFS_DEBUG_CXT     (1 << 2)
 
-#define DBG(m, x)       __UL_DBG(ulprocfs, ULPROCFS_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(ulprocfs, ULPROCFS_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(ulprocfs)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(ulprocfs, ULPROCFS_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(ulprocfs, ULPROCFS_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(ulprocfs, ULPROCFS_DEBUG_, m, x)
 
 void ul_procfs_init_debug(void)
 {
@@ -59,7 +57,7 @@ struct path_cxt *ul_new_procfs_path(pid_t pid, const char *prefix)
                return NULL;
        }
 
-       DBG(CXT, ul_debugobj(pc, "alloc"));
+       DBG_OBJ(CXT, pc, ul_debug("alloc"));
        return pc;
 }
 
@@ -90,7 +88,7 @@ int procfs_process_init_path(struct path_cxt *pc, pid_t pid)
        /* initialize procfs specific stuff */
        prc = ul_path_get_dialect(pc);
        if (!prc) {
-               DBG(CXT, ul_debugobj(pc, "alloc new procfs handler"));
+               DBG_OBJ(CXT, pc, ul_debug("alloc new procfs handler"));
                prc = calloc(1, sizeof(struct procfs_process));
                if (!prc)
                        return -ENOMEM;
@@ -98,7 +96,7 @@ int procfs_process_init_path(struct path_cxt *pc, pid_t pid)
                ul_path_set_dialect(pc, prc, procfs_process_deinit_path);
        }
 
-       DBG(CXT, ul_debugobj(pc, "init procfs stuff"));
+       DBG_OBJ(CXT, pc, ul_debug("init procfs stuff"));
 
        prc->pid = pid;
        return 0;
@@ -111,7 +109,7 @@ static void procfs_process_deinit_path(struct path_cxt *pc)
        if (!pc)
                return;
 
-       DBG(CXT, ul_debugobj(pc, "deinit"));
+       DBG_OBJ(CXT, pc, ul_debug("deinit"));
 
        prc = ul_path_get_dialect(pc);
        if (!prc)
index 00ed555dc503f7d9e30e52f04b0003f13ff0c5e0..ea883ef6a4fd8c7d0b9cb570ca28e1ab04fa725f 100644 (file)
@@ -37,11 +37,9 @@ UL_DEBUG_DEFINE_MASKNAMES(ulpty) = UL_DEBUG_EMPTY_MASKNAMES;
 #define ULPTY_DEBUG_DONE       (1 << 5)
 #define ULPTY_DEBUG_ALL                0xFFFF
 
-#define DBG(m, x)       __UL_DBG(ulpty, ULPTY_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(ulpty, ULPTY_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK   UL_DEBUG_MASK(ulpty)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(ulpty, ULPTY_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(ulpty, ULPTY_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(ulpty, ULPTY_DEBUG_, m, x)
 
 void ul_pty_init_debug(int mask)
 {
@@ -57,7 +55,7 @@ struct ul_pty *ul_new_pty(int is_stdin_tty)
        if (!pty)
                return NULL;
 
-       DBG(SETUP, ul_debugobj(pty, "alloc handler"));
+       DBG_OBJ(SETUP, pty, ul_debug("alloc handler"));
        pty->isterm = is_stdin_tty;
        pty->master = -1;
        pty->slave = -1;
@@ -136,12 +134,12 @@ void ul_pty_set_mainloop_time(struct ul_pty *pty, struct timeval *tv)
 {
        assert(pty);
        if (!tv) {
-               DBG(IO, ul_debugobj(pty, "mainloop time: clear"));
+               DBG_OBJ(IO, pty, ul_debug("mainloop time: clear"));
                timerclear(&pty->next_callback_time);
        } else {
                pty->next_callback_time.tv_sec = tv->tv_sec;
                pty->next_callback_time.tv_usec = tv->tv_usec;
-               DBG(IO, ul_debugobj(pty, "mainloop time: %"PRId64".%06"PRId64,
+               DBG_OBJ(IO, pty, ul_debug("mainloop time: %"PRId64".%06"PRId64,
                                (int64_t) tv->tv_sec, (int64_t) tv->tv_usec));
        }
 }
@@ -169,7 +167,7 @@ int ul_pty_setup(struct ul_pty *pty)
        sigprocmask(0, NULL, &pty->orgsig);
 
        if (pty->isterm) {
-               DBG(SETUP, ul_debugobj(pty, "create for terminal"));
+               DBG_OBJ(SETUP, pty, ul_debug("create for terminal"));
 
                /* original setting of the current terminal */
                if (tcgetattr(STDIN_FILENO, &pty->stdin_attrs) != 0) {
@@ -193,7 +191,7 @@ int ul_pty_setup(struct ul_pty *pty)
                cfmakeraw(&attrs);
                tcsetattr(STDIN_FILENO, TCSANOW, &attrs);
        } else {
-               DBG(SETUP, ul_debugobj(pty, "create for non-terminal"));
+               DBG_OBJ(SETUP, pty, ul_debug("create for non-terminal"));
 
                rc = openpty(&pty->master, &pty->slave, NULL, NULL, NULL);
                if (rc)
@@ -215,7 +213,7 @@ done:
        if (rc)
                ul_pty_cleanup(pty);
 
-       DBG(SETUP, ul_debugobj(pty, "pty setup done [master=%d, slave=%d, rc=%d]",
+       DBG_OBJ(SETUP, pty, ul_debug("pty setup done [master=%d, slave=%d, rc=%d]",
                                pty->master, pty->slave, rc));
        return rc;
 }
@@ -255,7 +253,7 @@ done:
        if (rc)
                ul_pty_cleanup(pty);
 
-       DBG(SETUP, ul_debugobj(pty, "pty signals setup done [rc=%d]", rc));
+       DBG_OBJ(SETUP, pty, ul_debug("pty signals setup done [rc=%d]", rc));
        return rc;
 }
 
@@ -269,7 +267,7 @@ void ul_pty_cleanup(struct ul_pty *pty)
        if (pty->master == -1 || !pty->isterm)
                return;
 
-       DBG(DONE, ul_debugobj(pty, "cleanup"));
+       DBG_OBJ(DONE, pty, ul_debug("cleanup"));
        rtt = pty->stdin_attrs;
        tcsetattr(STDIN_FILENO, TCSADRAIN, &rtt);
 }
@@ -286,7 +284,7 @@ int ul_pty_chownmod_slave(struct ul_pty *pty, uid_t uid, gid_t gid, mode_t mode)
 /* call me in child process */
 void ul_pty_init_slave(struct ul_pty *pty)
 {
-       DBG(SETUP, ul_debugobj(pty, "initialize slave"));
+       DBG_OBJ(SETUP, pty, ul_debug("initialize slave"));
 
        setsid();
 
@@ -308,7 +306,7 @@ void ul_pty_init_slave(struct ul_pty *pty)
 
        sigprocmask(SIG_SETMASK, &pty->orgsig, NULL);
 
-       DBG(SETUP, ul_debugobj(pty, "... initialize slave done"));
+       DBG_OBJ(SETUP, pty, ul_debug("... initialize slave done"));
 }
 
 static int write_output(char *obuf, ssize_t bytes)
@@ -370,16 +368,16 @@ static void drain_child_buffers(struct ul_pty *pty)
        unsigned int tries = 0;
        struct pollfd fd = { .fd = pty->slave, .events = POLLIN };
 
-       DBG(IO, ul_debugobj(pty, " waiting for empty slave"));
+       DBG_OBJ(IO, pty, ul_debug(" waiting for empty slave"));
        while (poll(&fd, 1, 10) == 1 && tries < 8) {
-               DBG(IO, ul_debugobj(pty, "   slave is not empty"));
+               DBG_OBJ(IO, pty, ul_debug("   slave is not empty"));
                xusleep(250000);
                tries++;
        }
        if (tries < 8)
-               DBG(IO, ul_debugobj(pty, "   slave is empty now"));
+               DBG_OBJ(IO, pty, ul_debug("   slave is empty now"));
 
-       DBG(IO, ul_debugobj(pty, " sending EOF to master"));
+       DBG_OBJ(IO, pty, ul_debug(" sending EOF to master"));
 }
 
 static int flush_child_buffers(struct ul_pty *pty, int *anything)
@@ -393,16 +391,16 @@ static int flush_child_buffers(struct ul_pty *pty, int *anything)
                if (hd->final_input)
                        drain_child_buffers(pty);
 
-               DBG(IO, ul_debugobj(hd, " stdin --> master trying %zu bytes", hd->size - hd->cursor));
+               DBG_OBJ(IO, hd, ul_debug(" stdin --> master trying %zu bytes", hd->size - hd->cursor));
 
                ret = write(pty->master, hd->buf + hd->cursor, hd->size - hd->cursor);
                if (ret == -1) {
-                       DBG(IO, ul_debugobj(hd, "   EAGAIN"));
+                       DBG_OBJ(IO, hd, ul_debug("   EAGAIN"));
                        if (!(errno == EINTR || errno == EAGAIN))
                                rc = -errno;
                        goto out;
                }
-               DBG(IO, ul_debugobj(hd, "   wrote %zd", ret));
+               DBG_OBJ(IO, hd, ul_debug("   wrote %zd", ret));
                any = 1;
                hd->cursor += ret;
 
@@ -439,10 +437,10 @@ static int mainloop_callback(struct ul_pty *pty)
        if (!pty->callbacks.mainloop)
                return 0;
 
-       DBG(IO, ul_debugobj(pty, "calling mainloop callback"));
+       DBG_OBJ(IO, pty, ul_debug("calling mainloop callback"));
        rc = pty->callbacks.mainloop(pty->callback_data);
 
-       DBG(IO, ul_debugobj(pty, " callback done [rc=%d]", rc));
+       DBG_OBJ(IO, pty, ul_debug(" callback done [rc=%d]", rc));
        return rc;
 }
 
@@ -453,7 +451,7 @@ static int handle_io(struct ul_pty *pty, int fd, int *eof)
        int rc = 0;
        sigset_t set;
 
-       DBG(IO, ul_debugobj(pty, " handle I/O on fd=%d", fd));
+       DBG_OBJ(IO, pty, ul_debug(" handle I/O on fd=%d", fd));
        *eof = 0;
 
        sigemptyset(&set);
@@ -475,14 +473,14 @@ static int handle_io(struct ul_pty *pty, int fd, int *eof)
 
        /* from stdin (user) to command */
        if (fd == STDIN_FILENO) {
-               DBG(IO, ul_debugobj(pty, " stdin --> master %zd bytes queued", bytes));
+               DBG_OBJ(IO, pty, ul_debug(" stdin --> master %zd bytes queued", bytes));
 
                if (schedule_child_write(pty, buf, bytes, 0))
                        return -errno;
 
        /* from command (master) to stdout */
        } else if (fd == pty->master) {
-               DBG(IO, ul_debugobj(pty, " master --> stdout %zd bytes", bytes));
+               DBG_OBJ(IO, pty, ul_debug(" master --> stdout %zd bytes", bytes));
                write_output(buf, bytes);
        }
 
@@ -540,7 +538,7 @@ static int handle_signal(struct ul_pty *pty, int fd)
        ssize_t bytes;
        int rc = 0;
 
-       DBG(SIG, ul_debugobj(pty, " handle signal on fd=%d", fd));
+       DBG_OBJ(SIG, pty, ul_debug(" handle signal on fd=%d", fd));
 
        bytes = read(fd, &info, sizeof(info));
        if (bytes != sizeof(info)) {
@@ -551,7 +549,7 @@ static int handle_signal(struct ul_pty *pty, int fd)
 
        switch (info.ssi_signo) {
        case SIGCHLD:
-               DBG(SIG, ul_debugobj(pty, " get signal SIGCHLD"));
+               DBG_OBJ(SIG, pty, ul_debug(" get signal SIGCHLD"));
 
                if (info.ssi_code == CLD_EXITED
                    || info.ssi_code == CLD_KILLED
@@ -569,13 +567,13 @@ static int handle_signal(struct ul_pty *pty, int fd)
                }
 
                if (pty->child <= 0) {
-                       DBG(SIG, ul_debugobj(pty, " no child, setting leaving timeout"));
+                       DBG_OBJ(SIG, pty, ul_debug(" no child, setting leaving timeout"));
                        pty->poll_timeout = 10;
                        timerclear(&pty->next_callback_time);
                }
                return 0;
        case SIGWINCH:
-               DBG(SIG, ul_debugobj(pty, " get signal SIGWINCH"));
+               DBG_OBJ(SIG, pty, ul_debug(" get signal SIGWINCH"));
                if (pty->isterm) {
                        ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&pty->win);
                        ioctl(pty->slave, TIOCSWINSZ, (char *)&pty->win);
@@ -592,7 +590,7 @@ static int handle_signal(struct ul_pty *pty, int fd)
        case SIGINT:
                FALLTHROUGH;
        case SIGQUIT:
-               DBG(SIG, ul_debugobj(pty, " get signal SIG{TERM,INT,QUIT}"));
+               DBG_OBJ(SIG, pty, ul_debug(" get signal SIG{TERM,INT,QUIT}"));
                pty->delivered_signal = info.ssi_signo;
                /* Child termination is going to generate SIGCHLD (see above) */
                if (pty->child > 0)
@@ -603,7 +601,7 @@ static int handle_signal(struct ul_pty *pty, int fd)
                                        &info, (void *) &pty->win);
                break;
        case SIGUSR1:
-               DBG(SIG, ul_debugobj(pty, " get signal SIGUSR1"));
+               DBG_OBJ(SIG, pty, ul_debug(" get signal SIGUSR1"));
                if (pty->callbacks.flush_logs)
                        rc = pty->callbacks.flush_logs(pty->callback_data);
                break;
@@ -640,13 +638,13 @@ int ul_pty_proxy_master(struct ul_pty *pty)
                size_t i;
                int errsv, timeout;
 
-               DBG(IO, ul_debugobj(pty, "--poll() loop--"));
+               DBG_OBJ(IO, pty, ul_debug("--poll() loop--"));
 
                /* note, callback usually updates @next_callback_time */
                if (timerisset(&pty->next_callback_time)) {
                        struct timeval now = { 0 };
 
-                       DBG(IO, ul_debugobj(pty, " callback requested"));
+                       DBG_OBJ(IO, pty, ul_debug(" callback requested"));
                        gettime_monotonic(&now);
                        if (timercmp(&now, &pty->next_callback_time, >)) {
                                rc = mainloop_callback(pty);
@@ -672,11 +670,11 @@ int ul_pty_proxy_master(struct ul_pty *pty)
                        pfd[POLLFD_MASTER].events &= ~POLLOUT;
 
                /* wait for input, signal or timeout */
-               DBG(IO, ul_debugobj(pty, "calling poll() [timeout=%dms]", timeout));
+               DBG_OBJ(IO, pty, ul_debug("calling poll() [timeout=%dms]", timeout));
                ret = poll(pfd, ARRAY_SIZE(pfd), timeout);
 
                errsv = errno;
-               DBG(IO, ul_debugobj(pty, "poll() rc=%d", ret));
+               DBG_OBJ(IO, pty, ul_debug("poll() rc=%d", ret));
 
                /* error */
                if (ret < 0) {
@@ -696,7 +694,7 @@ int ul_pty_proxy_master(struct ul_pty *pty)
                                rc = 0;
                        }
 
-                       DBG(IO, ul_debugobj(pty, "leaving poll() loop [timeout=%d, rc=%d]", timeout, rc));
+                       DBG_OBJ(IO, pty, ul_debug("leaving poll() loop [timeout=%d, rc=%d]", timeout, rc));
                        break;
                }
                /* event */
@@ -704,7 +702,7 @@ int ul_pty_proxy_master(struct ul_pty *pty)
                        if (pfd[i].revents == 0)
                                continue;
 
-                       DBG(IO, ul_debugobj(pty, " active pfd[%s].fd=%d %s %s %s %s %s",
+                       DBG_OBJ(IO, pty, ul_debug(" active pfd[%s].fd=%d %s %s %s %s %s",
                                                i == POLLFD_STDIN  ? "stdin" :
                                                i == POLLFD_MASTER ? "master" :
                                                i == POLLFD_SIGNAL ? "signal" : "???",
@@ -743,7 +741,7 @@ int ul_pty_proxy_master(struct ul_pty *pty)
                         * POLLNVAL means that fd is closed.
                         */
                        if ((pfd[i].revents & POLLHUP) || (pfd[i].revents & POLLNVAL) || eof) {
-                               DBG(IO, ul_debugobj(pty, " ignore FD"));
+                               DBG_OBJ(IO, pty, ul_debug(" ignore FD"));
                                if (i == POLLFD_STDIN) {
                                        pfd[i].fd = -1;
                                        ul_pty_write_eof_to_child(pty);
index 13977ee5b135413084e854a8890cb3618c4096da..5cbffc741935ab37367db3e4286a68c0f734d9cf 100644 (file)
@@ -32,11 +32,9 @@ UL_DEBUG_DEFINE_MASKNAMES(ulsysfs) = UL_DEBUG_EMPTY_MASKNAMES;
 #define ULSYSFS_DEBUG_INIT     (1 << 1)
 #define ULSYSFS_DEBUG_CXT      (1 << 2)
 
-#define DBG(m, x)       __UL_DBG(ulsysfs, ULSYSFS_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(ulsysfs, ULSYSFS_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(ulsysfs)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(ulsysfs, ULSYSFS_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(ulsysfs, ULSYSFS_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(ulsysfs, ULSYSFS_DEBUG_, m, x)
 
 void ul_sysfs_init_debug(void)
 {
@@ -59,7 +57,7 @@ struct path_cxt *ul_new_sysfs_path(dev_t devno, struct path_cxt *parent, const c
                return NULL;
        }
 
-       DBG(CXT, ul_debugobj(pc, "alloc"));
+       DBG_OBJ(CXT, pc, ul_debug("alloc"));
        return pc;
 }
 
@@ -92,7 +90,7 @@ int sysfs_blkdev_init_path(struct path_cxt *pc, dev_t devno, struct path_cxt *pa
        /* initialize sysfs blkdev specific stuff */
        blk = ul_path_get_dialect(pc);
        if (!blk) {
-               DBG(CXT, ul_debugobj(pc, "alloc new sysfs handler"));
+               DBG_OBJ(CXT, pc, ul_debug("alloc new sysfs handler"));
                blk = calloc(1, sizeof(struct sysfs_blkdev));
                if (!blk)
                        return -ENOMEM;
@@ -101,7 +99,7 @@ int sysfs_blkdev_init_path(struct path_cxt *pc, dev_t devno, struct path_cxt *pa
                ul_path_set_enoent_redirect(pc, sysfs_blkdev_enoent_redirect);
        }
 
-       DBG(CXT, ul_debugobj(pc, "init sysfs stuff"));
+       DBG_OBJ(CXT, pc, ul_debug("init sysfs stuff"));
 
        blk->devno = devno;
        sysfs_blkdev_set_parent(pc, parent);
@@ -116,7 +114,7 @@ static void sysfs_blkdev_deinit_path(struct path_cxt *pc)
        if (!pc)
                return;
 
-       DBG(CXT, ul_debugobj(pc, "deinit"));
+       DBG_OBJ(CXT, pc, ul_debug("deinit"));
 
        blk = ul_path_get_dialect(pc);
        if (!blk)
@@ -146,7 +144,7 @@ int sysfs_blkdev_set_parent(struct path_cxt *pc, struct path_cxt *parent)
        } else
                blk->parent = NULL;
 
-       DBG(CXT, ul_debugobj(pc, "new parent"));
+       DBG_OBJ(CXT, pc, ul_debug("new parent"));
        return 0;
 }
 
@@ -170,7 +168,7 @@ static int sysfs_blkdev_enoent_redirect(struct path_cxt *pc, const char *path, i
        if (blk && blk->parent && path) {
                *dirfd = ul_path_get_dirfd(blk->parent);
                if (*dirfd >= 0) {
-                       DBG(CXT, ul_debugobj(pc, "%s redirected to parent", path));
+                       DBG_OBJ(CXT, pc, ul_debug("%s redirected to parent", path));
                        return 0;
                }
        }
@@ -296,7 +294,7 @@ dev_t sysfs_blkdev_partno_to_devno(struct path_cxt *pc, int partno)
        }
 
        closedir(dir);
-       DBG(CXT, ul_debugobj(pc, "partno (%d) -> devno (%d)", (int) partno, (int) devno));
+       DBG_OBJ(CXT, pc, ul_debug("partno (%d) -> devno (%d)", (int) partno, (int) devno));
        return devno;
 }
 
index fa2379c4df36e06742319fa442441c59fc787014..f1bb3f8f5cbeab75d76824934f49e7239fe2909f 100644 (file)
@@ -352,11 +352,9 @@ struct blkid_struct_cache
 #define BLKID_DEBUG_ALL                0xFFFF          /* (1 << 16) aka FFFF is expected by API */
 
 UL_DEBUG_DECLARE_MASK(libblkid);
-#define DBG(m, x)      __UL_DBG(libblkid, BLKID_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(libblkid, BLKID_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(libblkid)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(libblkid, BLKID_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(libblkid, BLKID_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(libblkid, BLKID_DEBUG_, m, x)
 
 extern void blkid_debug_dump_dev(blkid_dev dev);
 
index d2fa077d4479c06da03ff8a3155035b9524e4491..3b9641c6c9734e6d0051a02435dbc916a620fc76 100644 (file)
@@ -101,7 +101,7 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
        if (!(cache = calloc(1, sizeof(struct blkid_struct_cache))))
                return -BLKID_ERR_MEM;
 
-       DBG(CACHE, ul_debugobj(cache, "alloc (from %s)", filename ? filename : "default cache"));
+       DBG_OBJ(CACHE, cache, ul_debug("alloc (from %s)", filename ? filename : "default cache"));
        INIT_LIST_HEAD(&cache->bic_devs);
        INIT_LIST_HEAD(&cache->bic_tags);
 
@@ -130,7 +130,7 @@ void blkid_put_cache(blkid_cache cache)
 
        (void) blkid_flush_cache(cache);
 
-       DBG(CACHE, ul_debugobj(cache, "freeing cache struct"));
+       DBG_OBJ(CACHE, cache, ul_debug("freeing cache struct"));
 
        /* DBG(CACHE, ul_debug_dump_cache(cache)); */
 
@@ -141,7 +141,7 @@ void blkid_put_cache(blkid_cache cache)
                blkid_free_dev(dev);
        }
 
-       DBG(CACHE, ul_debugobj(cache, "freeing cache tag heads"));
+       DBG_OBJ(CACHE, cache, ul_debug("freeing cache tag heads"));
        while (!list_empty(&cache->bic_tags)) {
                blkid_tag tag = list_entry(cache->bic_tags.next,
                                           struct blkid_struct_tag,
@@ -152,7 +152,7 @@ void blkid_put_cache(blkid_cache cache)
                                                   struct blkid_struct_tag,
                                                   bit_names);
 
-                       DBG(CACHE, ul_debugobj(cache, "warning: unfreed tag %s=%s",
+                       DBG_OBJ(CACHE, cache, ul_debug("warning: unfreed tag %s=%s",
                                                bad->bit_name, bad->bit_val));
                        blkid_free_tag(bad);
                }
@@ -185,7 +185,7 @@ void blkid_gc_cache(blkid_cache cache)
 
                ret = stat(dev->bid_name, &st);
                if (ret < 0) {
-                       DBG(CACHE, ul_debugobj(cache, "freeing non-existing %s", dev->bid_name));
+                       DBG_OBJ(CACHE, cache, ul_debug("freeing non-existing %s", dev->bid_name));
                        blkid_free_dev(dev);
                        cache->bic_flags |= BLKID_BIC_FL_CHANGED;
 
@@ -193,7 +193,7 @@ void blkid_gc_cache(blkid_cache cache)
                } else if (is_loopdev(dev->bid_name)
                                        && !loopdev_has_backing_file(dev->bid_name)) {
                        /* remove empty loop device from cache */
-                       DBG(CACHE, ul_debugobj(cache, "freeing empty loop device %s", dev->bid_name));
+                       DBG_OBJ(CACHE, cache, ul_debug("freeing empty loop device %s", dev->bid_name));
                        blkid_free_dev(dev);
                        cache->bic_flags |= BLKID_BIC_FL_CHANGED;
 #endif
index ca13f3970df6787f805830f1902d7b91e0b5ac28..366876e86df02efd5fbb3a136ae46e97cb0b4607 100644 (file)
@@ -37,7 +37,7 @@ blkid_dev blkid_new_dev(void)
        if (!(dev = calloc(1, sizeof(struct blkid_struct_dev))))
                return NULL;
 
-       DBG(DEV, ul_debugobj(dev, "alloc"));
+       DBG_OBJ(DEV, dev, ul_debug("alloc"));
        INIT_LIST_HEAD(&dev->bid_devs);
        INIT_LIST_HEAD(&dev->bid_tags);
 
@@ -49,7 +49,7 @@ void blkid_free_dev(blkid_dev dev)
        if (!dev)
                return;
 
-       DBG(DEV, ul_debugobj(dev, "freeing (%s)", dev->bid_name));
+       DBG_OBJ(DEV, dev, ul_debug("freeing (%s)", dev->bid_name));
 
        list_del(&dev->bid_devs);
        while (!list_empty(&dev->bid_tags)) {
index f195c0625cfbc44b8fbb6f196f42e50dd3985757..d802650258ae806e3f9d58e9f2d8638b0b0ba2c0 100644 (file)
@@ -24,7 +24,7 @@ static blkid_tag blkid_new_tag(void)
        if (!(tag = calloc(1, sizeof(struct blkid_struct_tag))))
                return NULL;
 
-       DBG(TAG, ul_debugobj(tag, "alloc"));
+       DBG_OBJ(TAG, tag, ul_debug("alloc"));
        INIT_LIST_HEAD(&tag->bit_tags);
        INIT_LIST_HEAD(&tag->bit_names);
 
@@ -36,7 +36,7 @@ void blkid_free_tag(blkid_tag tag)
        if (!tag)
                return;
 
-       DBG(TAG, ul_debugobj(tag, "freeing tag %s (%s)", tag->bit_name, tag->bit_val));
+       DBG_OBJ(TAG, tag, ul_debug("freeing tag %s (%s)", tag->bit_name, tag->bit_val));
 
        list_del(&tag->bit_tags);       /* list of tags for this device */
        list_del(&tag->bit_names);      /* list of tags with this type */
@@ -138,7 +138,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                        free(val);
                        return 0;
                }
-               DBG(TAG, ul_debugobj(t, "update (%s) '%s' -> '%s'", t->bit_name, t->bit_val, val));
+               DBG_OBJ(TAG, t, ul_debug("update (%s) '%s' -> '%s'", t->bit_name, t->bit_val, val));
                free(t->bit_val);
                t->bit_val = val;
        } else {
@@ -149,7 +149,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                t->bit_val = val;
                t->bit_dev = dev;
 
-               DBG(TAG, ul_debugobj(t, "setting (%s) '%s'", t->bit_name, t->bit_val));
+               DBG_OBJ(TAG, t, ul_debug("setting (%s) '%s'", t->bit_name, t->bit_val));
                list_add_tail(&t->bit_tags, &dev->bid_tags);
 
                if (dev->bid_cache) {
@@ -160,7 +160,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                                if (!head)
                                        goto errout;
 
-                               DBG(TAG, ul_debugobj(head, "creating new cache tag head %s", name));
+                               DBG_OBJ(TAG, head, ul_debug("creating new cache tag head %s", name));
                                head->bit_name = strdup(name);
                                if (!head->bit_name)
                                        goto errout;
index 2c7a00486694deb7908aa6ddcaef3ee430198b16..ce343db299feb66e421e808ca7c769bb9fc8b3e7 100644 (file)
@@ -112,14 +112,14 @@ fdisk_sector_t fdisk_align_lba(struct fdisk_context *cxt, fdisk_sector_t lba, in
        }
 /*
        if (lba != res)
-               DBG(CXT, ul_debugobj(cxt, "LBA %12ju aligned-%s %12ju [grain=%lus]",
+               DBG_OBJ(CXT, cxt, ul_debug("LBA %12ju aligned-%s %12ju [grain=%lus]",
                                (uintmax_t) lba,
                                direction == FDISK_ALIGN_UP ? "up  " :
                                direction == FDISK_ALIGN_DOWN ? "down" : "near",
                                (uintmax_t) res,
                                cxt->grain / cxt->sector_size));
        else
-               DBG(CXT, ul_debugobj(cxt, "LBA %12ju already aligned", (uintmax_t)lba));
+               DBG_OBJ(CXT, cxt, ul_debug("LBA %12ju already aligned", (uintmax_t)lba));
 */
        return res;
 }
@@ -140,7 +140,7 @@ fdisk_sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
 {
        fdisk_sector_t res;
 
-       /*DBG(CXT, ul_debugobj(cxt, "LBA: align in range <%ju..%ju>", (uintmax_t) start, (uintmax_t) stop));*/
+       /*DBG_OBJ(CXT, cxt, ul_debug("LBA: align in range <%ju..%ju>", (uintmax_t) start, (uintmax_t) stop));*/
 
        if (start + (cxt->grain / cxt->sector_size) <= stop) {
                start = fdisk_align_lba(cxt, start, FDISK_ALIGN_UP);
@@ -148,7 +148,7 @@ fdisk_sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
        }
 
        if (start + (cxt->grain / cxt->sector_size) > stop) {
-               DBG(CXT, ul_debugobj(cxt, "LBA: area smaller than grain, don't align"));
+               DBG_OBJ(CXT, cxt, ul_debug("LBA: area smaller than grain, don't align"));
                res = lba;
                goto done;
        }
@@ -162,7 +162,7 @@ fdisk_sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
        else
                res = lba;
 done:
-       DBG(CXT, ul_debugobj(cxt, "%ju in range <%ju..%ju> aligned to %ju",
+       DBG_OBJ(CXT, cxt, ul_debug("%ju in range <%ju..%ju> aligned to %ju",
                                (uintmax_t) lba,
                                (uintmax_t) start,
                                (uintmax_t) stop,
@@ -243,7 +243,7 @@ int fdisk_override_geometry(struct fdisk_context *cxt,
 
        rc = fdisk_reset_alignment(cxt);
 
-       DBG(CXT, ul_debugobj(cxt, "override C/H/S: %u/%u/%u [rc=%d]",
+       DBG_OBJ(CXT, cxt, ul_debug("override C/H/S: %u/%u/%u [rc=%d]",
                (unsigned) cxt->geom.cylinders,
                (unsigned) cxt->geom.heads,
                (unsigned) cxt->geom.sectors,
@@ -281,7 +281,7 @@ int fdisk_save_user_geometry(struct fdisk_context *cxt,
        if (cylinders)
                cxt->user_geom.cylinders = cylinders;
 
-       DBG(CXT, ul_debugobj(cxt, "user C/H/S: %u/%u/%u",
+       DBG_OBJ(CXT, cxt, ul_debug("user C/H/S: %u/%u/%u",
                                (unsigned) cxt->user_geom.cylinders,
                                (unsigned) cxt->user_geom.heads,
                                (unsigned) cxt->user_geom.sectors));
@@ -309,7 +309,7 @@ int fdisk_save_user_sector_size(struct fdisk_context *cxt,
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "user phy/log sector size: %u/%u", phy, log));
+       DBG_OBJ(CXT, cxt, ul_debug("user phy/log sector size: %u/%u", phy, log));
 
        cxt->user_pyh_sector = phy;
        cxt->user_log_sector = log;
@@ -343,7 +343,7 @@ int fdisk_save_user_grain(struct fdisk_context *cxt, unsigned long grain)
        if (!cxt || grain % 512)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "user grain size: %lu", grain));
+       DBG_OBJ(CXT, cxt, ul_debug("user grain size: %lu", grain));
        cxt->user_grain = grain;
        return 0;
 }
@@ -373,7 +373,7 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "applying user device properties"));
+       DBG_OBJ(CXT, cxt, ul_debug("applying user device properties"));
 
        if (cxt->user_pyh_sector)
                cxt->phy_sector_size = cxt->user_pyh_sector;
@@ -386,7 +386,7 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt)
 
                if (cxt->sector_size != old_secsz) {
                        cxt->total_sectors = (old_total * (old_secsz/512)) / (cxt->sector_size >> 9);
-                       DBG(CXT, ul_debugobj(cxt, "new total sectors: %ju", (uintmax_t)cxt->total_sectors));
+                       DBG_OBJ(CXT, cxt, ul_debug("new total sectors: %ju", (uintmax_t)cxt->total_sectors));
                }
        }
 
@@ -408,17 +408,17 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt)
                unsigned long granularity = max(cxt->phy_sector_size, cxt->min_io_size);
 
                cxt->grain = cxt->user_grain < granularity ? granularity : cxt->user_grain;
-               DBG(CXT, ul_debugobj(cxt, "new grain: %lu", cxt->grain));
+               DBG_OBJ(CXT, cxt, ul_debug("new grain: %lu", cxt->grain));
        }
 
        if (cxt->firstsector_bufsz != cxt->sector_size)
                fdisk_read_firstsector(cxt);
 
-       DBG(CXT, ul_debugobj(cxt, "new C/H/S: %u/%u/%u",
+       DBG_OBJ(CXT, cxt, ul_debug("new C/H/S: %u/%u/%u",
                (unsigned) cxt->geom.cylinders,
                (unsigned) cxt->geom.heads,
                (unsigned) cxt->geom.sectors));
-       DBG(CXT, ul_debugobj(cxt, "new log/phy sector size: %u/%u",
+       DBG_OBJ(CXT, cxt, ul_debug("new log/phy sector size: %u/%u",
                (unsigned) cxt->sector_size,
                (unsigned) cxt->phy_sector_size));
 
@@ -464,7 +464,7 @@ int fdisk_reset_device_properties(struct fdisk_context *cxt)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "*** resetting device properties"));
+       DBG_OBJ(CXT, cxt, ul_debug("*** resetting device properties"));
 
        fdisk_zeroize_device_properties(cxt);
        fdisk_discover_topology(cxt);
@@ -488,7 +488,7 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
        assert(cxt);
        assert(cxt->geom.heads == 0);
 
-       DBG(CXT, ul_debugobj(cxt, "%s: discovering geometry...", cxt->dev_path));
+       DBG_OBJ(CXT, cxt, ul_debug("%s: discovering geometry...", cxt->dev_path));
 
        if (fdisk_is_regfile(cxt))
                cxt->total_sectors = cxt->dev_st.st_size / cxt->sector_size;
@@ -501,7 +501,7 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
                blkdev_get_geometry(cxt->dev_fd, &h, &s);
        }
 
-       DBG(CXT, ul_debugobj(cxt, "total sectors: %ju (ioctl=%ju)",
+       DBG_OBJ(CXT, cxt, ul_debug("total sectors: %ju (ioctl=%ju)",
                                (uintmax_t) cxt->total_sectors,
                                (uintmax_t) nsects));
 
@@ -512,7 +512,7 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
        /* obtained heads and sectors */
        recount_geometry(cxt);
 
-       DBG(CXT, ul_debugobj(cxt, "result: C/H/S: %u/%u/%u",
+       DBG_OBJ(CXT, cxt, ul_debug("result: C/H/S: %u/%u/%u",
                               (unsigned) cxt->geom.cylinders,
                               (unsigned) cxt->geom.heads,
                               (unsigned) cxt->geom.sectors));
@@ -527,9 +527,9 @@ int fdisk_discover_topology(struct fdisk_context *cxt)
        assert(cxt);
        assert(cxt->sector_size == 0);
 
-       DBG(CXT, ul_debugobj(cxt, "%s: discovering topology...", cxt->dev_path));
+       DBG_OBJ(CXT, cxt, ul_debug("%s: discovering topology...", cxt->dev_path));
 #ifdef HAVE_LIBBLKID
-       DBG(CXT, ul_debugobj(cxt, "initialize libblkid prober"));
+       DBG_OBJ(CXT, cxt, ul_debug("initialize libblkid prober"));
 
        pr = blkid_new_probe();
        if (pr && blkid_probe_set_device(pr, cxt->dev_fd, 0, 0) == 0) {
@@ -550,11 +550,11 @@ int fdisk_discover_topology(struct fdisk_context *cxt)
                        if (cxt->io_size && cxt->phy_sector_size) {
                                if (cxt->io_size == 33553920) {
                                        /* 33553920 (32 MiB - 512) is always a controller error */
-                                       DBG(CXT, ul_debugobj(cxt, "ignore bad I/O size 33553920"));
+                                       DBG_OBJ(CXT, cxt, ul_debug("ignore bad I/O size 33553920"));
                                        cxt->io_size = cxt->phy_sector_size;
                                } else if ((cxt->io_size % cxt->phy_sector_size) != 0) {
                                        /* ignore optimal I/O if not aligned to phy.sector size */
-                                       DBG(CXT, ul_debugobj(cxt, "ignore misaligned I/O size"));
+                                       DBG_OBJ(CXT, cxt, ul_debug("ignore misaligned I/O size"));
                                        cxt->io_size = cxt->phy_sector_size;
                                }
                        }
@@ -574,9 +574,9 @@ int fdisk_discover_topology(struct fdisk_context *cxt)
        if (!cxt->io_size)
                cxt->io_size = cxt->sector_size;
 
-       DBG(CXT, ul_debugobj(cxt, "result: log/phy sector size: %ld/%ld",
+       DBG_OBJ(CXT, cxt, ul_debug("result: log/phy sector size: %ld/%ld",
                        cxt->sector_size, cxt->phy_sector_size));
-       DBG(CXT, ul_debugobj(cxt, "result: fdisk/optimal/minimal io: %ld/%ld/%ld",
+       DBG_OBJ(CXT, cxt, ul_debug("result: fdisk/optimal/minimal io: %ld/%ld/%ld",
                       cxt->io_size, cxt->optimal_io_size, cxt->min_io_size));
        return 0;
 }
@@ -673,7 +673,7 @@ int fdisk_apply_label_device_properties(struct fdisk_context *cxt)
        int rc = 0;
 
        if (cxt->label && cxt->label->op->reset_alignment) {
-               DBG(CXT, ul_debugobj(cxt, "applying label device properties..."));
+               DBG_OBJ(CXT, cxt, ul_debug("applying label device properties..."));
                rc = cxt->label->op->reset_alignment(cxt);
        }
        return rc;
@@ -695,7 +695,7 @@ int fdisk_reset_alignment(struct fdisk_context *cxt)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "resetting alignment..."));
+       DBG_OBJ(CXT, cxt, ul_debug("resetting alignment..."));
 
        /* default */
        cxt->grain = topology_get_grain(cxt);
@@ -705,7 +705,7 @@ int fdisk_reset_alignment(struct fdisk_context *cxt)
        /* overwrite default by label stuff */
        rc = fdisk_apply_label_device_properties(cxt);
 
-       DBG(CXT, ul_debugobj(cxt, "alignment reset to: "
+       DBG_OBJ(CXT, cxt, ul_debug("alignment reset to: "
                            "first LBA=%ju, last LBA=%ju, grain=%lu [rc=%d]",
                            (uintmax_t) cxt->first_lba, (uintmax_t) cxt->last_lba,
                            cxt->grain, rc));
index 507cc6fc63d749210ba2b13cf7631cbacfcbb943..ac141a79f490d5e04d2d89be9e8f944fe4cbdd19 100644 (file)
@@ -42,7 +42,7 @@ struct fdisk_ask *fdisk_new_ask(void)
        if (!ask)
                return NULL;
 
-       DBG(ASK, ul_debugobj(ask, "alloc"));
+       DBG_OBJ(ASK, ask, ul_debug("alloc"));
        ask->refcount = 1;
        return ask;
 }
@@ -54,7 +54,7 @@ void fdisk_reset_ask(struct fdisk_ask *ask)
        assert(ask);
        free(ask->query);
 
-       DBG(ASK, ul_debugobj(ask, "reset"));
+       DBG_OBJ(ASK, ask, ul_debug("reset"));
        refcount = ask->refcount;
 
        if (fdisk_is_ask(ask, MENU))
@@ -92,7 +92,7 @@ void fdisk_unref_ask(struct fdisk_ask *ask)
 
        if (ask->refcount <= 0) {
                fdisk_reset_ask(ask);
-               DBG(ASK, ul_debugobj(ask, "free"));
+               DBG_OBJ(ASK, ask, ul_debug("free"));
                free(ask);
        }
 }
@@ -141,7 +141,7 @@ int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
        assert(ask);
        assert(cxt);
 
-       DBG(ASK, ul_debugobj(ask, "do_ask for '%s'",
+       DBG_OBJ(ASK, ask, ul_debug("do_ask for '%s'",
                                ask->query ? ask->query :
                                ask->type == FDISK_ASKTYPE_INFO  ? "info" :
                                ask->type == FDISK_ASKTYPE_WARNX ? "warnx" :
@@ -152,18 +152,18 @@ int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
            !(ask->type == FDISK_ASKTYPE_INFO ||
              ask->type == FDISK_ASKTYPE_WARNX ||
              ask->type == FDISK_ASKTYPE_WARN)) {
-               DBG(ASK, ul_debugobj(ask, "dialogs disabled"));
+               DBG_OBJ(ASK, ask, ul_debug("dialogs disabled"));
                return -EINVAL;
        }
 
        if (!cxt->ask_cb) {
-               DBG(ASK, ul_debugobj(ask, "no ask callback specified!"));
+               DBG_OBJ(ASK, ask, ul_debug("no ask callback specified!"));
                return -EINVAL;
        }
 
        rc = cxt->ask_cb(cxt, ask, cxt->ask_data);
 
-       DBG(ASK, ul_debugobj(ask, "do_ask done [rc=%d]", rc));
+       DBG_OBJ(ASK, ask, ul_debug("do_ask done [rc=%d]", rc));
        return rc;
 }
 
@@ -501,7 +501,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew)
                }
        }
 
-       DBG(ASK, ul_debugobj(ask, "ask limits: low: %"PRIu64", high: %"PRIu64", default: %"PRIu64"",
+       DBG_OBJ(ASK, ask, ul_debug("ask limits: low: %"PRIu64", high: %"PRIu64", default: %"PRIu64"",
                                num->low, num->hig, num->dfl));
 
        if (!rc && !wantnew && num->low == num->hig) {
@@ -543,7 +543,7 @@ dont_ask:
                if (*partnum)
                        *partnum -= 1;
        }
-       DBG(ASK, ul_debugobj(ask, "result: %"PRIu64" [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
+       DBG_OBJ(ASK, ask, ul_debug("result: %"PRIu64" [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
        fdisk_unref_ask(ask);
        return rc;
 }
@@ -589,7 +589,7 @@ int fdisk_ask_number(struct fdisk_context *cxt,
        if (!rc)
                *result = fdisk_ask_number_get_result(ask);
 
-       DBG(ASK, ul_debugobj(ask, "result: %ju [rc=%d]\n", *result, rc));
+       DBG_OBJ(ASK, ask, ul_debug("result: %ju [rc=%d]\n", *result, rc));
        fdisk_unref_ask(ask);
        return rc;
 }
@@ -655,7 +655,7 @@ int fdisk_ask_string(struct fdisk_context *cxt,
        if (!rc)
                *result = fdisk_ask_string_get_result(ask);
 
-       DBG(ASK, ul_debugobj(ask, "result: %s [rc=%d]\n", *result, rc));
+       DBG_OBJ(ASK, ask, ul_debug("result: %s [rc=%d]\n", *result, rc));
        fdisk_unref_ask(ask);
        return rc;
 }
@@ -691,7 +691,7 @@ int fdisk_ask_yesno(struct fdisk_context *cxt,
        if (!rc)
                *result = fdisk_ask_yesno_get_result(ask) == 1 ? 1 : 0;
 
-       DBG(ASK, ul_debugobj(ask, "result: %d [rc=%d]\n", *result, rc));
+       DBG_OBJ(ASK, ask, ul_debug("result: %d [rc=%d]\n", *result, rc));
        fdisk_unref_ask(ask);
        return rc;
 }
@@ -759,7 +759,7 @@ int fdisk_ask_menu_set_result(struct fdisk_ask *ask, int key)
        assert(ask);
        assert(fdisk_is_ask(ask, MENU));
        ask->data.menu.result = key;
-       DBG(ASK, ul_debugobj(ask, "menu result: %c\n", key));
+       DBG_OBJ(ASK, ask, ul_debug("menu result: %c\n", key));
        return 0;
 
 }
@@ -873,7 +873,7 @@ int fdisk_ask_menu_add_item(struct fdisk_ask *ask, int key,
                last->next = mi;
        }
 
-       DBG(ASK, ul_debugobj(ask, "new menu item: %c, \"%s\" (%s)\n", mi->key, mi->name, mi->desc));
+       DBG_OBJ(ASK, ask, ul_debug("new menu item: %c, \"%s\" (%s)\n", mi->key, mi->name, mi->desc));
        return 0;
 }
 
index bc46f1f6222dfb2fcf47cfcd749bfb2a97fbecf4..d3a6e88d0a6e3367c46812aa3dea32927de2400b 100644 (file)
@@ -54,7 +54,7 @@ struct fdisk_context *fdisk_new_context(void)
        if (!cxt)
                return NULL;
 
-       DBG(CXT, ul_debugobj(cxt, "alloc"));
+       DBG_OBJ(CXT, cxt, ul_debug("alloc"));
        cxt->dev_fd = -1;
        cxt->refcount = 1;
 
@@ -156,7 +156,7 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
        if (!cxt)
                return NULL;
 
-       DBG(CXT, ul_debugobj(parent, "alloc nested [%p] [name=%s]", cxt, name));
+       DBG_OBJ(CXT, parent, ul_debug("alloc nested [%p] [name=%s]", cxt, name));
        cxt->refcount = 1;
 
        fdisk_ref_context(parent);
@@ -176,14 +176,14 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
        }
 
        if (lb && parent->dev_fd >= 0) {
-               DBG(CXT, ul_debugobj(cxt, "probing for nested %s", lb->name));
+               DBG_OBJ(CXT, cxt, ul_debug("probing for nested %s", lb->name));
 
                cxt->label = lb;
 
                if (lb->op->probe(cxt) == 1)
                        __fdisk_switch_label(cxt, lb);
                else {
-                       DBG(CXT, ul_debugobj(cxt, "not found %s label", lb->name));
+                       DBG_OBJ(CXT, cxt, ul_debug("not found %s label", lb->name));
                        if (lb->op->deinit)
                                lb->op->deinit(lb);
                        cxt->label = NULL;
@@ -236,7 +236,7 @@ struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name)
                    && c_strcasecmp(cxt->labels[i]->name, name) == 0)
                        return cxt->labels[i];
 
-       DBG(CXT, ul_debugobj(cxt, "failed to found %s label driver", name));
+       DBG_OBJ(CXT, cxt, ul_debug("failed to found %s label driver", name));
        return NULL;
 }
 
@@ -298,11 +298,11 @@ int __fdisk_switch_label(struct fdisk_context *cxt, struct fdisk_label *lb)
        if (!lb || !cxt)
                return -EINVAL;
        if (lb->disabled) {
-               DBG(CXT, ul_debugobj(cxt, "*** attempt to switch to disabled label %s -- ignore!", lb->name));
+               DBG_OBJ(CXT, cxt, ul_debug("*** attempt to switch to disabled label %s -- ignore!", lb->name));
                return -EINVAL;
        }
        cxt->label = lb;
-       DBG(CXT, ul_debugobj(cxt, "--> switching context to %s!", lb->name));
+       DBG_OBJ(CXT, cxt, ul_debug("--> switching context to %s!", lb->name));
 
        return fdisk_apply_label_device_properties(cxt);
 }
@@ -543,7 +543,7 @@ static void reset_context(struct fdisk_context *cxt)
 {
        size_t i;
 
-       DBG(CXT, ul_debugobj(cxt, "*** resetting context"));
+       DBG_OBJ(CXT, cxt, ul_debug("*** resetting context"));
 
        /* reset drives' private data */
        for (i = 0; i < cxt->nlabels; i++)
@@ -552,14 +552,14 @@ static void reset_context(struct fdisk_context *cxt)
        if (cxt->parent) {
                /* the first sector may be independent on parent */
                if (cxt->parent->firstsector != cxt->firstsector) {
-                       DBG(CXT, ul_debugobj(cxt, "  firstsector independent on parent (freeing)"));
+                       DBG_OBJ(CXT, cxt, ul_debug("  firstsector independent on parent (freeing)"));
                        free(cxt->firstsector);
                }
        } else {
                /* we close device only in primary context */
                if (cxt->dev_fd > -1 && cxt->is_priv)
                        close(cxt->dev_fd);
-               DBG(CXT, ul_debugobj(cxt, "  freeing firstsector"));
+               DBG_OBJ(CXT, cxt, ul_debug("  freeing firstsector"));
                free(cxt->firstsector);
        }
 
@@ -652,13 +652,13 @@ static int fdisk_assign_fd(struct fdisk_context *cxt, int fd,
        /* Don't report collision if there is already a valid partition table.
         * The bootbits are wiped when we create a *new* partition table only. */
        if (fdisk_is_ptcollision(cxt) && fdisk_has_label(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "ignore old %s", cxt->collision));
+               DBG_OBJ(CXT, cxt, ul_debug("ignore old %s", cxt->collision));
                cxt->pt_collision = 0;
                free(cxt->collision);
                cxt->collision = NULL;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "initialized for %s [%s %s %s]",
+       DBG_OBJ(CXT, cxt, ul_debug("initialized for %s [%s %s %s]",
                              fname,
                              cxt->readonly ? "READ-ONLY" : "READ-WRITE",
                              cxt->is_excl ? "EXCL" : "",
@@ -668,7 +668,7 @@ fail:
        {
                int rc = errno ? -errno : -EINVAL;
                cxt->dev_fd = -1;
-               DBG(CXT, ul_debugobj(cxt, "failed to assign device [rc=%d]", rc));
+               DBG_OBJ(CXT, cxt, ul_debug("failed to assign device [rc=%d]", rc));
                return rc;
        }
 }
@@ -704,7 +704,7 @@ int fdisk_assign_device(struct fdisk_context *cxt,
 {
        int fd, rc, flags = O_CLOEXEC;
 
-       DBG(CXT, ul_debugobj(cxt, "assigning device %s", fname));
+       DBG_OBJ(CXT, cxt, ul_debug("assigning device %s", fname));
        assert(cxt);
 
        if (readonly)
@@ -722,7 +722,7 @@ int fdisk_assign_device(struct fdisk_context *cxt,
 
        if (fd < 0) {
                rc = -errno;
-               DBG(CXT, ul_debugobj(cxt, "failed to assign device [rc=%d]", rc));
+               DBG_OBJ(CXT, cxt, ul_debug("failed to assign device [rc=%d]", rc));
                return rc;
        }
 
@@ -751,7 +751,7 @@ int fdisk_assign_device(struct fdisk_context *cxt,
 int fdisk_assign_device_by_fd(struct fdisk_context *cxt, int fd,
                        const char *fname, int readonly)
 {
-       DBG(CXT, ul_debugobj(cxt, "assign by fd"));
+       DBG_OBJ(CXT, cxt, ul_debug("assign by fd"));
        return fdisk_assign_fd(cxt, fd, fname, readonly, 0, 0);
 }
 
@@ -779,7 +779,7 @@ int fdisk_deassign_device(struct fdisk_context *cxt, int nosync)
                return rc;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "de-assigning device %s", cxt->dev_path));
+       DBG_OBJ(CXT, cxt, ul_debug("de-assigning device %s", cxt->dev_path));
 
        if (cxt->readonly && cxt->is_priv)
                close(cxt->dev_fd);
@@ -828,7 +828,7 @@ int fdisk_reassign_device(struct fdisk_context *cxt)
        assert(cxt);
        assert(cxt->dev_fd >= 0);
 
-       DBG(CXT, ul_debugobj(cxt, "re-assigning device %s", cxt->dev_path));
+       DBG_OBJ(CXT, cxt, ul_debug("re-assigning device %s", cxt->dev_path));
 
        devname = strdup(cxt->dev_path);
        if (!devname)
@@ -870,7 +870,7 @@ int fdisk_reread_partition_table(struct fdisk_context *cxt)
        if (!S_ISBLK(cxt->dev_st.st_mode))
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl"));
+       DBG_OBJ(CXT, cxt, ul_debug("calling re-read ioctl"));
        sync();
 #ifdef BLKRRPART
        fdisk_info(cxt, _("Calling ioctl() to re-read partition table."));
@@ -934,7 +934,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
        size_t nparts, i, nadds = 0, nupds = 0, nrems = 0;
        unsigned int ssf;
 
-       DBG(CXT, ul_debugobj(cxt, "rereading changes"));
+       DBG_OBJ(CXT, cxt, ul_debug("rereading changes"));
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
 
@@ -971,7 +971,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
 
        for (i = 0; i < nrems; i++) {
                pa = rem[i];
-               DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_DEL_PARTITION", pa->partno));
+               DBG_OBJ(PART, pa, ul_debug("#%zu calling BLKPG_DEL_PARTITION", pa->partno));
                if (partx_del_partition(cxt->dev_fd, pa->partno + 1) != 0) {
                        fdisk_warn(cxt, _("Failed to remove partition %zu from system"), pa->partno + 1);
                        err++;
@@ -979,7 +979,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
        }
        for (i = 0; i < nupds; i++) {
                pa = upd[i];
-               DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_RESIZE_PARTITION", pa->partno));
+               DBG_OBJ(PART, pa, ul_debug("#%zu calling BLKPG_RESIZE_PARTITION", pa->partno));
                if (partx_resize_partition(cxt->dev_fd, pa->partno + 1,
                                           pa->start * ssf, pa->size * ssf) != 0) {
                        fdisk_warn(cxt, _("Failed to update system information about partition %zu"), pa->partno + 1);
@@ -992,7 +992,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
                pa = add[i];
                sz = pa->size * ssf;
 
-               DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_ADD_PARTITION", pa->partno));
+               DBG_OBJ(PART, pa, ul_debug("#%zu calling BLKPG_ADD_PARTITION", pa->partno));
 
                if (fdisk_is_label(cxt, DOS) && fdisk_partition_is_container(pa))
                        /* Let's follow the Linux kernel and reduce
@@ -1043,7 +1043,7 @@ int fdisk_device_is_used(struct fdisk_context *cxt)
             cxt->is_excl ? 0 :
             cxt->is_priv ? 1 : 0;
 
-       DBG(CXT, ul_debugobj(cxt, "device used: %s [read-only=%d, excl=%d, priv:%d]",
+       DBG_OBJ(CXT, cxt, ul_debug("device used: %s [read-only=%d, excl=%d, priv:%d]",
                                rc ? "TRUE" : "FALSE", cxt->readonly,
                                cxt->is_excl, cxt->is_priv));
        return rc;
@@ -1090,7 +1090,7 @@ void fdisk_unref_context(struct fdisk_context *cxt)
 
        cxt->refcount--;
        if (cxt->refcount <= 0) {
-               DBG(CXT, ul_debugobj(cxt, "freeing context %p for %s", cxt, cxt->dev_path));
+               DBG_OBJ(CXT, cxt, ul_debug("freeing context %p for %s", cxt, cxt->dev_path));
 
                reset_context(cxt);     /* this is sensitive to parent<->child relationship! */
 
@@ -1196,7 +1196,7 @@ int fdisk_set_unit(struct fdisk_context *cxt, const char *str)
        else if (strcmp(str, "sector") == 0 || strcmp(str, "sectors") == 0)
                cxt->display_in_cyl_units = 0;
 
-       DBG(CXT, ul_debugobj(cxt, "display unit: %s", fdisk_get_unit(cxt, 0)));
+       DBG_OBJ(CXT, cxt, ul_debug("display unit: %s", fdisk_get_unit(cxt, 0)));
        return 0;
 }
 
@@ -1363,7 +1363,7 @@ fdisk_sector_t fdisk_get_first_lba(struct fdisk_context *cxt)
 fdisk_sector_t fdisk_set_first_lba(struct fdisk_context *cxt, fdisk_sector_t lba)
 {
        assert(cxt);
-       DBG(CXT, ul_debugobj(cxt, "setting first LBA from %ju to %ju",
+       DBG_OBJ(CXT, cxt, ul_debug("setting first LBA from %ju to %ju",
                        (uintmax_t) cxt->first_lba, (uintmax_t) lba));
        cxt->first_lba = lba;
        return 0;
index e3e57929a46465d933149a0686e44af8ab644713..7927d85b4ef2edefb6b3eeb368af7ac120d2a6fe 100644 (file)
 #define LIBFDISK_DEBUG_ALL     0xFFFF
 
 UL_DEBUG_DECLARE_MASK(libfdisk);
-#define DBG(m, x)      __UL_DBG(libfdisk, LIBFDISK_DEBUG_, m, x)
-#define ON_DBG(m, x)   __UL_DBG_CALL(libfdisk, LIBFDISK_DEBUG_, m, x)
-#define DBG_FLUSH      __UL_DBG_FLUSH(libfdisk, LIBFDISK_DEBUG_)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(libfdisk)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(libfdisk, LIBFDISK_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(libfdisk, LIBFDISK_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(libfdisk, LIBFDISK_DEBUG_, m, x)
+#define DBG_FLUSH              __UL_DBG_FLUSH(libfdisk, LIBFDISK_DEBUG_)
 
 /*
  * NLS -- the library has to be independent on main program, so define
index 9e2f44ca124d753906693a22e7da0448fb128988..19f3288665c35d57493a6f959af81f9da41581fd 100644 (file)
@@ -44,7 +44,7 @@ struct fdisk_labelitem *fdisk_new_labelitem(void)
                return NULL;
 
        li->refcount = 1;
-       DBG(ITEM, ul_debugobj(li, "alloc"));
+       DBG_OBJ(ITEM, li, ul_debug("alloc"));
        return li;
 }
 
@@ -107,7 +107,7 @@ void fdisk_unref_labelitem(struct fdisk_labelitem *li)
 
        li->refcount--;
        if (li->refcount <= 0) {
-               DBG(ITEM, ul_debugobj(li, "free"));
+               DBG_OBJ(ITEM, li, ul_debug("free"));
                fdisk_reset_labelitem(li);
                free(li);
        }
index 04afe8d26cb3f6609f7bdb7aa0bf92cb6c886a05..e7bd7b9ebdb184571f3179a3cb3afc0c67ba036b 100644 (file)
@@ -41,10 +41,10 @@ int fdisk_probe_labels(struct fdisk_context *cxt)
                if (!lb->op->probe)
                        continue;
                if (lb->disabled) {
-                       DBG(CXT, ul_debugobj(cxt, "%s: disabled -- ignore", lb->name));
+                       DBG_OBJ(CXT, cxt, ul_debug("%s: disabled -- ignore", lb->name));
                        continue;
                }
-               DBG(CXT, ul_debugobj(cxt, "probing for %s", lb->name));
+               DBG_OBJ(CXT, cxt, ul_debug("probing for %s", lb->name));
 
                cxt->label = lb;
                rc = lb->op->probe(cxt);
@@ -60,7 +60,7 @@ int fdisk_probe_labels(struct fdisk_context *cxt)
                return 0;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "no label found"));
+       DBG_OBJ(CXT, cxt, ul_debug("no label found"));
        return 1; /* not found */
 }
 
@@ -388,7 +388,7 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
                        return rc;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "creating a new %s label", lb->name));
+       DBG_OBJ(CXT, cxt, ul_debug("creating a new %s label", lb->name));
        return lb->op->create(cxt);
 }
 
@@ -424,7 +424,7 @@ int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name,
        if (!cxt->label->op->locate)
                return -ENOSYS;
 
-       DBG(CXT, ul_debugobj(cxt, "locating %d chunk of %s.", n, cxt->label->name));
+       DBG_OBJ(CXT, cxt, ul_debug("locating %d chunk of %s.", n, cxt->label->name));
        return cxt->label->op->locate(cxt, n, name, offset, size);
 }
 
@@ -444,7 +444,7 @@ int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id)
        if (!cxt || !cxt->label || !id)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "asking for disk %s ID", cxt->label->name));
+       DBG_OBJ(CXT, cxt, ul_debug("asking for disk %s ID", cxt->label->name));
 
        rc = fdisk_get_disklabel_item(cxt, FDISK_LABELITEM_ID, &item);
        if (rc == 0) {
@@ -476,7 +476,7 @@ int fdisk_get_disklabel_item(struct fdisk_context *cxt, int id, struct fdisk_lab
 
        fdisk_reset_labelitem(item);
        item->id = id;
-       DBG(CXT, ul_debugobj(cxt, "asking for disk %s item %d", cxt->label->name, item->id));
+       DBG_OBJ(CXT, cxt, ul_debug("asking for disk %s item %d", cxt->label->name, item->id));
 
        if (!cxt->label->op->get_item)
                return -ENOSYS;
@@ -497,7 +497,7 @@ int fdisk_set_disklabel_id(struct fdisk_context *cxt)
        if (!cxt->label->op->set_id)
                return -ENOSYS;
 
-       DBG(CXT, ul_debugobj(cxt, "setting %s disk ID", cxt->label->name));
+       DBG_OBJ(CXT, cxt, ul_debug("setting %s disk ID", cxt->label->name));
        return cxt->label->op->set_id(cxt, NULL);
 }
 
@@ -517,7 +517,7 @@ int fdisk_set_disklabel_id_from_string(struct fdisk_context *cxt, const char *st
        if (!cxt->label->op->set_id)
                return -ENOSYS;
 
-       DBG(CXT, ul_debugobj(cxt, "setting %s disk ID from '%s'", cxt->label->name, str));
+       DBG_OBJ(CXT, cxt, ul_debug("setting %s disk ID from '%s'", cxt->label->name, str));
        return cxt->label->op->set_id(cxt, str);
 }
 
@@ -545,7 +545,7 @@ int fdisk_set_partition_type(struct fdisk_context *cxt,
                        return -ENOMEM;
                fdisk_partition_set_type(pa, t);
 
-               DBG(CXT, ul_debugobj(cxt, "partition: %zd: set type", partnum));
+               DBG_OBJ(CXT, cxt, ul_debug("partition: %zd: set type", partnum));
                rc = cxt->label->op->set_part(cxt, partnum, pa);
                fdisk_unref_partition(pa);
                return rc;
@@ -576,7 +576,7 @@ int fdisk_toggle_partition_flag(struct fdisk_context *cxt,
 
        rc = cxt->label->op->part_toggle_flag(cxt, partnum, flag);
 
-       DBG(CXT, ul_debugobj(cxt, "partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc));
+       DBG_OBJ(CXT, cxt, ul_debug("partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc));
        return rc;
 }
 
index 9a5614d2154a7c756baa74a1c4f46e95e2887047..5e94ec36e2f500af9566b8f8429bcc6450b55c42 100644 (file)
@@ -45,7 +45,7 @@ struct fdisk_partition *fdisk_new_partition(void)
 
        pa->refcount = 1;
        init_partition(pa);
-       DBG(PART, ul_debugobj(pa, "alloc"));
+       DBG_OBJ(PART, pa, ul_debug("alloc"));
        return pa;
 }
 
@@ -62,7 +62,7 @@ void fdisk_reset_partition(struct fdisk_partition *pa)
        if (!pa)
                return;
 
-       DBG(PART, ul_debugobj(pa, "reset"));
+       DBG_OBJ(PART, pa, ul_debug("reset"));
        ref = pa->refcount;
 
        fdisk_unref_parttype(pa->type);
@@ -160,7 +160,7 @@ void fdisk_unref_partition(struct fdisk_partition *pa)
        if (pa->refcount <= 0) {
                list_del(&pa->parts);
                fdisk_reset_partition(pa);
-               DBG(PART, ul_debugobj(pa, "free"));
+               DBG_OBJ(PART, pa, ul_debug("free"));
                free(pa);
        }
 }
@@ -746,7 +746,7 @@ int fdisk_partition_next_partno(
        if (pa && pa->partno_follow_default) {
                size_t i;
 
-               DBG(PART, ul_debugobj(pa, "next partno (follow default)"));
+               DBG_OBJ(PART, pa, ul_debug("next partno (follow default)"));
 
                for (i = 0; i < cxt->label->nparts_max; i++) {
                        if (!fdisk_is_partition_used(cxt, i)) {
@@ -760,7 +760,7 @@ int fdisk_partition_next_partno(
 
        if (pa && fdisk_partition_has_partno(pa)) {
 
-               DBG(PART, ul_debugobj(pa, "next partno (specified=%zu)", pa->partno));
+               DBG_OBJ(PART, pa, ul_debug("next partno (specified=%zu)", pa->partno));
 
                if (pa->partno >= cxt->label->nparts_max ||
                    fdisk_is_partition_used(cxt, pa->partno))
@@ -780,7 +780,7 @@ static int probe_partition_content(struct fdisk_context *cxt, struct fdisk_parti
 {
        int rc = 1;     /* nothing */
 
-       DBG(PART, ul_debugobj(pa, "start probe #%zu partition [cxt %p] >>>", pa->partno, cxt));
+       DBG_OBJ(PART, pa, ul_debug("start probe #%zu partition [cxt %p] >>>", pa->partno, cxt));
 
        /* zeroize the current setting */
        strdup_to_struct_member(pa, fstype, NULL);
@@ -799,7 +799,7 @@ static int probe_partition_content(struct fdisk_context *cxt, struct fdisk_parti
                if (!pr)
                        goto done;
 
-               DBG(PART, ul_debugobj(pa, "blkid prober: %p", pr));
+               DBG_OBJ(PART, pa, ul_debug("blkid prober: %p", pr));
 
                blkid_probe_enable_superblocks(pr, 1);
                blkid_probe_set_superblocks_flags(pr,
@@ -834,7 +834,7 @@ static int probe_partition_content(struct fdisk_context *cxt, struct fdisk_parti
 #endif /* HAVE_LIBBLKID */
 
 done:
-       DBG(PART, ul_debugobj(pa, "<<< end probe #%zu partition[cxt %p, rc=%d]", pa->partno, cxt, rc));
+       DBG_OBJ(PART, pa, ul_debug("<<< end probe #%zu partition[cxt %p, rc=%d]", pa->partno, cxt, rc));
        return rc;
 }
 
@@ -1086,7 +1086,7 @@ static int resize_get_first_possible(
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
 
        *start = 0;
-       DBG(TAB, ul_debugobj(tb, "checking first possible before start=%ju", (uintmax_t) cur->start));
+       DBG_OBJ(TAB, tb, ul_debug("checking first possible before start=%ju", (uintmax_t) cur->start));
 
 
        while (fdisk_table_next_partition(tb, &itr, &pa) == 0) {
@@ -1094,7 +1094,7 @@ static int resize_get_first_possible(
                if (pa->start > cur->start || pa == cur)
                        break;
 
-               DBG(TAB, ul_debugobj(tb, " checking entry %p [partno=%zu start=%ju, end=%ju, size=%ju%s%s%s]",
+               DBG_OBJ(TAB, tb, ul_debug(" checking entry %p [partno=%zu start=%ju, end=%ju, size=%ju%s%s%s]",
                        pa,
                        fdisk_partition_get_partno(pa),
                        (uintmax_t) fdisk_partition_get_start(pa),
@@ -1106,32 +1106,32 @@ static int resize_get_first_possible(
 
 
                if (!fdisk_partition_is_freespace(pa)) {
-                       DBG(TAB, ul_debugobj(tb, "  ignored (no freespace)"));
+                       DBG_OBJ(TAB, tb, ul_debug("  ignored (no freespace)"));
                        first = NULL;
                        continue;
                }
                if (!fdisk_partition_has_start(pa) || !fdisk_partition_has_size(pa)) {
-                       DBG(TAB, ul_debugobj(tb, "  ignored (no start/size)"));
+                       DBG_OBJ(TAB, tb, ul_debug("  ignored (no start/size)"));
                        first = NULL;
                        continue;
                }
                /* The current is nested, free space has to be nested within the same parent */
                if (fdisk_partition_is_nested(cur)
                    && pa->parent_partno != cur->parent_partno) {
-                       DBG(TAB, ul_debugobj(tb, "  ignore (nested required)"));
+                       DBG_OBJ(TAB, tb, ul_debug("  ignore (nested required)"));
                        first = NULL;
                        continue;
                }
                if (pa->start + pa->size <= cur->start) {
                        first = pa;
-                       DBG(TAB, ul_debugobj(tb, "  entry usable"));
+                       DBG_OBJ(TAB, tb, ul_debug("  entry usable"));
                }
        }
 
        if (first)
                *start = first->start;
        else
-               DBG(PART, ul_debugobj(cur, "resize: nothing usable before %ju", (uintmax_t) cur->start));
+               DBG_OBJ(PART, cur, ul_debug("resize: nothing usable before %ju", (uintmax_t) cur->start));
 
        return first ? 0 : -1;
 }
@@ -1158,12 +1158,12 @@ static int resize_get_last_possible(
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
 
        *maxsz = 0;
-       DBG(TAB, ul_debugobj(tb, "checking last possible for start=%ju", (uintmax_t) start));
+       DBG_OBJ(TAB, tb, ul_debug("checking last possible for start=%ju", (uintmax_t) start));
 
 
        while (fdisk_table_next_partition(tb, &itr, &pa) == 0) {
 
-               DBG(TAB, ul_debugobj(tb, " checking entry %p [partno=%zu start=%ju, end=%ju, size=%ju%s%s%s]",
+               DBG_OBJ(TAB, tb, ul_debug(" checking entry %p [partno=%zu start=%ju, end=%ju, size=%ju%s%s%s]",
                        pa,
                        fdisk_partition_get_partno(pa),
                        (uintmax_t) fdisk_partition_get_start(pa),
@@ -1176,52 +1176,52 @@ static int resize_get_last_possible(
                if (!fdisk_partition_has_start(pa) ||
                    !fdisk_partition_has_size(pa) ||
                    (fdisk_partition_is_container(pa) && pa != cur)) {
-                       DBG(TAB, ul_debugobj(tb, "  ignored (no start/size or container)"));
+                       DBG_OBJ(TAB, tb, ul_debug("  ignored (no start/size or container)"));
                        continue;
                }
 
                if (fdisk_partition_is_nested(pa)
                    && fdisk_partition_is_container(cur)
                    && pa->parent_partno == cur->partno) {
-                       DBG(TAB, ul_debugobj(tb, "  ignore (nested child of the current partition)"));
+                       DBG_OBJ(TAB, tb, ul_debug("  ignore (nested child of the current partition)"));
                        continue;
                }
 
                /* The current is nested, free space has to be nested within the same parent */
                if (fdisk_partition_is_nested(cur)
                    && pa->parent_partno != cur->parent_partno) {
-                       DBG(TAB, ul_debugobj(tb, "  ignore (nested required)"));
+                       DBG_OBJ(TAB, tb, ul_debug("  ignore (nested required)"));
                        continue;
                }
 
                if (!last) {
                        if (start >= pa->start &&  start < pa->start + pa->size) {
                                if (fdisk_partition_is_freespace(pa) || pa == cur) {
-                                       DBG(TAB, ul_debugobj(tb, "  accepted as last"));
+                                       DBG_OBJ(TAB, tb, ul_debug("  accepted as last"));
                                        last = pa;
                                } else {
-                                       DBG(TAB, ul_debugobj(tb, "  failed to set last"));
+                                       DBG_OBJ(TAB, tb, ul_debug("  failed to set last"));
                                        break;
                                }
 
 
                                *maxsz = pa->size - (start - pa->start);
-                               DBG(TAB, ul_debugobj(tb, "  new max=%ju", (uintmax_t) *maxsz));
+                               DBG_OBJ(TAB, tb, ul_debug("  new max=%ju", (uintmax_t) *maxsz));
                        }
                } else if (!fdisk_partition_is_freespace(pa) && pa != cur) {
-                       DBG(TAB, ul_debugobj(tb, "  no free space behind current"));
+                       DBG_OBJ(TAB, tb, ul_debug("  no free space behind current"));
                        break;
                } else {
                        last = pa;
                        *maxsz = pa->size - (start - pa->start);
-                       DBG(TAB, ul_debugobj(tb, "  new max=%ju (last updated)", (uintmax_t) *maxsz));
+                       DBG_OBJ(TAB, tb, ul_debug("  new max=%ju (last updated)", (uintmax_t) *maxsz));
                }
        }
 
        if (last)
-               DBG(PART, ul_debugobj(cur, "resize: max size=%ju", (uintmax_t) *maxsz));
+               DBG_OBJ(PART, cur, ul_debug("resize: max size=%ju", (uintmax_t) *maxsz));
        else
-               DBG(PART, ul_debugobj(cur, "resize: nothing usable after %ju", (uintmax_t) start));
+               DBG_OBJ(PART, cur, ul_debug("resize: nothing usable after %ju", (uintmax_t) start));
 
        return last ? 0 : -1;
 }
@@ -1239,7 +1239,7 @@ static int recount_resize(
        struct fdisk_table *tb = NULL;
        int rc;
 
-       DBG(PART, ul_debugobj(tpl, ">>> resize requested"));
+       DBG_OBJ(PART, tpl, ul_debug(">>> resize requested"));
 
        FDISK_INIT_UNDEF(start);
        FDISK_INIT_UNDEF(size);
@@ -1261,7 +1261,7 @@ static int recount_resize(
 
        fdisk_table_sort_partitions(tb, fdisk_partition_cmp_start);
 
-       DBG(PART, ul_debugobj(tpl, "resize partition partno=%zu in table:", partno));
+       DBG_OBJ(PART, tpl, ul_debug("resize partition partno=%zu in table:", partno));
        ON_DBG(PART, fdisk_debug_print_table(tb));
 
        cur = fdisk_table_get_partition_by_partno(tb, partno);
@@ -1280,7 +1280,7 @@ static int recount_resize(
                } else
                        start += fdisk_partition_get_start(tpl);
 
-               DBG(PART, ul_debugobj(tpl, "resize: moving start %s relative, new start: %ju",
+               DBG_OBJ(PART, tpl, ul_debug("resize: moving start %s relative, new start: %ju",
                                tpl->movestart == FDISK_MOVE_DOWN  ? "DOWN" : "UP", (uintmax_t)start));
 
        /* 1b) set new start - try freespace before the current partition */
@@ -1289,13 +1289,13 @@ static int recount_resize(
                if (resize_get_first_possible(tb, cur, &start) != 0)
                        goto erange;
 
-               DBG(PART, ul_debugobj(tpl, "resize: moving start DOWN (first possible), new start: %ju",
+               DBG_OBJ(PART, tpl, ul_debug("resize: moving start DOWN (first possible), new start: %ju",
                                (uintmax_t)start));
 
        /* 1c) set new start - absolute number */
        } else if (fdisk_partition_has_start(tpl)) {
                start = fdisk_partition_get_start(tpl);
-               DBG(PART, ul_debugobj(tpl, "resize: moving start to absolute offset: %ju",
+               DBG_OBJ(PART, tpl, ul_debug("resize: moving start to absolute offset: %ju",
                                      (uintmax_t)start));
        }
 
@@ -1304,24 +1304,24 @@ static int recount_resize(
                struct fdisk_partition *area = area_by_offset(tb, cur, start);
 
                if (area == cur)
-                       DBG(PART, ul_debugobj(tpl, "resize: start points to the current partition"));
+                       DBG_OBJ(PART, tpl, ul_debug("resize: start points to the current partition"));
                else if (area && fdisk_partition_is_freespace(area))
-                       DBG(PART, ul_debugobj(tpl, "resize: start points to freespace"));
+                       DBG_OBJ(PART, tpl, ul_debug("resize: start points to freespace"));
                else if (!area && start >= cxt->first_lba && start < cxt->first_lba + (cxt->grain / cxt->sector_size))
-                       DBG(PART, ul_debugobj(tpl, "resize: start points before first partition"));
+                       DBG_OBJ(PART, tpl, ul_debug("resize: start points before first partition"));
                else {
-                       DBG(PART, ul_debugobj(tpl, "resize: start verification failed"));
+                       DBG_OBJ(PART, tpl, ul_debug("resize: start verification failed"));
                        goto erange;
                }
        } else {
                /* no change, start points to the current partition */
-               DBG(PART, ul_debugobj(tpl, "resize: start unchanged"));
+               DBG_OBJ(PART, tpl, ul_debug("resize: start unchanged"));
                start = fdisk_partition_get_start(cur);
        }
 
        /* 3a) set new size -- reduce */
        if (tpl->resize == FDISK_RESIZE_REDUCE && fdisk_partition_has_size(tpl)) {
-               DBG(PART, ul_debugobj(tpl, "resize: reduce"));
+               DBG_OBJ(PART, tpl, ul_debug("resize: reduce"));
                size = fdisk_partition_get_size(cur);
                if (fdisk_partition_get_size(tpl) > size)
                        goto erange;
@@ -1329,19 +1329,19 @@ static int recount_resize(
 
        /* 3b) set new size -- enlarge */
        } else if (tpl->resize == FDISK_RESIZE_ENLARGE && fdisk_partition_has_size(tpl)) {
-               DBG(PART, ul_debugobj(tpl, "resize: enlarge"));
+               DBG_OBJ(PART, tpl, ul_debug("resize: enlarge"));
                size = fdisk_partition_get_size(cur);
                size += fdisk_partition_get_size(tpl);
 
        /* 3c) set new size -- no size specified, enlarge to all freespace */
        } else if (tpl->resize == FDISK_RESIZE_ENLARGE) {
-               DBG(PART, ul_debugobj(tpl, "resize: enlarge to all possible"));
+               DBG_OBJ(PART, tpl, ul_debug("resize: enlarge to all possible"));
                if (resize_get_last_possible(tb, cur, start, &size))
                        goto erange;
 
        /* 3d) set new size -- absolute number */
        } else if (fdisk_partition_has_size(tpl)) {
-               DBG(PART, ul_debugobj(tpl, "resize: new absolute size"));
+               DBG_OBJ(PART, tpl, ul_debug("resize: new absolute size"));
                size = fdisk_partition_get_size(tpl);
        }
 
@@ -1353,18 +1353,18 @@ static int recount_resize(
 
                if (resize_get_last_possible(tb, cur, start, &maxsz))
                        goto erange;
-               DBG(PART, ul_debugobj(tpl, "resize: size=%ju, max=%ju",
+               DBG_OBJ(PART, tpl, ul_debug("resize: size=%ju, max=%ju",
                                        (uintmax_t) xsize, (uintmax_t) maxsz));
                if (xsize > maxsz)
                        goto erange;
        }
 
        if (FDISK_IS_UNDEF(size)) {
-               DBG(PART, ul_debugobj(tpl, "resize: size unchanged (undefined)"));
+               DBG_OBJ(PART, tpl, ul_debug("resize: size unchanged (undefined)"));
        }
 
 
-       DBG(PART, ul_debugobj(tpl, "<<< resize: SUCCESS: start %ju->%ju; size %ju->%ju",
+       DBG_OBJ(PART, tpl, ul_debug("<<< resize: SUCCESS: start %ju->%ju; size %ju->%ju",
                        (uintmax_t) fdisk_partition_get_start(cur), (uintmax_t) start,
                        (uintmax_t) fdisk_partition_get_size(cur), (uintmax_t) size));
        res->start = start;
@@ -1372,7 +1372,7 @@ static int recount_resize(
        fdisk_unref_table(tb);
        return 0;
 erange:
-       DBG(PART, ul_debugobj(tpl, "<<< resize: FAILED"));
+       DBG_OBJ(PART, tpl, ul_debug("<<< resize: FAILED"));
        fdisk_warnx(cxt, _("Failed to resize partition #%zu."), partno + 1);
        fdisk_unref_table(tb);
        return -ERANGE;
@@ -1424,7 +1424,7 @@ int fdisk_set_partition(struct fdisk_context *cxt, size_t partno,
                        goto done;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "setting partition %zu %p (start=%ju, end=%ju, size=%ju)",
+       DBG_OBJ(CXT, cxt, ul_debug("setting partition %zu %p (start=%ju, end=%ju, size=%ju)",
                    partno, xpa,
                    (uintmax_t) fdisk_partition_get_start(xpa),
                    (uintmax_t) fdisk_partition_get_end(xpa),
@@ -1444,7 +1444,7 @@ int fdisk_set_partition(struct fdisk_context *cxt, size_t partno,
        if (!rc && wipe)
                fdisk_wipe_partition(cxt, partno, TRUE);
 done:
-       DBG(CXT, ul_debugobj(cxt, "set_partition() rc=%d", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("set_partition() rc=%d", rc));
        if (xpa != pa)
                fdisk_unref_partition(xpa);
        return rc;
@@ -1532,24 +1532,24 @@ int fdisk_add_partition(struct fdisk_context *cxt,
 
        if (pa) {
                pa->fs_probed = 0;
-               DBG(CXT, ul_debugobj(cxt, "adding new partition %p", pa));
+               DBG_OBJ(CXT, cxt, ul_debug("adding new partition %p", pa));
                if (fdisk_partition_has_start(pa))
-                       DBG(CXT, ul_debugobj(cxt, "     start: %ju", (uintmax_t) fdisk_partition_get_start(pa)));
+                       DBG_OBJ(CXT, cxt, ul_debug("     start: %ju", (uintmax_t) fdisk_partition_get_start(pa)));
                if (fdisk_partition_has_end(pa))
-                       DBG(CXT, ul_debugobj(cxt, "       end: %ju", (uintmax_t) fdisk_partition_get_end(pa)));
+                       DBG_OBJ(CXT, cxt, ul_debug("       end: %ju", (uintmax_t) fdisk_partition_get_end(pa)));
                if (fdisk_partition_has_size(pa))
-                       DBG(CXT, ul_debugobj(cxt, "      size: %ju", (uintmax_t) fdisk_partition_get_size(pa)));
+                       DBG_OBJ(CXT, cxt, ul_debug("      size: %ju", (uintmax_t) fdisk_partition_get_size(pa)));
 
-               DBG(CXT, ul_debugobj(cxt,         "  defaults: start=%s, end=%s, partno=%s",
+               DBG_OBJ(CXT, cxt, ul_debug(        "  defaults: start=%s, end=%s, partno=%s",
                            pa->start_follow_default ? "yes" : "no",
                            pa->end_follow_default ? "yes" : "no",
                            pa->partno_follow_default ? "yes" : "no"));
        } else
-               DBG(CXT, ul_debugobj(cxt, "adding partition"));
+               DBG_OBJ(CXT, cxt, ul_debug("adding partition"));
 
        rc = cxt->label->op->add_part(cxt, pa, partno);
 
-       DBG(CXT, ul_debugobj(cxt, "add partition done (rc=%d)", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("add partition done (rc=%d)", rc));
        return rc;
 }
 
@@ -1571,7 +1571,7 @@ int fdisk_delete_partition(struct fdisk_context *cxt, size_t partno)
 
        fdisk_wipe_partition(cxt, partno, 0);
 
-       DBG(CXT, ul_debugobj(cxt, "deleting %s partition number %zd",
+       DBG_OBJ(CXT, cxt, ul_debug("deleting %s partition number %zd",
                                cxt->label->name, partno));
        return cxt->label->op->del_part(cxt, partno);
 }
index 8e36ada74c7d64b9c596f511fad61f00ef3dc2f0..13fc734f0e786c7f94de86dc0884e8c92671c073 100644 (file)
@@ -32,7 +32,7 @@ struct fdisk_parttype *fdisk_new_parttype(void)
 
        t->refcount = 1;
        t->flags = FDISK_PARTTYPE_ALLOCATED;
-       DBG(PARTTYPE, ul_debugobj(t, "alloc"));
+       DBG_OBJ(PARTTYPE, t, ul_debug("alloc"));
        return t;
 }
 
@@ -62,7 +62,7 @@ void fdisk_unref_parttype(struct fdisk_parttype *t)
 
        t->refcount--;
        if (t->refcount <= 0) {
-               DBG(PARTTYPE, ul_debugobj(t, "free"));
+               DBG_OBJ(PARTTYPE, t, ul_debug("free"));
                free(t->typestr);
                free(t->name);
                free(t);
@@ -337,26 +337,26 @@ static struct fdisk_parttype *parttype_from_data(
        if (!lb->nparttypes)
                return NULL;
 
-       DBG(LABEL, ul_debugobj(lb, " parsing '%s' data", str));
+       DBG_OBJ(LABEL, lb, ul_debug(" parsing '%s' data", str));
        types = lb->parttypes;
 
        if (types[0].typestr == NULL) {
                unsigned int code;
 
-               DBG(LABEL, ul_debugobj(lb, " +hex"));
+               DBG_OBJ(LABEL, lb, ul_debug(" +hex"));
 
                errno = 0;
                code = strtol(str, &end, 16);
 
                if (errno || *end != '\0') {
-                       DBG(LABEL, ul_debugobj(lb, "  failed: %m"));
+                       DBG_OBJ(LABEL, lb, ul_debug("  failed: %m"));
                        return NULL;
                }
                if (xcode)
                        *xcode = code;
                ret = fdisk_label_get_parttype_from_code(lb, code);
        } else {
-               DBG(LABEL, ul_debugobj(lb, " +string"));
+               DBG_OBJ(LABEL, lb, ul_debug(" +string"));
 
                /* maybe specified by type string (e.g. UUID) */
                ret = fdisk_label_get_parttype_from_string(lb, str);
@@ -376,7 +376,7 @@ static struct fdisk_parttype *parttype_from_data(
        }
 
        if (ret)
-               DBG(PARTTYPE, ul_debugobj(ret, " result '%s'", ret->name));
+               DBG_OBJ(PARTTYPE, ret, ul_debug(" result '%s'", ret->name));
        return ret;
 }
 
@@ -386,7 +386,7 @@ static struct fdisk_parttype *parttype_from_shortcut(
 {
        size_t i;
 
-       DBG(LABEL, ul_debugobj(lb, " parsing '%s' shortcut", str));
+       DBG_OBJ(LABEL, lb, ul_debug(" parsing '%s' shortcut", str));
 
        for (i = 0; i < lb->nparttype_cuts; i++) {
                const struct fdisk_shortcut *sc = &lb->parttype_cuts[i];
@@ -405,7 +405,7 @@ static struct fdisk_parttype *parttype_from_alias(
 {
        size_t i;
 
-       DBG(LABEL, ul_debugobj(lb, " parsing '%s' alias", str));
+       DBG_OBJ(LABEL, lb, ul_debug(" parsing '%s' alias", str));
 
        for (i = 0; i < lb->nparttype_cuts; i++) {
                const struct fdisk_shortcut *sc = &lb->parttype_cuts[i];
@@ -424,7 +424,7 @@ static struct fdisk_parttype *parttype_from_name(
 {
        size_t i;
 
-       DBG(LABEL, ul_debugobj(lb, " parsing '%s' name", str));
+       DBG_OBJ(LABEL, lb, ul_debug(" parsing '%s' name", str));
 
        for (i = 0; i < lb->nparttypes; i++) {
                const char *name = lb->parttypes[i].name;
@@ -464,7 +464,7 @@ struct fdisk_parttype *fdisk_label_advparse_parttype(
        if (!lb || !lb->nparttypes)
                return NULL;
 
-       DBG(LABEL, ul_debugobj(lb, "parsing '%s' (%s) type", str, lb->name));
+       DBG_OBJ(LABEL, lb, ul_debug("parsing '%s' (%s) type", str, lb->name));
 
        if ((flags & FDISK_PARTTYPE_PARSE_DATA)
            && !(flags & FDISK_PARTTYPE_PARSE_DATALAST))
@@ -495,7 +495,7 @@ struct fdisk_parttype *fdisk_label_advparse_parttype(
        }
 
        if (res)
-               DBG(PARTTYPE, ul_debugobj(res, "returns parsed '%s' [%s] partition type",
+               DBG_OBJ(PARTTYPE, res, ul_debug("returns parsed '%s' [%s] partition type",
                                res->name, res->typestr ? : ""));
        return res;
 }
index c7164fe0d64eac166eaa65c64e6649453d078872..de52c57bd3005de787ae326583be55b452348adf 100644 (file)
@@ -75,7 +75,7 @@ static void fdisk_script_free_header(struct fdisk_scriptheader *fi)
        if (!fi)
                return;
 
-       DBG(SCRIPT, ul_debugobj(fi, "free header %s", fi->name));
+       DBG_OBJ(SCRIPT, fi, ul_debug("free header %s", fi->name));
        free(fi->name);
        free(fi->data);
        list_del(&fi->headers);
@@ -99,7 +99,7 @@ struct fdisk_script *fdisk_new_script(struct fdisk_context *cxt)
        if (!dp)
                return NULL;
 
-       DBG(SCRIPT, ul_debugobj(dp, "alloc"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("alloc"));
        dp->refcount = 1;
        dp->cxt = cxt;
        fdisk_ref_context(cxt);
@@ -169,7 +169,7 @@ static void fdisk_reset_script(struct fdisk_script *dp)
 {
        assert(dp);
 
-       DBG(SCRIPT, ul_debugobj(dp, "reset"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("reset"));
 
        if (dp->table)
                fdisk_reset_table(dp->table);
@@ -199,7 +199,7 @@ void fdisk_unref_script(struct fdisk_script *dp)
                fdisk_reset_script(dp);
                fdisk_unref_context(dp->cxt);
                fdisk_unref_table(dp->table);
-               DBG(SCRIPT, ul_debugobj(dp, "free script"));
+               DBG_OBJ(SCRIPT, dp, ul_debug("free script"));
                free(dp);
        }
 }
@@ -297,7 +297,7 @@ int fdisk_script_set_header(struct fdisk_script *dp,
                return 0;       /* want to remove header that does not exist, success */
 
        if (!data) {
-               DBG(SCRIPT, ul_debugobj(dp, "freeing header %s", name));
+               DBG_OBJ(SCRIPT, dp, ul_debug("freeing header %s", name));
 
                /* no data, remove the header */
                fdisk_script_free_header(fi);
@@ -307,7 +307,7 @@ int fdisk_script_set_header(struct fdisk_script *dp,
        if (!fi) {
                int rc;
 
-               DBG(SCRIPT, ul_debugobj(dp, "setting new header %s='%s'", name, data));
+               DBG_OBJ(SCRIPT, dp, ul_debug("setting new header %s='%s'", name, data));
 
                /* new header */
                fi = calloc(1, sizeof(*fi));
@@ -327,7 +327,7 @@ int fdisk_script_set_header(struct fdisk_script *dp,
                /* update existing */
                char *x = strdup(data);
 
-               DBG(SCRIPT, ul_debugobj(dp, "update '%s' header '%s' -> '%s'", name, fi->data, data));
+               DBG_OBJ(SCRIPT, dp, ul_debug("update '%s' header '%s' -> '%s'", name, fi->data, data));
 
                if (!x)
                        return -ENOMEM;
@@ -397,7 +397,7 @@ int fdisk_script_set_table(struct fdisk_script *dp, struct fdisk_table *tb)
        fdisk_unref_table(dp->table);
        dp->table = tb;
 
-       DBG(SCRIPT, ul_debugobj(dp, "table replaced"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("table replaced"));
        return 0;
 }
 
@@ -409,7 +409,7 @@ static struct fdisk_label *script_get_label(struct fdisk_script *dp)
        if (!dp->label) {
                dp->label = fdisk_get_label(dp->cxt,
                                        fdisk_script_get_header(dp, "label"));
-               DBG(SCRIPT, ul_debugobj(dp, "label '%s'", dp->label ? dp->label->name : ""));
+               DBG_OBJ(SCRIPT, dp, ul_debug("label '%s'", dp->label ? dp->label->name : ""));
        }
        return dp->label;
 }
@@ -466,7 +466,7 @@ int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt
        if (!cxt)
                cxt = dp->cxt;
 
-       DBG(SCRIPT, ul_debugobj(dp, "reading context into script"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("reading context into script"));
        fdisk_reset_script(dp);
 
        lb = fdisk_get_label(cxt, NULL);
@@ -528,7 +528,7 @@ int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt
                rc = fdisk_script_set_header(dp, "sector-size", buf);
        }
 
-       DBG(SCRIPT, ul_debugobj(dp, "read context done [rc=%d]", rc));
+       DBG_OBJ(SCRIPT, dp, ul_debug("read context done [rc=%d]", rc));
        return rc;
 }
 
@@ -560,7 +560,7 @@ static int write_file_json(struct fdisk_script *dp, FILE *f)
        assert(dp);
        assert(f);
 
-       DBG(SCRIPT, ul_debugobj(dp, "writing json dump to file"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("writing json dump to file"));
 
        ul_jsonwrt_init(&json, f, 0, UL_JSON_PRETTY);
        ul_jsonwrt_root_open(&json);
@@ -596,11 +596,11 @@ static int write_file_json(struct fdisk_script *dp, FILE *f)
 
 
        if (!dp->table || fdisk_table_is_empty(dp->table)) {
-               DBG(SCRIPT, ul_debugobj(dp, "script table empty"));
+               DBG_OBJ(SCRIPT, dp, ul_debug("script table empty"));
                goto done;
        }
 
-       DBG(SCRIPT, ul_debugobj(dp, "%zu entries", fdisk_table_get_nents(dp->table)));
+       DBG_OBJ(SCRIPT, dp, ul_debug("%zu entries", fdisk_table_get_nents(dp->table)));
 
        ul_jsonwrt_array_open(&json, "partitions");
 
@@ -612,7 +612,7 @@ static int write_file_json(struct fdisk_script *dp, FILE *f)
                if (devname)
                        p = fdisk_partname(devname, pa->partno + 1);
                if (p) {
-                       DBG(SCRIPT, ul_debugobj(dp, "write %s entry", p));
+                       DBG_OBJ(SCRIPT, dp, ul_debug("write %s entry", p));
                        ul_jsonwrt_value_s(&json, "node", p);
                        free(p);
                }
@@ -655,7 +655,7 @@ done:
        ul_jsonwrt_object_close(&json);
        ul_jsonwrt_root_close(&json);
 
-       DBG(SCRIPT, ul_debugobj(dp, "write script done"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("write script done"));
        return 0;
 }
 
@@ -669,7 +669,7 @@ static int write_file_sfdisk(struct fdisk_script *dp, FILE *f)
        assert(dp);
        assert(f);
 
-       DBG(SCRIPT, ul_debugobj(dp, "writing sfdisk-like script to file"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("writing sfdisk-like script to file"));
 
        /* script headers */
        list_for_each(h, &dp->headers) {
@@ -680,11 +680,11 @@ static int write_file_sfdisk(struct fdisk_script *dp, FILE *f)
        }
 
        if (!dp->table || fdisk_table_is_empty(dp->table)) {
-               DBG(SCRIPT, ul_debugobj(dp, "script table empty"));
+               DBG_OBJ(SCRIPT, dp, ul_debug("script table empty"));
                return 0;
        }
 
-       DBG(SCRIPT, ul_debugobj(dp, "%zu entries", fdisk_table_get_nents(dp->table)));
+       DBG_OBJ(SCRIPT, dp, ul_debug("%zu entries", fdisk_table_get_nents(dp->table)));
 
        fputc('\n', f);
 
@@ -696,7 +696,7 @@ static int write_file_sfdisk(struct fdisk_script *dp, FILE *f)
                if (devname)
                        p = fdisk_partname(devname, pa->partno + 1);
                if (p) {
-                       DBG(SCRIPT, ul_debugobj(dp, "write %s entry", p));
+                       DBG_OBJ(SCRIPT, dp, ul_debug("write %s entry", p));
                        fprintf(f, "%s : ", p);
                        free(p);
                } else
@@ -738,7 +738,7 @@ static int write_file_sfdisk(struct fdisk_script *dp, FILE *f)
                fputc('\n', f);
        }
 
-       DBG(SCRIPT, ul_debugobj(dp, "write script done"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("write script done"));
        return 0;
 }
 
@@ -781,7 +781,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
                "first-lba", "last-lba", "table-length", "sector-size"
        };
 
-       DBG(SCRIPT, ul_debugobj(dp, "   parse header '%s'", s));
+       DBG_OBJ(SCRIPT, dp, ul_debug("   parse header '%s'", s));
 
        if (!s || !*s)
                return -EINVAL;
@@ -1058,7 +1058,7 @@ static int parse_start_value(struct fdisk_script *dp, struct fdisk_partition *pa
        }
 
 done:
-       DBG(SCRIPT, ul_debugobj(dp, "  start parse result: rc=%d, move=%s, start=%ju, default=%s",
+       DBG_OBJ(SCRIPT, dp, ul_debug("  start parse result: rc=%d, move=%s, start=%ju, default=%s",
                                rc, pa->movestart == FDISK_MOVE_DOWN ? "down" :
                                    pa->movestart == FDISK_MOVE_UP ? "up" : "none",
                                    pa->start,
@@ -1115,7 +1115,7 @@ static int parse_size_value(struct fdisk_script *dp, struct fdisk_partition *pa,
        }
 
 done:
-       DBG(SCRIPT, ul_debugobj(dp, "  size parse result: rc=%d, move=%s, size=%ju, default=%s",
+       DBG_OBJ(SCRIPT, dp, ul_debug("  size parse result: rc=%d, move=%s, size=%ju, default=%s",
                                rc, pa->resize == FDISK_RESIZE_REDUCE ? "reduce" :
                                    pa->resize == FDISK_RESIZE_ENLARGE ? "enlarge" : "none",
                                    pa->size,
@@ -1144,7 +1144,7 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
        assert(s);
        assert(dp->table);
 
-       DBG(SCRIPT, ul_debugobj(dp, "   parse script line: '%s'", s));
+       DBG_OBJ(SCRIPT, dp, ul_debug("   parse script line: '%s'", s));
 
        pa = fdisk_new_partition();
        if (!pa)
@@ -1180,7 +1180,7 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
 
        while (rc == 0 && p && *p) {
 
-               DBG(SCRIPT, ul_debugobj(dp, " parsing '%s'", p));
+               DBG_OBJ(SCRIPT, dp, ul_debug(" parsing '%s'", p));
                p = (char *) skip_blank(p);
 
                if (!c_strncasecmp(p, "start=", 6)) {
@@ -1234,7 +1234,7 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
                        }
                        free(type);
                } else {
-                       DBG(SCRIPT, ul_debugobj(dp, "script parse error: unknown field '%s'", p));
+                       DBG_OBJ(SCRIPT, dp, ul_debug("script parse error: unknown field '%s'", p));
                        rc = -EINVAL;
                        break;
                }
@@ -1243,7 +1243,7 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
        if (!rc)
                rc = fdisk_table_add_partition(dp->table, pa);
        if (rc)
-               DBG(SCRIPT, ul_debugobj(dp, "script parse error: [rc=%d]", rc));
+               DBG_OBJ(SCRIPT, dp, ul_debug("script parse error: [rc=%d]", rc));
 
        fdisk_unref_partition(pa);
        return rc;
@@ -1278,7 +1278,7 @@ static int parse_line_valcommas(struct fdisk_script *dp, char *s)
                p = (char *) skip_blank(p);
                item++;
 
-               DBG(SCRIPT, ul_debugobj(dp, " parsing item %d ('%s')", item, p));
+               DBG_OBJ(SCRIPT, dp, ul_debug(" parsing item %d ('%s')", item, p));
                begin = p;
 
                switch (item) {
@@ -1335,7 +1335,7 @@ static int parse_line_valcommas(struct fdisk_script *dp, char *s)
        if (!rc)
                rc = fdisk_table_add_partition(dp->table, pa);
        if (rc)
-               DBG(SCRIPT, ul_debugobj(dp, "script parse error: [rc=%d]", rc));
+               DBG_OBJ(SCRIPT, dp, ul_debug("script parse error: [rc=%d]", rc));
 
        fdisk_unref_partition(pa);
        return rc;
@@ -1349,7 +1349,7 @@ static int fdisk_script_read_buffer(struct fdisk_script *dp, char *s)
        assert(dp);
        assert(s);
 
-       DBG(SCRIPT, ul_debugobj(dp, "  parsing buffer"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("  parsing buffer"));
 
        s = (char *) skip_blank(s);
        if (!s || !*s)
@@ -1371,7 +1371,7 @@ static int fdisk_script_read_buffer(struct fdisk_script *dp, char *s)
                rc = parse_line_valcommas(dp, s);
 
        if (rc)
-               DBG(SCRIPT, ul_debugobj(dp, "%zu: parse error [rc=%d]",
+               DBG_OBJ(SCRIPT, dp, ul_debug("%zu: parse error [rc=%d]",
                                dp->nlines, rc));
        return rc;
 }
@@ -1416,7 +1416,7 @@ int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t b
        assert(f);
        assert(bufsz);
 
-       DBG(SCRIPT, ul_debugobj(dp, " parsing line %zu", dp->nlines));
+       DBG_OBJ(SCRIPT, dp, ul_debug(" parsing line %zu", dp->nlines));
 
        /* read the next non-blank non-comment line */
        do {
@@ -1433,10 +1433,10 @@ int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t b
                        /* Missing final newline?  Otherwise an extremely */
                        /* long line - assume file was corrupted */
                        if (feof(f)) {
-                               DBG(SCRIPT, ul_debugobj(dp, "no final newline"));
+                               DBG_OBJ(SCRIPT, dp, ul_debug("no final newline"));
                                s = strchr(buf, '\0');
                        } else {
-                               DBG(SCRIPT, ul_debugobj(dp,
+                               DBG_OBJ(SCRIPT, dp, ul_debug(
                                        "%zu: missing newline at line", dp->nlines));
                                return -EINVAL;
                        }
@@ -1469,7 +1469,7 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
        assert(dp);
        assert(f);
 
-       DBG(SCRIPT, ul_debugobj(dp, "parsing file"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("parsing file"));
 
        while (!feof(f)) {
                rc = fdisk_script_read_line(dp, f, buf, sizeof(buf));
@@ -1480,7 +1480,7 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
        if (rc == 1)
                rc = 0;         /* end of file */
 
-       DBG(SCRIPT, ul_debugobj(dp, "parsing file done [rc=%d]", rc));
+       DBG_OBJ(SCRIPT, dp, ul_debug("parsing file done [rc=%d]", rc));
        return rc;
 }
 
@@ -1517,7 +1517,7 @@ int fdisk_set_script(struct fdisk_context *cxt, struct fdisk_script *dp)
        /* ref new */
        cxt->script = dp;
        if (cxt->script) {
-               DBG(CXT, ul_debugobj(cxt, "setting reference to script %p", cxt->script));
+               DBG_OBJ(CXT, cxt, ul_debug("setting reference to script %p", cxt->script));
                fdisk_ref_script(cxt->script);
        }
 
@@ -1555,7 +1555,7 @@ int fdisk_apply_script_headers(struct fdisk_context *cxt, struct fdisk_script *d
        assert(cxt);
        assert(dp);
 
-       DBG(SCRIPT, ul_debugobj(dp, "applying script headers"));
+       DBG_OBJ(SCRIPT, dp, ul_debug("applying script headers"));
        fdisk_set_script(cxt, dp);
 
        if (dp->sector_size && dp->cxt->sector_size != dp->sector_size) {
@@ -1634,7 +1634,7 @@ int fdisk_apply_script(struct fdisk_context *cxt, struct fdisk_script *dp)
        assert(dp);
        assert(cxt);
 
-       DBG(CXT, ul_debugobj(cxt, "applying script %p", dp));
+       DBG_OBJ(CXT, cxt, ul_debug("applying script %p", dp));
 
        old = fdisk_get_script(cxt);
        fdisk_ref_script(old);
@@ -1649,7 +1649,7 @@ int fdisk_apply_script(struct fdisk_context *cxt, struct fdisk_script *dp)
        fdisk_set_script(cxt, old);
        fdisk_unref_script(old);
 
-       DBG(CXT, ul_debugobj(cxt, "script done [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("script done [rc=%d]", rc));
        return rc;
 }
 
index 30955e1a64abb92331dc6d82e796fc2cd8651d2d..9582eba7047700c58a4c1cc7d974d5bdcc225642 100644 (file)
@@ -28,7 +28,7 @@ struct fdisk_table *fdisk_new_table(void)
        if (!tb)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "alloc"));
+       DBG_OBJ(TAB, tb, ul_debug("alloc"));
        tb->refcount = 1;
        INIT_LIST_HEAD(&tb->parts);
        return tb;
@@ -49,7 +49,7 @@ int fdisk_reset_table(struct fdisk_table *tb)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "reset"));
+       DBG_OBJ(TAB, tb, ul_debug("reset"));
 
        while (!list_empty(&tb->parts)) {
                struct fdisk_partition *pa = list_entry(tb->parts.next,
@@ -89,7 +89,7 @@ void fdisk_unref_table(struct fdisk_table *tb)
        if (tb->refcount <= 0) {
                fdisk_reset_table(tb);
 
-               DBG(TAB, ul_debugobj(tb, "free"));
+               DBG_OBJ(TAB, tb, ul_debug("free"));
                free(tb);
        }
 }
@@ -232,7 +232,7 @@ int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa
        list_add_tail(&pa->parts, &tb->parts);
        tb->nents++;
 
-       DBG(TAB, ul_debugobj(tb, "add entry %p [start=%ju, end=%ju, size=%ju, %s %s %s]",
+       DBG_OBJ(TAB, tb, ul_debug("add entry %p [start=%ju, end=%ju, size=%ju, %s %s %s]",
                        pa,
                        (uintmax_t) fdisk_partition_get_start(pa),
                        fdisk_partition_has_end(pa) ? (uintmax_t) fdisk_partition_get_end(pa) : 0,
@@ -259,7 +259,7 @@ static int table_insert_partition(
                list_add(&pa->parts, &tb->parts);
        tb->nents++;
 
-       DBG(TAB, ul_debugobj(tb, "insert entry %p pre=%p [start=%ju, end=%ju, size=%ju, %s %s %s]",
+       DBG_OBJ(TAB, tb, ul_debug("insert entry %p pre=%p [start=%ju, end=%ju, size=%ju, %s %s %s]",
                        pa, poz ? poz : NULL,
                        (uintmax_t) fdisk_partition_get_start(pa),
                        (uintmax_t) fdisk_partition_get_end(pa),
@@ -287,7 +287,7 @@ int fdisk_table_remove_partition(struct fdisk_table *tb, struct fdisk_partition
        if (!tb || !pa)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "remove entry %p", pa));
+       DBG_OBJ(TAB, tb, ul_debug("remove entry %p", pa));
        list_del(&pa->parts);
        INIT_LIST_HEAD(&pa->parts);
 
@@ -316,7 +316,7 @@ int fdisk_get_partitions(struct fdisk_context *cxt, struct fdisk_table **tb)
        if (!cxt->label->op->get_part)
                return -ENOSYS;
 
-       DBG(CXT, ul_debugobj(cxt, " -- get table --"));
+       DBG_OBJ(CXT, cxt, ul_debug(" -- get table --"));
 
        if (!*tb && !(*tb = fdisk_new_table()))
                return -ENOMEM;
@@ -340,8 +340,9 @@ void fdisk_debug_print_table(struct fdisk_table *tb)
        struct fdisk_partition *pa;
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
-       while (fdisk_table_next_partition(tb, &itr, &pa) == 0)
-               ul_debugobj(tb, "partition %p [partno=%zu, start=%ju, end=%ju, size=%ju%s%s%s] ",
+       while (fdisk_table_next_partition(tb, &itr, &pa) == 0) {
+               ul_debugobj(tb, UL_DEBUG_MASK(libfdisk));
+               ul_debug("partition %p [partno=%zu, start=%ju, end=%ju, size=%ju%s%s%s] ",
                            pa, pa->partno,
                            (uintmax_t) fdisk_partition_get_start(pa),
                            (uintmax_t) fdisk_partition_get_end(pa),
@@ -349,6 +350,7 @@ void fdisk_debug_print_table(struct fdisk_table *tb)
                            fdisk_partition_is_nested(pa) ? " nested" : "",
                            fdisk_partition_is_freespace(pa) ? " freespace" : "",
                            fdisk_partition_is_container(pa) ? " container" : "");
+       }
 
 }
 
@@ -383,14 +385,14 @@ int fdisk_table_sort_partitions(struct fdisk_table *tb,
                return -EINVAL;
 
        /*
-       DBG(TAB, ul_debugobj(tb, "Before sort:"));
+       DBG_OBJ(TAB, tb, ul_debug("Before sort:"));
        ON_DBG(TAB, fdisk_debug_print_table(tb));
        */
 
        list_sort(&tb->parts, cmp_parts_wrapper, (void *) cmp);
 
        /*
-       DBG(TAB, ul_debugobj(tb, "After sort:"));
+       DBG_OBJ(TAB, tb, ul_debug("After sort:"));
        ON_DBG(TAB, fdisk_debug_print_table(tb));
        */
 
@@ -462,7 +464,7 @@ static int table_add_freespace(
        assert(fdisk_partition_has_start(pa));
        assert(fdisk_partition_has_end(pa));
 
-       DBG(TAB, ul_debugobj(tb, "adding freespace"));
+       DBG_OBJ(TAB, tb, ul_debug("adding freespace"));
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
        if (parent && fdisk_partition_has_partno(parent)) {
@@ -475,7 +477,7 @@ static int table_add_freespace(
                        }
                }
                if (!real_parent) {
-                       DBG(TAB, ul_debugobj(tb, "not found freespace parent (partno=%zu)",
+                       DBG_OBJ(TAB, tb, ul_debug("not found freespace parent (partno=%zu)",
                                        parent->partno));
                        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
                }
@@ -501,7 +503,7 @@ static int table_add_freespace(
 
        fdisk_unref_partition(pa);
 
-       DBG(TAB, ul_debugobj(tb, "adding freespace DONE [rc=%d]", rc));
+       DBG_OBJ(TAB, tb, ul_debug("adding freespace DONE [rc=%d]", rc));
        return rc;
 }
 
@@ -523,25 +525,25 @@ static int check_container_freespace(struct fdisk_context *cxt,
        assert(cont);
        assert(fdisk_partition_has_start(cont));
 
-       DBG(TAB, ul_debugobj(tb, "analyze container 0x%p", cont));
+       DBG_OBJ(TAB, tb, ul_debug("analyze container 0x%p", cont));
 
        last = fdisk_partition_get_start(cont);
        grain = cxt->grain > cxt->sector_size ? cxt->grain / cxt->sector_size : 1;
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
 
-       DBG(CXT, ul_debugobj(cxt, "initialized:  last=%ju, grain=%ju",
+       DBG_OBJ(CXT, cxt, ul_debug("initialized:  last=%ju, grain=%ju",
                             (uintmax_t)last,  (uintmax_t)grain));
 
        while (fdisk_table_next_partition(parts, &itr, &pa) == 0) {
 
-               DBG(CXT, ul_debugobj(cxt, "partno=%zu, start=%ju",
+               DBG_OBJ(CXT, cxt, ul_debug("partno=%zu, start=%ju",
                                     pa->partno, (uintmax_t)pa->start));
 
                if (!pa->used || !fdisk_partition_is_nested(pa)
                              || !fdisk_partition_has_start(pa))
                        continue;
 
-               DBG(CXT, ul_debugobj(cxt, "freespace container analyze: partno=%zu, start=%ju, end=%ju",
+               DBG_OBJ(CXT, cxt, ul_debug("freespace container analyze: partno=%zu, start=%ju, end=%ju",
                                        pa->partno,
                                        (uintmax_t) fdisk_partition_get_start(pa),
                                        (uintmax_t) fdisk_partition_get_end(pa)));
@@ -558,12 +560,12 @@ static int check_container_freespace(struct fdisk_context *cxt,
        x = fdisk_partition_get_start(cont) + fdisk_partition_get_size(cont) - 1;
        lastplusoff = last + cxt->first_lba;
        if (lastplusoff < x && x - lastplusoff > grain) {
-               DBG(TAB, ul_debugobj(tb, "add remaining space in container 0x%p", cont));
+               DBG_OBJ(TAB, tb, ul_debug("add remaining space in container 0x%p", cont));
                rc = table_add_freespace(cxt, tb, lastplusoff, x, cont);
        }
 
 done:
-       DBG(TAB, ul_debugobj(tb, "analyze container 0x%p DONE [rc=%d]", cont, rc));
+       DBG_OBJ(TAB, tb, ul_debug("analyze container 0x%p DONE [rc=%d]", cont, rc));
        return rc;
 }
 
@@ -590,7 +592,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
        struct fdisk_partition *pa;
        struct fdisk_iter itr;
 
-       DBG(CXT, ul_debugobj(cxt, "-- get freespace --"));
+       DBG_OBJ(CXT, cxt, ul_debug("-- get freespace --"));
 
        if (!cxt || !cxt->label || !tb)
                return -EINVAL;
@@ -606,19 +608,19 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
        last = cxt->first_lba;
        grain = cxt->grain > cxt->sector_size ? cxt->grain / cxt->sector_size : 1;
 
-       DBG(CXT, ul_debugobj(cxt, "initialized:  last=%ju, grain=%ju",
+       DBG_OBJ(CXT, cxt, ul_debug("initialized:  last=%ju, grain=%ju",
                             (uintmax_t)last,  (uintmax_t)grain));
 
        /* analyze gaps between partitions */
        while (rc == 0 && fdisk_table_next_partition(parts, &itr, &pa) == 0) {
 
-               DBG(CXT, ul_debugobj(cxt, "partno=%zu, start=%ju",
+               DBG_OBJ(CXT, cxt, ul_debug("partno=%zu, start=%ju",
                                     pa->partno, (uintmax_t)pa->start));
 
                if (!pa->used || pa->wholedisk || fdisk_partition_is_nested(pa)
                              || !fdisk_partition_has_start(pa))
                        continue;
-               DBG(CXT, ul_debugobj(cxt, "freespace analyze: partno=%zu, start=%ju, end=%ju",
+               DBG_OBJ(CXT, cxt, ul_debug("freespace analyze: partno=%zu, start=%ju, end=%ju",
                                        pa->partno,
                                        (uintmax_t) fdisk_partition_get_start(pa),
                                        (uintmax_t) fdisk_partition_get_end(pa)));
@@ -649,7 +651,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
        /* add free-space behind last partition to the end of the table (so
         * don't use table_add_freespace()) */
        if (rc == 0 && last + grain < cxt->last_lba - 1) {
-               DBG(CXT, ul_debugobj(cxt, "freespace behind last partition detected"));
+               DBG_OBJ(CXT, cxt, ul_debug("freespace behind last partition detected"));
                rc = new_freespace(cxt,
                        last + (last > cxt->first_lba || nparts ? 1 : 0),
                        cxt->last_lba, NULL, &pa);
@@ -662,7 +664,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
 done:
        fdisk_unref_table(parts);
 
-       DBG(CXT, ul_debugobj(cxt, "get freespace DONE [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("get freespace DONE [rc=%d]", rc));
        return rc;
 }
 
@@ -678,7 +680,7 @@ int fdisk_table_wrong_order(struct fdisk_table *tb)
        struct fdisk_iter itr;
        fdisk_sector_t last = 0;
 
-       DBG(TAB, ul_debugobj(tb, "wrong older check"));
+       DBG_OBJ(TAB, tb, ul_debug("wrong older check"));
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
        while (tb && fdisk_table_next_partition(tb, &itr, &pa) == 0) {
@@ -712,7 +714,7 @@ int fdisk_apply_table(struct fdisk_context *cxt, struct fdisk_table *tb)
        assert(cxt);
        assert(tb);
 
-       DBG(TAB, ul_debugobj(tb, "applying to context %p", cxt));
+       DBG_OBJ(TAB, tb, ul_debug("applying to context %p", cxt));
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
        while (tb && fdisk_table_next_partition(tb, &itr, &pa) == 0) {
@@ -737,10 +739,10 @@ int fdisk_diff_tables(struct fdisk_table *a, struct fdisk_table *b,
        assert(res);
        assert(change);
 
-       DBG(TAB, ul_debugobj(a, "table diff [new table=%p]", b));
+       DBG_OBJ(TAB, a, ul_debug("table diff [new table=%p]", b));
 
        if (a && (itr->head == NULL || itr->head == &a->parts)) {
-               DBG(TAB, ul_debugobj(a, " scanning old table"));
+               DBG_OBJ(TAB, a, ul_debug(" scanning old table"));
                do {
                        rc = fdisk_table_next_partition(a, itr, &pa);
                        if (rc != 0)
@@ -749,9 +751,9 @@ int fdisk_diff_tables(struct fdisk_table *a, struct fdisk_table *b,
        }
 
        if (rc == 1 && b) {
-               DBG(TAB, ul_debugobj(a, " scanning new table"));
+               DBG_OBJ(TAB, a, ul_debug(" scanning new table"));
                if (itr->head != &b->parts) {
-                       DBG(TAB, ul_debugobj(a, "  initialize to TAB=%p", b));
+                       DBG_OBJ(TAB, a, ul_debug("  initialize to TAB=%p", b));
                        fdisk_reset_iter(itr, FDISK_ITER_FORWARD);
                }
 
@@ -760,7 +762,7 @@ int fdisk_diff_tables(struct fdisk_table *a, struct fdisk_table *b,
                                continue;
                        if (a == NULL ||
                            fdisk_table_get_partition_by_partno(a, pb->partno) == NULL) {
-                               DBG(TAB, ul_debugobj(a, " #%zu ADDED", pb->partno));
+                               DBG_OBJ(TAB, a, ul_debug(" #%zu ADDED", pb->partno));
                                *change = FDISK_DIFF_ADDED;
                                *res = pb;
                                return 0;
@@ -769,26 +771,26 @@ int fdisk_diff_tables(struct fdisk_table *a, struct fdisk_table *b,
        }
 
        if (rc) {
-               DBG(TAB, ul_debugobj(a, "table diff done [rc=%d]", rc));
+               DBG_OBJ(TAB, a, ul_debug("table diff done [rc=%d]", rc));
                return rc;      /* error or done */
        }
 
        pb = fdisk_table_get_partition_by_partno(b, pa->partno);
 
        if (!pb) {
-               DBG(TAB, ul_debugobj(a, " #%zu REMOVED", pa->partno));
+               DBG_OBJ(TAB, a, ul_debug(" #%zu REMOVED", pa->partno));
                *change = FDISK_DIFF_REMOVED;
                *res = pa;
        } else if (pb->start != pa->start) {
-               DBG(TAB, ul_debugobj(a, " #%zu MOVED", pb->partno));
+               DBG_OBJ(TAB, a, ul_debug(" #%zu MOVED", pb->partno));
                *change = FDISK_DIFF_MOVED;
                *res = pb;
        } else if (pb->size != pa->size) {
-               DBG(TAB, ul_debugobj(a, " #%zu RESIZED", pb->partno));
+               DBG_OBJ(TAB, a, ul_debug(" #%zu RESIZED", pb->partno));
                *change = FDISK_DIFF_RESIZED;
                *res = pb;
        } else {
-               DBG(TAB, ul_debugobj(a, " #%zu UNCHANGED", pb->partno));
+               DBG_OBJ(TAB, a, ul_debug(" #%zu UNCHANGED", pb->partno));
                *change = FDISK_DIFF_UNCHANGED;
                *res = pa;
        }
index a3397ab523f8da1efcc921dc8e056b7dfe2c5f21..0a995bff200505951c90a9aa03c7c636aea59e71 100644 (file)
@@ -19,13 +19,13 @@ static int read_from_device(struct fdisk_context *cxt,
 
        assert(cxt);
 
-       DBG(CXT, ul_debugobj(cxt, "reading: offset=%ju, size=%zu",
+       DBG_OBJ(CXT, cxt, ul_debug("reading: offset=%ju, size=%zu",
                                start, size));
 
        r = lseek(cxt->dev_fd, start, SEEK_SET);
        if (r == -1)
        {
-               DBG(CXT, ul_debugobj(cxt, "failed to seek to offset %ju: %m", start));
+               DBG_OBJ(CXT, cxt, ul_debug("failed to seek to offset %ju: %m", start));
                return -errno;
        }
 
@@ -34,7 +34,7 @@ static int read_from_device(struct fdisk_context *cxt,
        if (r < 0 || (size_t)r != size) {
                if (!errno)
                        errno = EINVAL; /* probably too small file/device */
-               DBG(CXT, ul_debugobj(cxt, "failed to read %zu from offset %ju: %m",
+               DBG_OBJ(CXT, cxt, ul_debug("failed to read %zu from offset %ju: %m",
                                size, start));
                return -errno;
        }
@@ -61,7 +61,7 @@ int fdisk_init_firstsector_buffer(struct fdisk_context *cxt,
                if (!cxt->parent || cxt->parent->firstsector != cxt->firstsector)
                        free(cxt->firstsector);
 
-               DBG(CXT, ul_debugobj(cxt, "initialize in-memory first sector "
+               DBG_OBJ(CXT, cxt, ul_debug("initialize in-memory first sector "
                                "buffer [sector_size=%lu]", cxt->sector_size));
                cxt->firstsector = calloc(1, cxt->sector_size);
                if (!cxt->firstsector)
@@ -71,7 +71,7 @@ int fdisk_init_firstsector_buffer(struct fdisk_context *cxt,
                return 0;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "zeroize in-memory first sector buffer"));
+       DBG_OBJ(CXT, cxt, ul_debug("zeroize in-memory first sector buffer"));
        memset(cxt->firstsector, 0, cxt->firstsector_bufsz);
 
        if (protect_size) {
@@ -83,7 +83,7 @@ int fdisk_init_firstsector_buffer(struct fdisk_context *cxt,
                 * maybe it was already modified. Let's re-read from the device
                 * to be sure.                  -- kzak 13-Apr-2015
                 */
-               DBG(CXT, ul_debugobj(cxt, "first sector protection enabled -- re-reading"));
+               DBG_OBJ(CXT, cxt, ul_debug("first sector protection enabled -- re-reading"));
                read_from_device(cxt, cxt->firstsector, protect_off, protect_size);
        }
        return 0;
index f8aa2405234b327460837fe677d0c193b59b55cd..64b8a3a9646625ec3eca887eabd8713ca75edca3 100644 (file)
@@ -36,7 +36,7 @@ void fdisk_free_wipe_areas(struct fdisk_context *cxt)
        while (!list_empty(&cxt->wipes)) {
                struct fdisk_wipe *wp = list_entry(cxt->wipes.next,
                                                  struct fdisk_wipe, wipes);
-               DBG(WIPE, ul_debugobj(wp, "free [start=%ju, size=%ju]",
+               DBG_OBJ(WIPE, wp, ul_debug("free [start=%ju, size=%ju]",
                                (uintmax_t) wp->start, (uintmax_t) wp->size));
                list_del(&wp->wipes);
                free(wp);
@@ -69,7 +69,7 @@ int fdisk_set_wipe_area(struct fdisk_context *cxt,
        /* disable */
        if (!enable) {
                if (wp) {
-                       DBG(WIPE, ul_debugobj(wp, "disable [start=%ju, size=%ju]",
+                       DBG_OBJ(WIPE, wp, ul_debug("disable [start=%ju, size=%ju]",
                                                (uintmax_t) start, (uintmax_t) size));
                        list_del(&wp->wipes);
                        free(wp);
@@ -87,7 +87,7 @@ int fdisk_set_wipe_area(struct fdisk_context *cxt,
        if (!wp)
                return -ENOMEM;
 
-       DBG(WIPE, ul_debugobj(wp, "enable [start=%ju, size=%ju]",
+       DBG_OBJ(WIPE, wp, ul_debug("enable [start=%ju, size=%ju]",
                                (uintmax_t) start, (uintmax_t) size));
 
        INIT_LIST_HEAD(&wp->wipes);
@@ -125,17 +125,17 @@ int fdisk_do_wipe(struct fdisk_context *cxt)
                blkid_loff_t start = (blkid_loff_t) wp->start * cxt->sector_size,
                             size = (blkid_loff_t) wp->size * cxt->sector_size;
 
-               DBG(WIPE, ul_debugobj(wp, "initialize libblkid prober [start=%ju, size=%ju]",
+               DBG_OBJ(WIPE, wp, ul_debug("initialize libblkid prober [start=%ju, size=%ju]",
                                             (uintmax_t) start, (uintmax_t) size));
 
                rc = blkid_probe_set_device(pr, cxt->dev_fd, start, size);
                if (rc) {
-                       DBG(WIPE, ul_debugobj(wp, "blkid_probe_set_device() failed [rc=%d]", rc));
+                       DBG_OBJ(WIPE, wp, ul_debug("blkid_probe_set_device() failed [rc=%d]", rc));
                        return rc;
                }
                blkid_probe_set_sectorsize(pr, cxt->sector_size);
 
-               DBG(WIPE, ul_debugobj(wp, " wiping..."));
+               DBG_OBJ(WIPE, wp, ul_debug(" wiping..."));
                blkid_wipe_all(pr);
        }
 
@@ -164,7 +164,7 @@ int fdisk_check_collisions(struct fdisk_context *cxt)
        assert(cxt);
        assert(cxt->dev_fd >= 0);
 
-       DBG(WIPE, ul_debugobj(cxt, "wipe check: initialize libblkid prober"));
+       DBG_OBJ(WIPE, cxt, ul_debug("wipe check: initialize libblkid prober"));
 
        pr = blkid_new_probe();
        if (!pr)
index 4d2a20f235f0ebe5162dff59476b147a3af04b32..c16480fef03c16245d410ca6fc3386556d89ea58 100644 (file)
@@ -107,7 +107,7 @@ struct libmnt_cache *mnt_new_cache(void)
        struct libmnt_cache *cache = calloc(1, sizeof(*cache));
        if (!cache)
                return NULL;
-       DBG(CACHE, ul_debugobj(cache, "alloc"));
+       DBG_OBJ(CACHE, cache, ul_debug("alloc"));
        cache->refcount = 1;
        return cache;
 }
@@ -126,7 +126,7 @@ void mnt_free_cache(struct libmnt_cache *cache)
        if (!cache)
                return;
 
-       DBG(CACHE, ul_debugobj(cache, "free [refcount=%d]", cache->refcount));
+       DBG_OBJ(CACHE, cache, ul_debug("free [refcount=%d]", cache->refcount));
 
        for (i = 0; i < cache->nents; i++) {
                struct mnt_cache_entry *e = &cache->ents[i];
@@ -150,7 +150,7 @@ void mnt_ref_cache(struct libmnt_cache *cache)
 {
        if (cache) {
                cache->refcount++;
-               /*DBG(CACHE, ul_debugobj(cache, "ref=%d", cache->refcount));*/
+               /*DBG_OBJ(CACHE, cache, ul_debug("ref=%d", cache->refcount));*/
        }
 }
 
@@ -165,7 +165,7 @@ void mnt_unref_cache(struct libmnt_cache *cache)
 {
        if (cache) {
                cache->refcount--;
-               /*DBG(CACHE, ul_debugobj(cache, "unref=%d", cache->refcount));*/
+               /*DBG_OBJ(CACHE, cache, ul_debug("unref=%d", cache->refcount));*/
                if (cache->refcount <= 0) {
                        mnt_unref_table(cache->mountinfo);
 
@@ -240,7 +240,7 @@ static int cache_add_entry(struct libmnt_cache *cache, char *key,
        e->flag = flag;
        cache->nents++;
 
-       DBG(CACHE, ul_debugobj(cache, "add entry [%2zd] (%s): %s: %s",
+       DBG_OBJ(CACHE, cache, ul_debug("add entry [%2zd] (%s): %s: %s",
                        cache->nents,
                        (flag & MNT_CACHE_ISPATH) ? "path" : "tag",
                        value, key));
@@ -379,7 +379,7 @@ static int read_from_blkid(struct libmnt_cache *cache, const char *devname)
        assert(cache);
        assert(devname);
 
-       DBG(CACHE, ul_debugobj(cache, "%s: reading from blkid", devname));
+       DBG_OBJ(CACHE, cache, ul_debug("%s: reading from blkid", devname));
 
        pr =  blkid_new_probe_from_filename(devname);
        if (!pr)
@@ -415,7 +415,7 @@ static int read_from_blkid(struct libmnt_cache *cache, const char *devname)
        }
 
 done:
-       DBG(CACHE, ul_debugobj(cache, "\tread %zd tags [rc=%d]", ntags, rc));
+       DBG_OBJ(CACHE, cache, ul_debug("\tread %zd tags [rc=%d]", ntags, rc));
        blkid_free_probe(pr);
        free(cacheval);
 
@@ -442,7 +442,7 @@ static int read_from_udev(struct libmnt_cache *cache, const char *devname)
        if (rc < 0)
                return rc;
 
-       DBG(CACHE, ul_debugobj(cache, "%s: reading from udev", devname));
+       DBG_OBJ(CACHE, cache, ul_debug("%s: reading from udev", devname));
 
        for (t = mnttags; t && t->mnt_name; t++) {
                const char *data;
@@ -468,7 +468,7 @@ static int read_from_udev(struct libmnt_cache *cache, const char *devname)
                free(tagval), tagval = NULL;
        }
 
-       DBG(CACHE, ul_debugobj(cache, "\tread %zd tags [rc=%d]", ntags, rc));
+       DBG_OBJ(CACHE, cache, ul_debug("\tread %zd tags [rc=%d]", ntags, rc));
        sd_device_unref(sd);
        free(cacheval);
        free(tagval);
@@ -493,7 +493,7 @@ int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname)
        if (!cache || !devname)
                return -EINVAL;
 
-       DBG(CACHE, ul_debugobj(cache, "tags for %s requested", devname));
+       DBG_OBJ(CACHE, cache, ul_debug("tags for %s requested", devname));
 
        if (is_device_cached(cache, devname))
                return 0;
@@ -610,7 +610,7 @@ static char *fstype_from_blkid(const char *devname, int *ambi)
  */
 char *mnt_get_fstype(const char *devname, int *ambi, struct libmnt_cache *cache)
 {
-       DBG(CACHE, ul_debugobj(cache, "get %s FS type", devname));
+       DBG_OBJ(CACHE, cache, ul_debug("get %s FS type", devname));
 
        if (cache)
                return fstype_from_cache(devname, cache);
@@ -625,7 +625,7 @@ static char *canonicalize_path_and_cache(const char *path,
        char *key;
        char *value;
 
-       DBG(CACHE, ul_debugobj(cache, "canonicalize path %s", path));
+       DBG_OBJ(CACHE, cache, ul_debug("canonicalize path %s", path));
        p = ul_canonicalize_path(path);
 
        if (p && cache) {
@@ -664,7 +664,7 @@ char *mnt_resolve_path(const char *path, struct libmnt_cache *cache)
 {
        char *p = NULL;
 
-       /*DBG(CACHE, ul_debugobj(cache, "resolving path %s", path));*/
+       /*DBG_OBJ(CACHE, cache, ul_debug("resolving path %s", path));*/
 
        if (!path)
                return NULL;
@@ -699,7 +699,7 @@ char *mnt_resolve_target(const char *path, struct libmnt_cache *cache)
        if (!path)
                return NULL;
 
-       /*DBG(CACHE, ul_debugobj(cache, "resolving target %s", path));*/
+       /*DBG_OBJ(CACHE, cache, ul_debug("resolving target %s", path));*/
 
        if (!cache || !cache->mountinfo)
                return mnt_resolve_path(path, cache);
@@ -801,7 +801,7 @@ char *mnt_resolve_tag(const char *token, const char *value,
 {
        char *p = NULL;
 
-       /*DBG(CACHE, ul_debugobj(cache, "resolving tag token=%s value=%s",
+       /*DBG_OBJ(CACHE, cache, ul_debug("resolving tag token=%s value=%s",
                                token, value));*/
 
        if (!token || !value)
index 53464f19ae30a264e22daec7762514c739291389..f4b012847a7381f5bb09a5645637e421e3a08d67 100644 (file)
@@ -79,7 +79,7 @@ struct libmnt_context *mnt_new_context(void)
 
        cxt->noautofs = 0;
 
-       DBG(CXT, ul_debugobj(cxt, "----> allocate %s",
+       DBG_OBJ(CXT, cxt, ul_debug("----> allocate %s",
                                cxt->restricted ? "[RESTRICTED]" : ""));
 
        return cxt;
@@ -116,7 +116,7 @@ void mnt_free_context(struct libmnt_context *cxt)
 
        free(cxt->children);
 
-       DBG(CXT, ul_debugobj(cxt, "free"));
+       DBG_OBJ(CXT, cxt, ul_debug("free"));
        free(cxt);
 }
 
@@ -147,7 +147,7 @@ int mnt_reset_context(struct libmnt_context *cxt)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "<---- reset [status=%d] ---->",
+       DBG_OBJ(CXT, cxt, ul_debug("<---- reset [status=%d] ---->",
                                mnt_context_get_status(cxt)));
 
        fl = cxt->flags;
@@ -212,7 +212,7 @@ int mnt_context_save_template(struct libmnt_context *cxt)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "saving template"));
+       DBG_OBJ(CXT, cxt, ul_debug("saving template"));
 
        /* reset old saved data */
        mnt_unref_optlist(cxt->optlist_saved);
@@ -241,7 +241,7 @@ int mnt_context_apply_template(struct libmnt_context *cxt)
        }
 
        if (cxt->optlist_saved) {
-               DBG(CXT, ul_debugobj(cxt, "restoring template"));
+               DBG_OBJ(CXT, cxt, ul_debug("restoring template"));
                cxt->optlist = mnt_copy_optlist(cxt->optlist_saved);
        }
 
@@ -261,7 +261,7 @@ struct libmnt_context *mnt_copy_context(struct libmnt_context *o)
        if (!n)
                return NULL;
 
-       DBG(CXT, ul_debugobj(n, "<---- clone ---->"));
+       DBG_OBJ(CXT, n, ul_debug("<---- clone ---->"));
 
        n->flags = o->flags;
 
@@ -332,7 +332,7 @@ static int context_init_paths(struct libmnt_context *cxt, int writable)
 
        if (!cxt->utab_path) {
                cxt->utab_path = mnt_get_utab_path();
-               DBG(CXT, ul_debugobj(cxt, "utab path initialized to: %s", cxt->utab_path));
+               DBG_OBJ(CXT, cxt, ul_debug("utab path initialized to: %s", cxt->utab_path));
        }
 
        if (!writable)
@@ -342,7 +342,7 @@ static int context_init_paths(struct libmnt_context *cxt, int writable)
        if (cxt->flags & MNT_FL_TABPATHS_CHECKED)
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "checking for writable tab files"));
+       DBG_OBJ(CXT, cxt, ul_debug("checking for writable tab files"));
 
        ns_old = mnt_context_switch_target_ns(cxt);
        if (!ns_old)
@@ -378,10 +378,10 @@ static int set_flag(struct libmnt_context *cxt, int flag, int enable)
        if (!cxt)
                return -EINVAL;
        if (enable) {
-               DBG(CXT, ul_debugobj(cxt, "enabling flag %04x", flag));
+               DBG_OBJ(CXT, cxt, ul_debug("enabling flag %04x", flag));
                cxt->flags |= flag;
        } else {
-               DBG(CXT, ul_debugobj(cxt, "disabling flag %04x", flag));
+               DBG_OBJ(CXT, cxt, ul_debug("disabling flag %04x", flag));
                cxt->flags &= ~flag;
        }
        return 0;
@@ -416,7 +416,7 @@ int mnt_context_is_restricted(struct libmnt_context *cxt)
 int mnt_context_force_unrestricted(struct libmnt_context *cxt)
 {
        if (mnt_context_is_restricted(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "force UNRESTRICTED"));
+               DBG_OBJ(CXT, cxt, ul_debug("force UNRESTRICTED"));
                cxt->restricted = 0;
        }
 
@@ -997,7 +997,7 @@ int mnt_context_set_fs(struct libmnt_context *cxt, struct libmnt_fs *fs)
        if (cxt->fs == fs)
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "setting new FS"));
+       DBG_OBJ(CXT, cxt, ul_debug("setting new FS"));
 
        /* new */
        if (fs) {
@@ -1452,7 +1452,7 @@ int mnt_context_get_mountinfo(struct libmnt_context *cxt, struct libmnt_table **
        if (tb)
                *tb = cxt->mountinfo;
 
-       DBG(CXT, ul_debugobj(cxt, "mountinfo requested [nents=%d]",
+       DBG_OBJ(CXT, cxt, ul_debug("mountinfo requested [nents=%d]",
                                mnt_table_get_nents(cxt->mountinfo)));
 
 end:
@@ -1557,7 +1557,7 @@ int mnt_context_set_tabfilter(struct libmnt_context *cxt,
                                cxt->table_fltrcb,
                                cxt->table_fltrcb_data);
 
-       DBG(CXT, ul_debugobj(cxt, "tabfilter %s", fltr ? "ENABLED!" : "disabled"));
+       DBG_OBJ(CXT, cxt, ul_debug("tabfilter %s", fltr ? "ENABLED!" : "disabled"));
        return 0;
 }
 
@@ -1907,7 +1907,7 @@ int mnt_context_open_tree(struct libmnt_context *cxt, const char *path, unsigned
        if (mnt_context_is_xnocanonicalize(cxt, "source"))
                oflg |= AT_SYMLINK_NOFOLLOW;
 
-       DBG(CXT, ul_debugobj(cxt, "open_tree(path=%s%s%s)", path,
+       DBG_OBJ(CXT, cxt, ul_debug("open_tree(path=%s%s%s)", path,
                                oflg & OPEN_TREE_CLONE ? " clone" : "",
                                oflg & AT_RECURSIVE ? " recursive" : ""));
        fd = open_tree(AT_FDCWD, path, oflg);
@@ -1933,7 +1933,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "--> preparing source path"));
+       DBG_OBJ(CXT, cxt, ul_debug("--> preparing source path"));
 
        src = mnt_fs_get_source(cxt->fs);
 
@@ -1952,7 +1952,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
        if (type && strcmp(type, "zfs") == 0)
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "srcpath '%s'", src));
+       DBG_OBJ(CXT, cxt, ul_debug("srcpath '%s'", src));
 
        ns_old = mnt_context_switch_target_ns(cxt);
        if (!ns_old)
@@ -1980,7 +1980,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
         }
 
        if (rc) {
-               DBG(CXT, ul_debugobj(cxt, "failed to prepare srcpath [rc=%d]", rc));
+               DBG_OBJ(CXT, cxt, ul_debug("failed to prepare srcpath [rc=%d]", rc));
                goto end;
        }
 
@@ -1995,7 +1995,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
            || mnt_optlist_is_move(ol)
            || mnt_optlist_is_remount(ol)
            || mnt_fs_is_pseudofs(cxt->fs)) {
-               DBG(CXT, ul_debugobj(cxt, "REMOUNT/BIND/MOVE/pseudo FS source: %s", path));
+               DBG_OBJ(CXT, cxt, ul_debug("REMOUNT/BIND/MOVE/pseudo FS source: %s", path));
                goto end;
        }
 
@@ -2003,7 +2003,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
        if (rc)
                goto end;
 
-       DBG(CXT, ul_debugobj(cxt, "final srcpath '%s'",
+       DBG_OBJ(CXT, cxt, ul_debug("final srcpath '%s'",
                                mnt_fs_get_source(cxt->fs)));
 
 end:
@@ -2049,7 +2049,7 @@ int mnt_context_guess_srcpath_fstype(struct libmnt_context *cxt, char **type)
                                rc = -ENOMEM;
                }
        } else {
-               DBG(CXT, ul_debugobj(cxt, "access(%s) failed [%m]", dev));
+               DBG_OBJ(CXT, cxt, ul_debug("access(%s) failed [%m]", dev));
                if (strchr(dev, ':') != NULL) {
                        *type = strdup("nfs");
                        if (!*type)
@@ -2081,7 +2081,7 @@ int mnt_context_guess_srcpath_fstype(struct libmnt_context *cxt, char **type)
                if (opt
                    && (allowed = mnt_opt_get_value(opt))
                    && !match_fstype(*type, allowed)) {
-                       DBG(CXT, ul_debugobj(cxt, "%s is not allowed by auto-fstypes=%s",
+                       DBG_OBJ(CXT, cxt, ul_debug("%s is not allowed by auto-fstypes=%s",
                                                *type, allowed));
                        free(*type);
                        *type = NULL;
@@ -2117,7 +2117,7 @@ int mnt_context_guess_fstype(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "--> preparing fstype"));
+       DBG_OBJ(CXT, cxt, ul_debug("--> preparing fstype"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -2147,7 +2147,7 @@ int mnt_context_guess_fstype(struct libmnt_context *cxt)
        else
                free(type);
 done:
-       DBG(CXT, ul_debugobj(cxt, "FS type: %s [rc=%d]",
+       DBG_OBJ(CXT, cxt, ul_debug("FS type: %s [rc=%d]",
                                mnt_fs_get_fstype(cxt->fs), rc));
        return rc;
 none:
@@ -2173,7 +2173,7 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "checking for helper"));
+       DBG_OBJ(CXT, cxt, ul_debug("checking for helper"));
 
        if (cxt->helper) {
                free(cxt->helper);
@@ -2220,7 +2220,7 @@ int mnt_context_prepare_helper(struct libmnt_context *cxt, const char *name,
                        found = mnt_is_path(helper);
                }
 
-               DBG(CXT, ul_debugobj(cxt, "%-25s ... %s", helper,
+               DBG_OBJ(CXT, cxt, ul_debug("%-25s ... %s", helper,
                                        found ? "found" : "not found"));
                if (!found)
                        continue;
@@ -2271,10 +2271,10 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
        assert(cxt->action);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "--> prepare update"));
+       DBG_OBJ(CXT, cxt, ul_debug("--> prepare update"));
 
        if (mnt_context_propagation_only(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "skip update: only MS_PROPAGATION"));
+               DBG_OBJ(CXT, cxt, ul_debug("skip update: only MS_PROPAGATION"));
                return 0;
        }
 
@@ -2282,22 +2282,22 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
        source = mnt_fs_get_srcpath(cxt->fs);
 
        if (cxt->action == MNT_ACT_UMOUNT && target && !strcmp(target, "/")) {
-               DBG(CXT, ul_debugobj(cxt, "root umount: setting NOMTAB"));
+               DBG_OBJ(CXT, cxt, ul_debug("root umount: setting NOMTAB"));
                mnt_context_disable_mtab(cxt, TRUE);
        }
        if (mnt_context_is_nomtab(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "skip update: NOMTAB flag"));
+               DBG_OBJ(CXT, cxt, ul_debug("skip update: NOMTAB flag"));
                return 0;
        }
        name = mnt_context_get_writable_tabpath(cxt);
        if (!name) {
-               DBG(CXT, ul_debugobj(cxt, "skip update: no writable destination"));
+               DBG_OBJ(CXT, cxt, ul_debug("skip update: no writable destination"));
                return 0;
        }
 
        /* 0 = success, 1 = not called yet */
        if (cxt->syscall_status != 1 && cxt->syscall_status != 0) {
-               DBG(CXT, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                                "skip update: syscall failed [status=%d]",
                                cxt->syscall_status));
                return 0;
@@ -2309,14 +2309,14 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
 
        if ((cxt->action == MNT_ACT_UMOUNT || mnt_optlist_is_move(ol))
            && is_file_empty(name)) {
-               DBG(CXT, ul_debugobj(cxt, "skip update: umount/move, empty table"));
+               DBG_OBJ(CXT, cxt, ul_debug("skip update: umount/move, empty table"));
                return 0;
        }
 
        if (mnt_optlist_is_move(ol) &&
            ((target && startswithpath(name, target))
             || (source && startswithpath(name, source)))) {
-               DBG(CXT, ul_debugobj(cxt, "skip update: utab move"));
+               DBG_OBJ(CXT, cxt, ul_debug("skip update: utab move"));
                return 0;
        }
 
@@ -2338,7 +2338,7 @@ int mnt_context_prepare_update(struct libmnt_context *cxt)
                                        NULL, cxt->fs);
 
        if (mnt_update_is_ready(cxt->update)) {
-               DBG(CXT, ul_debugobj(cxt, "update is ready"));
+               DBG_OBJ(CXT, cxt, ul_debug("update is ready"));
                mnt_update_start(cxt->update);
        }
        return rc < 0 ? rc : 0;
@@ -2352,11 +2352,11 @@ int mnt_context_update_tabs(struct libmnt_context *cxt)
        assert(cxt);
 
        if (mnt_context_is_nomtab(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "don't update: NOMTAB flag"));
+               DBG_OBJ(CXT, cxt, ul_debug("don't update: NOMTAB flag"));
                return 0;
        }
        if (!cxt->update || !mnt_update_is_ready(cxt->update)) {
-               DBG(CXT, ul_debugobj(cxt, "don't update: no update prepared"));
+               DBG_OBJ(CXT, cxt, ul_debug("don't update: no update prepared"));
                return 0;
        }
 
@@ -2370,11 +2370,11 @@ int mnt_context_update_tabs(struct libmnt_context *cxt)
            && mnt_context_utab_writable(cxt)) {
 
                if (mnt_update_already_done(cxt->update)) {
-                       DBG(CXT, ul_debugobj(cxt, "don't update: error evaluate or already updated"));
+                       DBG_OBJ(CXT, cxt, ul_debug("don't update: error evaluate or already updated"));
                        goto emit;
                }
        } else if (cxt->helper) {
-               DBG(CXT, ul_debugobj(cxt, "don't update: external helper"));
+               DBG_OBJ(CXT, cxt, ul_debug("don't update: external helper"));
                goto end;
        }
 
@@ -2382,7 +2382,7 @@ int mnt_context_update_tabs(struct libmnt_context *cxt)
            && !(mnt_context_helper_executed(cxt) &&
                 mnt_context_get_helper_status(cxt) == 0)) {
 
-               DBG(CXT, ul_debugobj(cxt, "don't update: syscall/helper failed/not called"));
+               DBG_OBJ(CXT, cxt, ul_debug("don't update: syscall/helper failed/not called"));
                goto end;
        }
 
@@ -2413,10 +2413,10 @@ static int apply_fs(struct libmnt_context *cxt, struct libmnt_fs *fs, unsigned l
 
        if (!cxt->optsmode) {
                if (mnt_context_is_restricted(cxt)) {
-                       DBG(CXT, ul_debugobj(cxt, "force fstab usage for non-root users!"));
+                       DBG_OBJ(CXT, cxt, ul_debug("force fstab usage for non-root users!"));
                        cxt->optsmode = MNT_OMODE_USER;
                } else {
-                       DBG(CXT, ul_debugobj(cxt, "use default optsmode"));
+                       DBG_OBJ(CXT, cxt, ul_debug("use default optsmode"));
                        cxt->optsmode = MNT_OMODE_AUTO;
                }
 
@@ -2425,9 +2425,9 @@ static int apply_fs(struct libmnt_context *cxt, struct libmnt_fs *fs, unsigned l
        if (!mnt_context_get_fs(cxt))
                return -ENOMEM;
 
-       DBG(CXT, ul_debugobj(cxt, "apply entry:"));
+       DBG_OBJ(CXT, cxt, ul_debug("apply entry:"));
        DBG(CXT, mnt_fs_print_debug(fs, stderr));
-       DBG(CXT, ul_debugobj(cxt, "OPTSMODE (opt-part): ignore=%d, append=%d, prepend=%d, replace=%d",
+       DBG_OBJ(CXT, cxt, ul_debug("OPTSMODE (opt-part): ignore=%d, append=%d, prepend=%d, replace=%d",
                                  cxt->optsmode & MNT_OMODE_IGNORE ? 1 : 0,
                                  cxt->optsmode & MNT_OMODE_APPEND ? 1 : 0,
                                  cxt->optsmode & MNT_OMODE_PREPEND ? 1 : 0,
@@ -2475,7 +2475,7 @@ static int apply_fs(struct libmnt_context *cxt, struct libmnt_fs *fs, unsigned l
                cxt->flags |= MNT_FL_TAB_APPLIED;
 
 done:
-       DBG(CXT, ul_debugobj(cxt, "final entry [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("final entry [rc=%d]", rc));
        DBG(CXT, mnt_fs_print_debug(cxt->fs, stderr));
 
        return rc;
@@ -2550,15 +2550,15 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
                return -EINVAL;
 
        if (mnt_context_tab_applied(cxt)) {     /* already applied */
-               DBG(CXT, ul_debugobj(cxt, "fstab already applied -- skip"));
+               DBG_OBJ(CXT, cxt, ul_debug("fstab already applied -- skip"));
                return 0;
        }
 
        if (mnt_context_is_restricted(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "force fstab usage for non-root users!"));
+               DBG_OBJ(CXT, cxt, ul_debug("force fstab usage for non-root users!"));
                cxt->optsmode = MNT_OMODE_USER;
        } else if (cxt->optsmode == 0) {
-               DBG(CXT, ul_debugobj(cxt, "use default optsmode"));
+               DBG_OBJ(CXT, cxt, ul_debug("use default optsmode"));
                cxt->optsmode = MNT_OMODE_AUTO;
        } else if (cxt->optsmode & MNT_OMODE_NOTAB) {
                cxt->optsmode &= ~MNT_OMODE_FSTAB;
@@ -2576,21 +2576,21 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
                tgt = mnt_fs_get_target(cxt->fs);
        }
 
-       DBG(CXT, ul_debugobj(cxt, "OPTSMODE (file-part): force=%d, fstab=%d, mtab=%d",
+       DBG_OBJ(CXT, cxt, ul_debug("OPTSMODE (file-part): force=%d, fstab=%d, mtab=%d",
                                  cxt->optsmode & MNT_OMODE_FORCE ? 1 : 0,
                                  cxt->optsmode & MNT_OMODE_FSTAB ? 1 : 0,
                                  cxt->optsmode & MNT_OMODE_MTAB ? 1 : 0));
 
        /* fstab is not required if source and target are specified */
        if (src && tgt && !(cxt->optsmode & MNT_OMODE_FORCE)) {
-               DBG(CXT, ul_debugobj(cxt, "fstab not required -- skip"));
+               DBG_OBJ(CXT, cxt, ul_debug("fstab not required -- skip"));
                return 0;
        }
 
        if (!src && tgt
            && !(cxt->optsmode & MNT_OMODE_FSTAB)
            && !(cxt->optsmode & MNT_OMODE_MTAB)) {
-               DBG(CXT, ul_debugobj(cxt, "only target; fstab/mtab not required "
+               DBG_OBJ(CXT, cxt, ul_debug("only target; fstab/mtab not required "
                                          "-- skip, probably MS_PROPAGATION"));
                return 0;
        }
@@ -2604,7 +2604,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
 
        /* try fstab */
        if (cxt->optsmode & MNT_OMODE_FSTAB) {
-               DBG(CXT, ul_debugobj(cxt, "trying to apply fstab (src=%s, target=%s)", src, tgt));
+               DBG_OBJ(CXT, cxt, ul_debug("trying to apply fstab (src=%s, target=%s)", src, tgt));
                rc = mnt_context_get_fstab(cxt, &tab);
                if (!rc)
                        rc = apply_table(cxt, tab, MNT_ITER_FORWARD, mflags);
@@ -2613,7 +2613,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
        /* try mountinfo */
        if (rc < 0 && (cxt->optsmode & MNT_OMODE_MTAB)
            && (isremount || cxt->action == MNT_ACT_UMOUNT)) {
-               DBG(CXT, ul_debugobj(cxt, "trying to apply mountinfo (src=%s, target=%s)", src, tgt));
+               DBG_OBJ(CXT, cxt, ul_debug("trying to apply mountinfo (src=%s, target=%s)", src, tgt));
                if (tgt)
                        rc = mnt_context_get_mountinfo_for_target(cxt, &tab, tgt);
                else
@@ -2629,11 +2629,11 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt)
                if (!mnt_context_is_restricted(cxt)
                    && tgt && !src
                    && isremount) {
-                       DBG(CXT, ul_debugobj(cxt, "only target; ignore missing mountinfo entry on remount"));
+                       DBG_OBJ(CXT, cxt, ul_debug("only target; ignore missing mountinfo entry on remount"));
                        return 0;
                }
 
-               DBG(CXT, ul_debugobj(cxt, "failed to find entry in fstab/mountinfo [rc=%d]: %m", rc));
+               DBG_OBJ(CXT, cxt, ul_debug("failed to find entry in fstab/mountinfo [rc=%d]: %m", rc));
 
                /* force to "not found in fstab/mountinfo" error, the details why
                 * not found are not so important and may be misinterpreted by
@@ -2766,7 +2766,7 @@ int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "syscall status set to: %d", status));
+       DBG_OBJ(CXT, cxt, ul_debug("syscall status set to: %d", status));
        cxt->syscall_status = status;
        return 0;
 }
@@ -3022,7 +3022,7 @@ int mnt_context_get_excode(
                break;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "excode: rc=%d message=\"%s\"", rc,
+       DBG_OBJ(CXT, cxt, ul_debug("excode: rc=%d message=\"%s\"", rc,
                                buf ? buf : "<no-message>"));
        return rc;
 }
@@ -3058,7 +3058,7 @@ int mnt_context_init_helper(struct libmnt_context *cxt, int action,
        if (!rc)
                cxt->action = action;
 
-       DBG(CXT, ul_debugobj(cxt, "initialized for [u]mount.<type> helper [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("initialized for [u]mount.<type> helper [rc=%d]", rc));
        return rc;
 }
 
@@ -3151,7 +3151,7 @@ static int mnt_context_add_child(struct libmnt_context *cxt, pid_t pid)
        if (!pids)
                return -ENOMEM;
 
-       DBG(CXT, ul_debugobj(cxt, "add new child %d", pid));
+       DBG_OBJ(CXT, cxt, ul_debug("add new child %d", pid));
        cxt->children = pids;
        cxt->children[cxt->nchildren++] = pid;
 
@@ -3167,7 +3167,7 @@ int mnt_fork_context(struct libmnt_context *cxt)
        if (!mnt_context_is_parent(cxt))
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "forking context"));
+       DBG_OBJ(CXT, cxt, ul_debug("forking context"));
 
        DBG_FLUSH;
 
@@ -3175,13 +3175,13 @@ int mnt_fork_context(struct libmnt_context *cxt)
 
        switch (pid) {
        case -1: /* error */
-               DBG(CXT, ul_debugobj(cxt, "fork failed %m"));
+               DBG_OBJ(CXT, cxt, ul_debug("fork failed %m"));
                return -errno;
 
        case 0: /* child */
                cxt->pid = getpid();
                mnt_context_enable_fork(cxt, FALSE);
-               DBG(CXT, ul_debugobj(cxt, "child created"));
+               DBG_OBJ(CXT, cxt, ul_debug("child created"));
                break;
 
        default:
@@ -3209,7 +3209,7 @@ int mnt_context_wait_for_children(struct libmnt_context *cxt,
                if (!pid)
                        continue;
                do {
-                       DBG(CXT, ul_debugobj(cxt,
+                       DBG_OBJ(CXT, cxt, ul_debug(
                                        "waiting for child (%d/%d): %d",
                                        i + 1, cxt->nchildren, pid));
                        errno = 0;
@@ -3267,7 +3267,7 @@ int mnt_context_set_target_ns(struct libmnt_context *cxt, const char *path)
        if (!cxt)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "Setting %s as target namespace", path));
+       DBG_OBJ(CXT, cxt, ul_debug("Setting %s as target namespace", path));
 
        /* cleanup only */
        if (!path) {
@@ -3296,11 +3296,11 @@ int mnt_context_set_target_ns(struct libmnt_context *cxt, const char *path)
                return -errno;
 
        /* test whether namespace switching works */
-       DBG(CXT, ul_debugobj(cxt, "Trying whether namespace is valid"));
+       DBG_OBJ(CXT, cxt, ul_debug("Trying whether namespace is valid"));
        if (setns(tmp, CLONE_NEWNS)
            || setns(cxt->ns_orig.fd, CLONE_NEWNS)) {
                errsv = errno;
-               DBG(CXT, ul_debugobj(cxt, "setns(2) failed [errno=%d %m]", errno));
+               DBG_OBJ(CXT, cxt, ul_debug("setns(2) failed [errno=%d %m]", errno));
                goto err;
        }
 
@@ -3392,14 +3392,14 @@ struct libmnt_ns *mnt_context_switch_ns(struct libmnt_context *cxt, struct libmn
        }
 
        /* switch */
-       DBG(CXT, ul_debugobj(cxt, "Switching to %s namespace",
+       DBG_OBJ(CXT, cxt, ul_debug("Switching to %s namespace",
                ns == mnt_context_get_target_ns(cxt) ? "target" :
                ns == mnt_context_get_origin_ns(cxt) ? "original" : "other"));
 
        if (setns(ns->fd, CLONE_NEWNS)) {
                int errsv = errno;
 
-               DBG(CXT, ul_debugobj(cxt, "setns(2) failed [errno=%d %m]", errno));
+               DBG_OBJ(CXT, cxt, ul_debug("setns(2) failed [errno=%d %m]", errno));
                errno = errsv;
                return NULL;
        }
index 2de6766cda53777f1ee83382b3235c473df79ee1..1d1f851ec2b229e05b7148ea01efe08585a4dd4f 100644 (file)
@@ -52,7 +52,7 @@ static int fix_optstr(struct libmnt_context *cxt)
        if (cxt->flags & MNT_FL_MOUNTOPTS_FIXED)
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "--> preparing options"));
+       DBG_OBJ(CXT, cxt, ul_debug("--> preparing options"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -138,7 +138,7 @@ static int fix_optstr(struct libmnt_context *cxt)
 #endif
        rc = mnt_context_call_hooks(cxt, MNT_STAGE_PREP_OPTIONS);
 done:
-       DBG(CXT, ul_debugobj(cxt, "<-- preparing options done [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("<-- preparing options done [rc=%d]", rc));
        cxt->flags |= MNT_FL_MOUNTOPTS_FIXED;
 
        if (rc)
@@ -167,7 +167,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
        if (!cxt->fs)
                return 0;
 
-       DBG(CXT, ul_debugobj(cxt, "mount: evaluating permissions"));
+       DBG_OBJ(CXT, cxt, ul_debug("mount: evaluating permissions"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -186,7 +186,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
        if (user_flags & MNT_MS_USER
            && (opt = mnt_optlist_get_opt(ol, MNT_MS_USER, cxt->map_userspace))
            && mnt_opt_has_value(opt)) {
-               DBG(CXT, ul_debugobj(cxt, "perms: user=<name> detected, ignore"));
+               DBG_OBJ(CXT, cxt, ul_debug("perms: user=<name> detected, ignore"));
 
                cxt->flags |= MNT_FL_SAVED_USER;
 
@@ -227,7 +227,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                        rc = mnt_optlist_remove_flags(ol,
                                        MNT_MS_OWNER | MNT_MS_GROUP, cxt->map_userspace);
 
-               DBG(CXT, ul_debugobj(cxt, "perms: superuser [rc=%d]", rc));
+               DBG_OBJ(CXT, cxt, ul_debug("perms: superuser [rc=%d]", rc));
                if (rc)
                        return rc;
 
@@ -241,7 +241,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                 */
                if (!mnt_context_tab_applied(cxt))
                {
-                       DBG(CXT, ul_debugobj(cxt, "perms: fstab not applied, ignore user mount"));
+                       DBG_OBJ(CXT, cxt, ul_debug("perms: fstab not applied, ignore user mount"));
                        return -EPERM;
                }
 
@@ -271,7 +271,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                        char *xsrc = NULL;
                        const char *srcpath = mnt_fs_get_srcpath(cxt->fs);
 
-                       DBG(CXT, ul_debugobj(cxt, "perms: owner/group"));
+                       DBG_OBJ(CXT, cxt, ul_debug("perms: owner/group"));
 
                        if (!srcpath) {                                 /* Ah... source is TAG */
                                cache = mnt_context_get_cache(cxt);
@@ -281,7 +281,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                                srcpath = xsrc;
                        }
                        if (!srcpath) {
-                               DBG(CXT, ul_debugobj(cxt, "perms: src undefined"));
+                               DBG_OBJ(CXT, cxt, ul_debug("perms: src undefined"));
                                return -EPERM;
                        }
 
@@ -310,7 +310,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                }
 
                if (!(user_flags & (MNT_MS_USER | MNT_MS_USERS))) {
-                       DBG(CXT, ul_debugobj(cxt, "perms: evaluation ends with -EPERMS [flags=0x%08lx]", user_flags));
+                       DBG_OBJ(CXT, cxt, ul_debug("perms: evaluation ends with -EPERMS [flags=0x%08lx]", user_flags));
                        return -EPERM;
                }
 
@@ -388,7 +388,7 @@ static int exec_helper(struct libmnt_context *cxt)
        assert(cxt->helper);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "mount: executing helper %s", cxt->helper));
+       DBG_OBJ(CXT, cxt, ul_debug("mount: executing helper %s", cxt->helper));
 
        if (ns_tgt->fd != -1
            && asprintf(&namespace, "/proc/%i/fd/%i",
@@ -457,7 +457,7 @@ static int exec_helper(struct libmnt_context *cxt)
                }
                args[i] = NULL;                         /* 14 */
                for (i = 0; args[i]; i++)
-                       DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
+                       DBG_OBJ(CXT, cxt, ul_debug("argv[%d] = \"%s\"",
                                                        i, args[i]));
                DBG_FLUSH;
                execv(cxt->helper, (char * const *) args);
@@ -470,17 +470,17 @@ static int exec_helper(struct libmnt_context *cxt)
                if (waitpid(pid, &st, 0) == (pid_t) -1) {
                        cxt->helper_status = -1;
                        rc = -errno;
-                       DBG(CXT, ul_debugobj(cxt, "waitpid failed [errno=%d]", -rc));
+                       DBG_OBJ(CXT, cxt, ul_debug("waitpid failed [errno=%d]", -rc));
                } else {
                        cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
                        cxt->helper_exec_status = rc = 0;
 
                        if (cxt->helper_status == MNT_EX_EXEC) {
                                rc = -MNT_ERR_EXEC;
-                               DBG(CXT, ul_debugobj(cxt, "%s exec failed", cxt->helper));
+                               DBG_OBJ(CXT, cxt, ul_debug("%s exec failed", cxt->helper));
                        }
 
-                       DBG(CXT, ul_debugobj(cxt, "%s forked [status=%d, rc=%d]",
+                       DBG_OBJ(CXT, cxt, ul_debug("%s forked [status=%d, rc=%d]",
                                cxt->helper,
                                cxt->helper_status, rc));
                }
@@ -489,7 +489,7 @@ static int exec_helper(struct libmnt_context *cxt)
 
        case -1:
                cxt->helper_exec_status = rc = -errno;
-               DBG(CXT, ul_debugobj(cxt, "fork() failed"));
+               DBG_OBJ(CXT, cxt, ul_debug("fork() failed"));
                break;
        }
 
@@ -549,7 +549,7 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
                rc = mnt_context_call_hooks(cxt, MNT_STAGE_MOUNT);
 
        if (rc == 0 && mnt_context_is_fake(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "FAKE (-f) set status=0"));
+               DBG_OBJ(CXT, cxt, ul_debug("FAKE (-f) set status=0"));
                cxt->syscall_status = 0;
        }
 
@@ -600,7 +600,7 @@ static int do_mount_by_types(struct libmnt_context *cxt, const char *types)
        assert(cxt);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "trying to mount by FS list '%s'", types));
+       DBG_OBJ(CXT, cxt, ul_debug("trying to mount by FS list '%s'", types));
 
        p0 = p = strdup(types);
        if (!p)
@@ -612,19 +612,19 @@ static int do_mount_by_types(struct libmnt_context *cxt, const char *types)
                if (end)
                        *end = '\0';
 
-               DBG(CXT, ul_debugobj(cxt, "-->trying '%s'", p));
+               DBG_OBJ(CXT, cxt, ul_debug("-->trying '%s'", p));
 
                /* Let's support things like "udf,iso9660,auto" */
                if (strcmp(p, "auto") == 0) {
                        rc = mnt_context_guess_srcpath_fstype(cxt, &autotype);
                        if (rc) {
-                               DBG(CXT, ul_debugobj(cxt, "failed to guess FS type [rc=%d]", rc));
+                               DBG_OBJ(CXT, cxt, ul_debug("failed to guess FS type [rc=%d]", rc));
                                free(p0);
                                free(autotype);
                                return rc;
                        }
                        p = autotype;
-                       DBG(CXT, ul_debugobj(cxt, "   --> '%s'", p));
+                       DBG_OBJ(CXT, cxt, ul_debug("   --> '%s'", p));
                }
 
                if (p)
@@ -652,11 +652,11 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
         * Use the pattern as list of the filesystems
         */
        if (!neg && pattern) {
-               DBG(CXT, ul_debugobj(cxt, "use FS pattern as FS list"));
+               DBG_OBJ(CXT, cxt, ul_debug("use FS pattern as FS list"));
                return do_mount_by_types(cxt, pattern);
        }
 
-       DBG(CXT, ul_debugobj(cxt, "trying to mount by FS pattern '%s'", pattern));
+       DBG_OBJ(CXT, cxt, ul_debug("trying to mount by FS pattern '%s'", pattern));
 
        /*
         * Apply pattern to /etc/filesystems and /proc/filesystems
@@ -674,7 +674,7 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
                return -MNT_ERR_NOFSTYPE;
 
        for (fp = filesystems; *fp; fp++) {
-               DBG(CXT, ul_debugobj(cxt, " ##### trying '%s'", *fp));
+               DBG_OBJ(CXT, cxt, ul_debug(" ##### trying '%s'", *fp));
                rc = do_mount(cxt, *fp);
                if (is_termination_status(cxt))
                        break;
@@ -693,7 +693,7 @@ static int prepare_target(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       DBG(CXT, ul_debugobj(cxt, "--> preparing target path"));
+       DBG_OBJ(CXT, cxt, ul_debug("--> preparing target path"));
 
        tgt = mnt_fs_get_target(cxt->fs);
        if (!tgt)
@@ -743,7 +743,7 @@ static int prepare_target(struct libmnt_context *cxt)
        if (!mnt_context_switch_ns(cxt, ns_old))
                return -MNT_ERR_NAMESPACE;
 
-       DBG(CXT, ul_debugobj(cxt, "final target '%s' [rc=%d]",
+       DBG_OBJ(CXT, cxt, ul_debug("final target '%s' [rc=%d]",
                                mnt_fs_get_target(cxt->fs), rc));
        return rc;
 }
@@ -777,7 +777,7 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
        if (!ns_old)
                return -MNT_ERR_NAMESPACE;
 
-       DBG(CXT, ul_debugobj(cxt, "mount: preparing"));
+       DBG_OBJ(CXT, cxt, ul_debug("mount: preparing"));
 
        rc = mnt_context_apply_fstab(cxt);
        if (!rc)
@@ -810,7 +810,7 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
                rc = mnt_context_call_hooks(cxt, MNT_STAGE_PREP);
 
        if (rc) {
-               DBG(CXT, ul_debugobj(cxt, "mount: preparing failed"));
+               DBG_OBJ(CXT, cxt, ul_debug("mount: preparing failed"));
                goto end;
        }
 
@@ -859,7 +859,7 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
        assert((cxt->flags & MNT_FL_PREPARED));
        assert((cxt->action == MNT_ACT_MOUNT));
 
-       DBG(CXT, ul_debugobj(cxt, "mount: do mount"));
+       DBG_OBJ(CXT, cxt, ul_debug("mount: do mount"));
 
        ns_old = mnt_context_switch_target_ns(cxt);
        if (!ns_old)
@@ -891,7 +891,7 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
        if (!mnt_context_switch_ns(cxt, ns_old))
                return -MNT_ERR_NAMESPACE;
 
-       DBG(CXT, ul_debugobj(cxt, "mnt_context_do_mount() done [rc=%d]", res));
+       DBG_OBJ(CXT, cxt, ul_debug("mnt_context_do_mount() done [rc=%d]", res));
        return res;
 }
 
@@ -1074,7 +1074,7 @@ again:
                    && !mnt_context_is_rwonly_mount(cxt)) {     /* no explicit read-write */
 
                        assert(!(cxt->flags & MNT_FL_FORCED_RDONLY));
-                       DBG(CXT, ul_debugobj(cxt, "write-protected source, trying RDONLY."));
+                       DBG_OBJ(CXT, cxt, ul_debug("write-protected source, trying RDONLY."));
 
                        mnt_context_reset_status(cxt);
                        mnt_context_set_mflags(cxt, mflags | MS_RDONLY);
@@ -1092,7 +1092,7 @@ again:
                struct libmnt_optlist *ol = mnt_context_get_optlist(cxt);
 
                mnt_context_reset_status(cxt);
-               DBG(CXT, ul_debugobj(cxt, "enabling loop= for EROFS"));
+               DBG_OBJ(CXT, cxt, ul_debug("enabling loop= for EROFS"));
                mnt_optlist_append_flags(ol, MNT_MS_LOOP, cxt->map_userspace);
 
                rc = mnt_context_call_hooks(cxt, MNT_STAGE_PREP_SOURCE);
@@ -1108,7 +1108,7 @@ again:
        if (!mnt_context_switch_ns(cxt, ns_old))
                rc = -MNT_ERR_NAMESPACE;
 
-       DBG(CXT, ul_debugobj(cxt, "mnt_context_mount() done [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("mnt_context_mount() done [rc=%d]", rc));
        return rc;
 }
 
@@ -1175,7 +1175,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, ul_debugobj(cxt, "next-mount: trying %s", tgt));
+       DBG_OBJ(CXT, cxt, ul_debug("next-mount: trying %s", tgt));
 
        /*  ignore swap */
        if (mnt_fs_is_swaparea(*fs) ||
@@ -1195,7 +1195,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
                                        cxt->optstr_pattern))) {
                if (ignored)
                        *ignored = 1;
-               DBG(CXT, ul_debugobj(cxt, "next-mount: not-match "
+               DBG_OBJ(CXT, cxt, ul_debug("next-mount: not-match "
                                "[fstype: %s, t-pattern: %s, options: %s, O-pattern: %s]",
                                mnt_fs_get_fstype(*fs),
                                cxt->fstype_pattern,
@@ -1208,7 +1208,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
        rc = mnt_context_is_fs_mounted(cxt, *fs, &mounted);
        if (rc) {
                if (mnt_table_is_empty(cxt->mountinfo)) {
-                       DBG(CXT, ul_debugobj(cxt, "next-mount: no mount table [rc=%d], ignore", rc));
+                       DBG_OBJ(CXT, cxt, ul_debug("next-mount: no mount table [rc=%d], ignore", rc));
                        rc = 0;
                        if (ignored)
                                *ignored = 1;
@@ -1272,7 +1272,7 @@ int mnt_context_next_mount(struct libmnt_context *cxt,
        }
 
        if (mnt_context_is_child(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "next-mount: child exit [rc=%d]", rc));
+               DBG_OBJ(CXT, cxt, ul_debug("next-mount: child exit [rc=%d]", rc));
                DBG_FLUSH;
                _exit(rc);
        }
@@ -1345,7 +1345,7 @@ int mnt_context_next_remount(struct libmnt_context *cxt,
 
        tgt = mnt_fs_get_target(*fs);
 
-       DBG(CXT, ul_debugobj(cxt, "next-remount: trying %s", tgt));
+       DBG_OBJ(CXT, cxt, ul_debug("next-remount: trying %s", tgt));
 
        /* ignore filesystems which don't match options patterns */
        if ((cxt->fstype_pattern && !mnt_fs_match_fstype(*fs,
@@ -1356,7 +1356,7 @@ int mnt_context_next_remount(struct libmnt_context *cxt,
                                        cxt->optstr_pattern))) {
                if (ignored)
                        *ignored = 1;
-               DBG(CXT, ul_debugobj(cxt, "next-remount: not-match "
+               DBG_OBJ(CXT, cxt, ul_debug("next-remount: not-match "
                                "[fstype: %s, t-pattern: %s, options: %s, O-pattern: %s]",
                                mnt_fs_get_fstype(*fs),
                                cxt->fstype_pattern,
index 68b93ef06a461e7684b23debbc1b9799b35da93e..a0a7fe9248666bc06fca66df508113bddd03a778 100644 (file)
@@ -59,7 +59,7 @@ static int __mountinfo_find_umount_fs(struct libmnt_context *cxt,
        assert(pfs);
 
        *pfs = NULL;
-       DBG(CXT, ul_debugobj(cxt, " search %s in mountinfo", tgt));
+       DBG_OBJ(CXT, cxt, ul_debug(" search %s in mountinfo", tgt));
 
        /*
         * The mount table may be huge, and on systems with utab we have to
@@ -84,12 +84,12 @@ static int __mountinfo_find_umount_fs(struct libmnt_context *cxt,
                rc = mnt_context_get_mountinfo(cxt, &mountinfo);
 
        if (rc) {
-               DBG(CXT, ul_debugobj(cxt, "umount: failed to read mountinfo"));
+               DBG_OBJ(CXT, cxt, ul_debug("umount: failed to read mountinfo"));
                return rc;
        }
 
        if (mnt_table_get_nents(mountinfo) == 0) {
-               DBG(CXT, ul_debugobj(cxt, "umount: mountinfo empty"));
+               DBG_OBJ(CXT, cxt, ul_debug("umount: mountinfo empty"));
                return 1;
        }
 
@@ -111,14 +111,14 @@ try_loopdev:
                                                        mnt_fs_get_target(fs),
                                                        MNT_ITER_BACKWARD);
                        if (!fs1) {
-                               DBG(CXT, ul_debugobj(cxt, "mountinfo is broken?!?!"));
+                               DBG_OBJ(CXT, cxt, ul_debug("mountinfo is broken?!?!"));
                                rc = -EINVAL;
                                goto err;
                        }
                        if (fs != fs1) {
                                /* Something was stacked over `file' on the
                                 * same mount point. */
-                               DBG(CXT, ul_debugobj(cxt,
+                               DBG_OBJ(CXT, cxt, ul_debug(
                                                "umount: %s: %s is mounted "
                                                "over it on the same point",
                                                tgt, mnt_fs_get_source(fs1)));
@@ -141,13 +141,13 @@ try_loopdev:
 
                        count = loopdev_count_by_backing_file(bf, &loopdev);
                        if (count == 1) {
-                               DBG(CXT, ul_debugobj(cxt,
+                               DBG_OBJ(CXT, cxt, ul_debug(
                                        "umount: %s --> %s (retry)", tgt, loopdev));
                                tgt = loopdev;
                                goto try_loopdev;
 
                        } else if (count > 1)
-                               DBG(CXT, ul_debugobj(cxt,
+                               DBG_OBJ(CXT, cxt, ul_debug(
                                        "umount: warning: %s is associated "
                                        "with more than one loopdev", tgt));
                }
@@ -158,7 +158,7 @@ try_loopdev:
        if (!mnt_context_switch_ns(cxt, ns_old))
                return -MNT_ERR_NAMESPACE;
 
-       DBG(CXT, ul_debugobj(cxt, "umount fs: %s", fs ? mnt_fs_get_target(fs) :
+       DBG_OBJ(CXT, cxt, ul_debug("umount fs: %s", fs ? mnt_fs_get_target(fs) :
                                                        "<not found>"));
        return fs ? 0 : 1;
 err:
@@ -186,7 +186,7 @@ int mnt_context_find_umount_fs(struct libmnt_context *cxt,
        if (!cxt || !tgt || !pfs)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "umount: lookup FS for '%s'", tgt));
+       DBG_OBJ(CXT, cxt, ul_debug("umount: lookup FS for '%s'", tgt));
 
        if (!*tgt)
                return 1; /* empty string is not an error */
@@ -254,7 +254,7 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg
        assert(cxt);
        assert(cxt->fs);
 
-       DBG(CXT, ul_debugobj(cxt, " lookup by statfs"));
+       DBG_OBJ(CXT, cxt, ul_debug(" lookup by statfs"));
 
        /*
         * Let's try to avoid mountinfo usage at all to minimize performance
@@ -288,7 +288,7 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg
                struct statfs vfs;
                int fd;
 
-               DBG(CXT, ul_debugobj(cxt, "  trying fstatfs()"));
+               DBG_OBJ(CXT, cxt, ul_debug("  trying fstatfs()"));
 
                /* O_PATH avoids triggering automount points. */
                fd = open(tgt, O_PATH);
@@ -306,10 +306,10 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg
                }
        }
        if (type) {
-               DBG(CXT, ul_debugobj(cxt, "  umount: disabling mountinfo"));
+               DBG_OBJ(CXT, cxt, ul_debug("  umount: disabling mountinfo"));
                mnt_context_disable_mtab(cxt, TRUE);
 
-               DBG(CXT, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                        "  mountinfo unnecessary [type=%s]", type));
                return 0;
        }
@@ -326,7 +326,7 @@ static int lookup_umount_fs_by_mountinfo(struct libmnt_context *cxt, const char
        assert(cxt);
        assert(cxt->fs);
 
-       DBG(CXT, ul_debugobj(cxt, " lookup by mountinfo"));
+       DBG_OBJ(CXT, cxt, ul_debug(" lookup by mountinfo"));
 
        /* search */
        rc = __mountinfo_find_umount_fs(cxt, tgt, &fs);
@@ -339,10 +339,10 @@ static int lookup_umount_fs_by_mountinfo(struct libmnt_context *cxt, const char
                mnt_fs_set_target(cxt->fs, NULL);
 
                if (!mnt_copy_fs(cxt->fs, fs)) {
-                       DBG(CXT, ul_debugobj(cxt, "  failed to copy FS"));
+                       DBG_OBJ(CXT, cxt, ul_debug("  failed to copy FS"));
                        return -errno;
                }
-               DBG(CXT, ul_debugobj(cxt, "  mountinfo applied"));
+               DBG_OBJ(CXT, cxt, ul_debug("  mountinfo applied"));
        }
 
        cxt->flags |= MNT_FL_TAB_APPLIED;
@@ -364,11 +364,11 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
        assert(cxt);
        assert(cxt->fs);
 
-       DBG(CXT, ul_debugobj(cxt, "umount: lookup FS"));
+       DBG_OBJ(CXT, cxt, ul_debug("umount: lookup FS"));
 
        tgt = mnt_fs_get_target(cxt->fs);
        if (!tgt) {
-               DBG(CXT, ul_debugobj(cxt, " undefined target"));
+               DBG_OBJ(CXT, cxt, ul_debug(" undefined target"));
                return -EINVAL;
        }
 
@@ -382,7 +382,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
        if (rc <= 0)
                goto done;
 
-       DBG(CXT, ul_debugobj(cxt, " cannot find '%s'", tgt));
+       DBG_OBJ(CXT, cxt, ul_debug(" cannot find '%s'", tgt));
        return 0;       /* this is correct! */
 
 done:
@@ -394,7 +394,7 @@ done:
 
                rc = mnt_optlist_set_optstr(ol, mnt_fs_get_options(cxt->fs), NULL);
        }
-       DBG(CXT, ul_debugobj(cxt, "  lookup done [rc=%d]", rc));
+       DBG_OBJ(CXT, cxt, ul_debug("  lookup done [rc=%d]", rc));
        return rc;
 }
 
@@ -448,7 +448,7 @@ static int prepare_helper_from_option(struct libmnt_context *cxt,
                return 1;
 
        suffix = mnt_opt_get_value(opt);
-       DBG(CXT, ul_debugobj(cxt, "umount: umount.%s %s requested", suffix, name));
+       DBG_OBJ(CXT, cxt, ul_debug("umount: umount.%s %s requested", suffix, name));
 
        return mnt_context_prepare_helper(cxt, "umount", suffix);
 }
@@ -521,10 +521,10 @@ static int evaluate_permissions(struct libmnt_context *cxt)
        if (!mnt_context_is_restricted(cxt))
                 return 0;              /* superuser mount */
 
-       DBG(CXT, ul_debugobj(cxt, "umount: evaluating permissions"));
+       DBG_OBJ(CXT, cxt, ul_debug("umount: evaluating permissions"));
 
        if (!mnt_context_tab_applied(cxt)) {
-               DBG(CXT, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                                "cannot find %s in mountinfo and you are not root",
                                mnt_fs_get_target(cxt->fs)));
                goto eperm;
@@ -543,7 +543,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
         * if so then unmounting is allowed
         */
        if (is_fuse_usermount(cxt, &rc)) {
-               DBG(CXT, ul_debugobj(cxt, "fuse user mount, umount is allowed"));
+               DBG_OBJ(CXT, cxt, ul_debug("fuse user mount, umount is allowed"));
                return 0;
        }
        if (rc)
@@ -561,7 +561,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, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                                "umount: using bind source: %s", src));
        }
 
@@ -588,7 +588,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                                fs = NULL;
                }
                if (!fs) {
-                       DBG(CXT, ul_debugobj(cxt,
+                       DBG_OBJ(CXT, cxt, ul_debug(
                                        "umount %s: mountinfo disagrees with fstab",
                                        tgt));
                        goto eperm;
@@ -614,7 +614,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                goto eperm;
 
        if (fstab_flags & MNT_MS_USERS) {
-               DBG(CXT, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                        "umount: promiscuous setting ('users') in fstab"));
                return 0;
        }
@@ -629,7 +629,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                char *curr_user = NULL;
                struct libmnt_ns *ns_old;
 
-               DBG(CXT, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                                "umount: checking user=<username> from mountinfo"));
 
                ns_old = mnt_context_switch_origin_ns(cxt);
@@ -643,7 +643,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                        return -MNT_ERR_NAMESPACE;
                }
                if (!curr_user) {
-                       DBG(CXT, ul_debugobj(cxt, "umount %s: cannot "
+                       DBG_OBJ(CXT, cxt, ul_debug("umount %s: cannot "
                                "convert %d to username", tgt, getuid()));
                        goto eperm;
                }
@@ -662,11 +662,11 @@ static int evaluate_permissions(struct libmnt_context *cxt)
        }
 
        if (ok) {
-               DBG(CXT, ul_debugobj(cxt, "umount %s is allowed", tgt));
+               DBG_OBJ(CXT, cxt, ul_debug("umount %s is allowed", tgt));
                return 0;
        }
 eperm:
-       DBG(CXT, ul_debugobj(cxt, "umount is not allowed for you"));
+       DBG_OBJ(CXT, cxt, ul_debug("umount is not allowed for you"));
        return -EPERM;
 }
 
@@ -684,7 +684,7 @@ static int exec_helper(struct libmnt_context *cxt)
        assert(cxt->helper_exec_status == 1);
 
        if (mnt_context_is_fake(cxt)) {
-               DBG(CXT, ul_debugobj(cxt, "fake mode: does not execute helper"));
+               DBG_OBJ(CXT, cxt, ul_debug("fake mode: does not execute helper"));
                cxt->helper_exec_status = rc = 0;
                return rc;
        }
@@ -738,7 +738,7 @@ static int exec_helper(struct libmnt_context *cxt)
 
                args[i] = NULL;                                 /* 12 */
                for (i = 0; args[i]; i++)
-                       DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
+                       DBG_OBJ(CXT, cxt, ul_debug("argv[%d] = \"%s\"",
                                                        i, args[i]));
                DBG_FLUSH;
                execv(cxt->helper, (char * const *) args);
@@ -751,17 +751,17 @@ static int exec_helper(struct libmnt_context *cxt)
                if (waitpid(pid, &st, 0) == (pid_t) -1) {
                        cxt->helper_status = -1;
                        rc = -errno;
-                       DBG(CXT, ul_debugobj(cxt, "waitpid failed [errno=%d]", -rc));
+                       DBG_OBJ(CXT, cxt, ul_debug("waitpid failed [errno=%d]", -rc));
                } else {
                        cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
                        cxt->helper_exec_status = rc = 0;
 
                        if (cxt->helper_status == MNT_EX_EXEC) {
                                rc = -MNT_ERR_EXEC;
-                               DBG(CXT, ul_debugobj(cxt, "%s exec failed", cxt->helper));
+                               DBG_OBJ(CXT, cxt, ul_debug("%s exec failed", cxt->helper));
                        }
 
-                       DBG(CXT, ul_debugobj(cxt, "%s forked [status=%d, rc=%d]",
+                       DBG_OBJ(CXT, cxt, ul_debug("%s forked [status=%d, rc=%d]",
                                cxt->helper,
                                cxt->helper_status, rc));
                }
@@ -770,7 +770,7 @@ static int exec_helper(struct libmnt_context *cxt)
 
        case -1:
                cxt->helper_exec_status = rc = -errno;
-               DBG(CXT, ul_debugobj(cxt, "fork() failed"));
+               DBG_OBJ(CXT, cxt, ul_debug("fork() failed"));
                break;
        }
 
@@ -859,7 +859,7 @@ static int do_umount(struct libmnt_context *cxt)
        if (!target)
                return -EINVAL;
 
-       DBG(CXT, ul_debugobj(cxt, "do umount"));
+       DBG_OBJ(CXT, cxt, ul_debug("do umount"));
 
        if (mnt_context_is_restricted(cxt) && !mnt_context_is_fake(cxt)) {
                /*
@@ -882,7 +882,7 @@ static int do_umount(struct libmnt_context *cxt)
        if (mnt_context_is_force(cxt))
                flags |= MNT_FORCE;
 
-       DBG(CXT, ul_debugobj(cxt, "umount(2) [target='%s', flags=0x%08x]%s",
+       DBG_OBJ(CXT, cxt, ul_debug("umount(2) [target='%s', flags=0x%08x]%s",
                                target, flags,
                                mnt_context_is_fake(cxt) ? " (FAKE)" : ""));
 
@@ -920,7 +920,7 @@ static int do_umount(struct libmnt_context *cxt)
 
                mnt_context_enable_loopdel(cxt, FALSE);
 
-               DBG(CXT, ul_debugobj(cxt,
+               DBG_OBJ(CXT, cxt, ul_debug(
                        "umount(2) failed [errno=%d] -- trying to remount read-only",
                        -cxt->syscall_status));
 
@@ -928,27 +928,27 @@ static int do_umount(struct libmnt_context *cxt)
                            MS_REMOUNT | MS_RDONLY, NULL);
                if (rc < 0) {
                        cxt->syscall_status = -errno;
-                       DBG(CXT, ul_debugobj(cxt,
+                       DBG_OBJ(CXT, cxt, ul_debug(
                                "read-only re-mount(2) failed [errno=%d]",
                                -cxt->syscall_status));
 
                        return -cxt->syscall_status;
                }
                cxt->syscall_status = 0;
-               DBG(CXT, ul_debugobj(cxt, "read-only re-mount(2) success"));
+               DBG_OBJ(CXT, cxt, ul_debug("read-only re-mount(2) success"));
                mnt_fs_mark_attached(cxt->fs);
                return 0;
        }
 
        if (rc < 0) {
-               DBG(CXT, ul_debugobj(cxt, "umount(2) failed [errno=%d]",
+               DBG_OBJ(CXT, cxt, ul_debug("umount(2) failed [errno=%d]",
                        -cxt->syscall_status));
                return -cxt->syscall_status;
        }
 
        cxt->syscall_status = 0;
        mnt_fs_mark_detached(cxt->fs);
-       DBG(CXT, ul_debugobj(cxt, "umount(2) success"));
+       DBG_OBJ(CXT, cxt, ul_debug("umount(2) success"));
        return 0;
 }
 
@@ -1015,7 +1015,7 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt)
        }
 
        if (rc) {
-               DBG(CXT, ul_debugobj(cxt, "umount: preparing failed"));
+               DBG_OBJ(CXT, cxt, ul_debug("umount: preparing failed"));
                return rc;
        }
        cxt->flags |= MNT_FL_PREPARED;
@@ -1141,7 +1141,7 @@ int mnt_context_umount(struct libmnt_context *cxt)
        assert(cxt->helper_exec_status == 1);
        assert(cxt->syscall_status == 1);
 
-       DBG(CXT, ul_debugobj(cxt, "umount: %s", mnt_context_get_target(cxt)));
+       DBG_OBJ(CXT, cxt, ul_debug("umount: %s", mnt_context_get_target(cxt)));
 
        ns_old = mnt_context_switch_target_ns(cxt);
        if (!ns_old)
@@ -1224,7 +1224,7 @@ int mnt_context_next_umount(struct libmnt_context *cxt,
                tgt = mnt_fs_get_target(*fs);
        } while (!tgt);
 
-       DBG(CXT, ul_debugobj(cxt, "next-umount: trying %s [fstype: %s, t-pattern: %s, options: %s, O-pattern: %s]", tgt,
+       DBG_OBJ(CXT, cxt, ul_debug("next-umount: trying %s [fstype: %s, t-pattern: %s, options: %s, O-pattern: %s]", tgt,
                                 mnt_fs_get_fstype(*fs), cxt->fstype_pattern, mnt_fs_get_options(*fs), cxt->optstr_pattern));
 
        /* ignore filesystems which don't match options patterns */
@@ -1237,7 +1237,7 @@ int mnt_context_next_umount(struct libmnt_context *cxt,
                if (ignored)
                        *ignored = 1;
 
-               DBG(CXT, ul_debugobj(cxt, "next-umount: not-match"));
+               DBG_OBJ(CXT, cxt, ul_debug("next-umount: not-match"));
                return 0;
        }
 
index ada5fde43ae93e0a008a181a3bd3f545becea8da..9c8e22cf92c6b3e28e2491ba76ece66ee7cab567 100644 (file)
@@ -40,7 +40,7 @@ struct libmnt_fs *mnt_new_fs(void)
 
        fs->refcount = 1;
        INIT_LIST_HEAD(&fs->ents);
-       DBG(FS, ul_debugobj(fs, "alloc"));
+       DBG_OBJ(FS, fs, ul_debug("alloc"));
        return fs;
 }
 
@@ -58,7 +58,7 @@ void mnt_free_fs(struct libmnt_fs *fs)
        if (!fs)
                return;
 
-       DBG(FS, ul_debugobj(fs, "free [refcount=%d]", fs->refcount));
+       DBG_OBJ(FS, fs, ul_debug("free [refcount=%d]", fs->refcount));
 
        mnt_reset_fs(fs);
        free(fs);
@@ -121,7 +121,7 @@ void mnt_ref_fs(struct libmnt_fs *fs)
 {
        if (fs) {
                fs->refcount++;
-               /*DBG(FS, ul_debugobj(fs, "ref=%d", fs->refcount));*/
+               /*DBG_OBJ(FS, fs, ul_debug("ref=%d", fs->refcount));*/
        }
 }
 
@@ -136,7 +136,7 @@ void mnt_unref_fs(struct libmnt_fs *fs)
 {
        if (fs) {
                fs->refcount--;
-               /*DBG(FS, ul_debugobj(fs, "unref=%d", fs->refcount));*/
+               /*DBG_OBJ(FS, fs, ul_debug("unref=%d", fs->refcount));*/
                if (fs->refcount <= 0)
                        mnt_free_fs(fs);
        }
@@ -213,10 +213,10 @@ static inline int sync_opts_from_optlist(struct libmnt_fs *fs, struct libmnt_opt
                        rc = strdup_to_struct_member(fs, user_optstr, p);
 
                if (rc) {
-                       DBG(FS, ul_debugobj(fs, "sync failed [rc=%d]", rc));
+                       DBG_OBJ(FS, fs, ul_debug("sync failed [rc=%d]", rc));
                        return rc;
                } else {
-                       DBG(FS, ul_debugobj(fs, "synced: "
+                       DBG_OBJ(FS, fs, ul_debug("synced: "
                                "vfs: '%s' fs: '%s' user: '%s', optstr: '%s'",
                                fs->vfs_optstr, fs->fs_optstr, fs->user_optstr, fs->optstr));
                        fs->opts_age = age;
index 599ee8c521fad4ffaf9606a8be4a679b1d636769..4fe4688ab85ed13483e5a33d373a98f8be618835 100644 (file)
@@ -43,7 +43,7 @@ struct libmnt_statmnt *mnt_new_statmnt(void)
                return NULL;
 
        sm->refcount = 1;
-       DBG(STATMNT, ul_debugobj(sm, "alloc"));
+       DBG_OBJ(STATMNT, sm, ul_debug("alloc"));
        return sm;
 #else
        errno = ENOSYS;
@@ -61,7 +61,7 @@ void mnt_ref_statmnt(struct libmnt_statmnt *sm)
 {
        if (sm) {
                sm->refcount++;
-               /*DBG(STATMNT, ul_debugobj(sm, "ref=%d", sm->refcount));*/
+               /*DBG_OBJ(STATMNT, sm, ul_debug("ref=%d", sm->refcount));*/
        }
 }
 
@@ -76,7 +76,7 @@ void mnt_unref_statmnt(struct libmnt_statmnt *sm)
 {
        if (sm) {
                sm->refcount--;
-               /*DBG(STATMNT, ul_debugobj(sm, "unref=%d", sm->refcount));*/
+               /*DBG_OBJ(STATMNT, sm, ul_debug("unref=%d", sm->refcount));*/
                if (sm->refcount <= 0) {
                        free(sm->buf);
                        free(sm);
@@ -97,7 +97,7 @@ int mnt_statmnt_set_mask(struct libmnt_statmnt *sm, uint64_t mask)
                return -EINVAL;
        sm->mask = mask;
 
-       DBG(STATMNT, ul_debugobj(sm, "mask=0x%" PRIx64, sm->mask));
+       DBG_OBJ(STATMNT, sm, ul_debug("mask=0x%" PRIx64, sm->mask));
        return 0;
 }
 
@@ -123,7 +123,7 @@ int mnt_statmnt_disable_fetching(struct libmnt_statmnt *sm, int disable)
        sm->disabled = disable ? 1 : 0;
 
        /*
-       DBG(STATMNT, ul_debugobj(sm, "statmount() %s",
+       DBG_OBJ(STATMNT, sm, ul_debug("statmount() %s",
                                sm->disabled ? "off" : "on"));
        */
        return old;
@@ -303,7 +303,7 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask)
        if (!fs)
                return -EINVAL;
 
-       DBG(FS, ul_debugobj(fs, "statmount fetch"));
+       DBG_OBJ(FS, fs, ul_debug("statmount fetch"));
 
        /* add default mask if on-demand enabled */
        if (fs->stmnt
@@ -335,7 +335,7 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask)
                rc = mnt_id_from_path(fs->target, &fs->uniq_id, NULL);
                if (rc)
                        goto done;
-               DBG(FS, ul_debugobj(fs, " uniq-ID=%" PRIu64, fs->uniq_id));
+               DBG_OBJ(FS, fs, ul_debug(" uniq-ID=%" PRIu64, fs->uniq_id));
        }
 
        /* fetch all missing information by default */
@@ -359,7 +359,7 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask)
                ns = fs->ns_id;
 
        if (fs->stmnt) {
-               DBG(FS, ul_debugobj(fs, " reuse libmnt_stmnt"));
+               DBG_OBJ(FS, fs, ul_debug(" reuse libmnt_stmnt"));
 
                /* note that ul_statmount() (re)allocates the buffer */
                if (fs->stmnt->buf && fs->stmnt->bufsiz > 0)
@@ -370,10 +370,10 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask)
                buf = fs->stmnt->buf;
                bufsiz = fs->stmnt->bufsiz;
        } else {
-               DBG(FS, ul_debugobj(fs, " use private buffer"));
+               DBG_OBJ(FS, fs, ul_debug(" use private buffer"));
                rc = ul_statmount(fs->uniq_id, 0, mask, &buf, &bufsiz, 0);
        }
-       DBG(FS, ul_debugobj(fs, " statmount [rc=%d bufsiz=%zu ns=%" PRIu64 " mask: %s%s%s%s%s%s%s]",
+       DBG_OBJ(FS, fs, ul_debug(" statmount [rc=%d bufsiz=%zu ns=%" PRIu64 " mask: %s%s%s%s%s%s%s]",
                                rc, bufsiz, ns,
                                mask & STATMOUNT_SB_BASIC ? "sb-basic " : "",
                                mask & STATMOUNT_MNT_BASIC ? "mnt-basic " : "",
index 821269f1e91add0d11c49ce18cd17d716336400f..b620795271e24afe89a294c08a966f6357a2d47b 100644 (file)
@@ -310,7 +310,7 @@ static int hook_mount_post(
        assert(target);
        assert(hd->userns_fd >= 0);
 
-       DBG(HOOK, ul_debugobj(hs, " attaching namespace to %s", target));
+       DBG_OBJ(HOOK, hs, ul_debug(" attaching namespace to %s", target));
 
        /*
         * Once a mount has been attached to the filesystem it can't be
@@ -323,7 +323,7 @@ static int hook_mount_post(
                if (api && api->fd_tree >= 0) {
                        fd_tree = api->fd_tree;
                        is_private = 0;
-                       DBG(HOOK, ul_debugobj(hs, " reuse tree FD"));
+                       DBG_OBJ(HOOK, hs, ul_debug(" reuse tree FD"));
                }
        }
 #endif
@@ -332,7 +332,7 @@ static int hook_mount_post(
                            OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC |
                            (recursive ? AT_RECURSIVE : 0));
        if (fd_tree < 0) {
-               DBG(HOOK, ul_debugobj(hs, " failed to open tree"));
+               DBG_OBJ(HOOK, hs, ul_debug(" failed to open tree"));
                mnt_context_syscall_save_status(cxt, "open_tree", 0);
                return -MNT_ERR_IDMAP;
        }
@@ -480,7 +480,7 @@ static int hook_prepare_options(
 
 done:
        /* define post-mount hook to enter the namespace */
-       DBG(HOOK, ul_debugobj(hs, " wanted new user namespace"));
+       DBG_OBJ(HOOK, hs, ul_debug(" wanted new user namespace"));
        cxt->force_clone = 1; /* require OPEN_TREE_CLONE */
        rc = mnt_context_append_hook(cxt, hs,
                                MNT_STAGE_MOUNT_POST,
@@ -492,7 +492,7 @@ done:
        return 0;
 
 err:
-       DBG(HOOK, ul_debugobj(hs, " failed to set up idmap"));
+       DBG_OBJ(HOOK, hs, ul_debug(" failed to set up idmap"));
        free_hook_data(hd);
        free(buf);
        return -MNT_ERR_MOUNTOPT;
@@ -504,7 +504,7 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
 {
        void *data;
 
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks and free hook data */
        while (mnt_context_remove_hook(cxt, hs, 0, &data) == 0) {
index a7cb13a08b23357cf047594a3b686406aca7e61e..811685b136f4e2cd1cb6a7b972a0fc6394d947eb 100644 (file)
@@ -28,7 +28,7 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
 {
        void *data;
 
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks */
        while (mnt_context_remove_hook(cxt, hs, 0, &data) == 0) {
@@ -79,7 +79,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
        if (!ns_old)
                return -MNT_ERR_NAMESPACE;
 
-       DBG(LOOP, ul_debugobj(cxt, "checking if %s mounted on %s",
+       DBG_OBJ(LOOP, cxt, ul_debug("checking if %s mounted on %s",
                                backing_file, target));
 
        rc = mnt_context_get_user_mflags(cxt, &flags);
@@ -117,7 +117,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
                }
        }
        if (rc)
-               DBG(LOOP, ul_debugobj(cxt, "%s already mounted", backing_file));
+               DBG_OBJ(LOOP, cxt, ul_debug("%s already mounted", backing_file));
 
        if (!mnt_context_switch_ns(cxt, ns_old))
                return -MNT_ERR_NAMESPACE;
@@ -138,10 +138,10 @@ static int setup_loopdev(struct libmnt_context *cxt,
        if (!backing_file)
                return -EINVAL;
 
-       DBG(LOOP, ul_debugobj(cxt, "trying to set up device for %s", backing_file));
+       DBG_OBJ(LOOP, cxt, ul_debug("trying to set up device for %s", backing_file));
 
        if (mnt_optlist_is_rdonly(ol)) {
-               DBG(LOOP, ul_debugobj(cxt, "enabling READ-ONLY flag"));
+               DBG_OBJ(LOOP, cxt, ul_debug("enabling READ-ONLY flag"));
                lo_flags |= LO_FLAGS_READ_ONLY;
        }
 
@@ -157,7 +157,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
        if (!rc && (opt = mnt_optlist_get_opt(ol, MNT_MS_OFFSET, cxt->map_userspace))
            && mnt_opt_has_value(opt)) {
                if (strtosize(mnt_opt_get_value(opt), &offset)) {
-                       DBG(LOOP, ul_debugobj(cxt, "failed to parse offset="));
+                       DBG_OBJ(LOOP, cxt, ul_debug("failed to parse offset="));
                        rc = -MNT_ERR_MOUNTOPT;
                }
        }
@@ -168,7 +168,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
        if (!rc && (opt = mnt_optlist_get_opt(ol, MNT_MS_SIZELIMIT, cxt->map_userspace))
            && mnt_opt_has_value(opt)) {
                if (strtosize(mnt_opt_get_value(opt), &sizelimit)) {
-                       DBG(LOOP, ul_debugobj(cxt, "failed to parse sizelimit="));
+                       DBG_OBJ(LOOP, cxt, ul_debug("failed to parse sizelimit="));
                        rc = -MNT_ERR_MOUNTOPT;
                }
        }
@@ -177,7 +177,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
         * encryption=
         */
        if (!rc && mnt_optlist_get_opt(ol, MNT_MS_ENCRYPTION, cxt->map_userspace)) {
-               DBG(LOOP, ul_debugobj(cxt, "encryption no longer supported"));
+               DBG_OBJ(LOOP, cxt, ul_debug("encryption no longer supported"));
                rc = -MNT_ERR_MOUNTOPT;
        }
 
@@ -202,12 +202,12 @@ static int setup_loopdev(struct libmnt_context *cxt,
                rc = loopcxt_find_overlap(&lc, backing_file, offset, sizelimit);
                switch (rc) {
                case 0: /* not found */
-                       DBG(LOOP, ul_debugobj(cxt, "not found overlapping loopdev"));
+                       DBG_OBJ(LOOP, cxt, ul_debug("not found overlapping loopdev"));
                        loopcxt_deinit(&lc);
                        break;
 
                case 1: /* overlap */
-                       DBG(LOOP, ul_debugobj(cxt, "overlapping %s detected",
+                       DBG_OBJ(LOOP, cxt, ul_debug("overlapping %s detected",
                                                loopcxt_get_device(&lc)));
                        rc = -MNT_ERR_LOOPOVERLAP;
                        goto done;
@@ -216,12 +216,12 @@ static int setup_loopdev(struct libmnt_context *cxt,
                {
                        uint32_t lc_encrypt_type = 0;
 
-                       DBG(LOOP, ul_debugobj(cxt, "re-using existing loop device %s",
+                       DBG_OBJ(LOOP, cxt, ul_debug("re-using existing loop device %s",
                                loopcxt_get_device(&lc)));
 
                        /* Open loop device to block device autoclear... */
                        if (loopcxt_get_fd(&lc) < 0) {
-                               DBG(LOOP, ul_debugobj(cxt, "failed to get loopdev FD"));
+                               DBG_OBJ(LOOP, cxt, ul_debug("failed to get loopdev FD"));
                                rc = -errno;
                                goto done;
                        }
@@ -232,7 +232,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
                         * mean time.
                         */
                        if (!loopcxt_get_info(&lc)) {
-                               DBG(LOOP, ul_debugobj(cxt, "lost race with %s teardown",
+                               DBG_OBJ(LOOP, cxt, ul_debug("lost race with %s teardown",
                                                loopcxt_get_device(&lc)));
                                loopcxt_deinit(&lc);
                                break;
@@ -242,7 +242,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
                         * way to change its parameters. */
                        if (loopcxt_is_readonly(&lc)
                            && !(lo_flags & LO_FLAGS_READ_ONLY)) {
-                               DBG(LOOP, ul_debugobj(cxt, "%s is read-only",
+                               DBG_OBJ(LOOP, cxt, ul_debug("%s is read-only",
                                                loopcxt_get_device(&lc)));
                                rc = -EROFS;
                                goto done;
@@ -251,7 +251,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
                        /* This is no more supported, but check to be safe. */
                        if (loopcxt_get_encrypt_type(&lc, &lc_encrypt_type) == 0
                            && lc_encrypt_type != LO_CRYPT_NONE) {
-                               DBG(LOOP, ul_debugobj(cxt, "encryption no longer supported for device %s",
+                               DBG_OBJ(LOOP, cxt, ul_debug("encryption no longer supported for device %s",
                                        loopcxt_get_device(&lc)));
                                rc = -MNT_ERR_LOOPOVERLAP;
                                goto done;
@@ -271,14 +271,14 @@ static int setup_loopdev(struct libmnt_context *cxt,
                }
        }
 
-       DBG(LOOP, ul_debugobj(cxt, "not found; create a new loop device"));
+       DBG_OBJ(LOOP, cxt, ul_debug("not found; create a new loop device"));
        rc = loopcxt_init(&lc, 0);
        if (rc)
                goto done_no_deinit;
        if (mnt_opt_has_value(loopopt)) {
                rc = loopcxt_set_device(&lc, mnt_opt_get_value(loopopt));
                if (rc == 0 && loopcxt_is_lost(&lc)) {
-                       DBG(LOOP, ul_debugobj(cxt, "node lost"));
+                       DBG_OBJ(LOOP, cxt, ul_debug("node lost"));
 
                        dev_t devno = loopcxt_get_devno(&lc);
                        /* TRANSLATORS: Do not translate "e ". It is a message classifier. */
@@ -296,7 +296,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
         * because kernel provides the name in /sys.
         */
        if (get_linux_version() >= KERNEL_VERSION(2, 6, 37)) {
-               DBG(LOOP, ul_debugobj(cxt, "enabling AUTOCLEAR flag"));
+               DBG_OBJ(LOOP, cxt, ul_debug("enabling AUTOCLEAR flag"));
                lo_flags |= LO_FLAGS_AUTOCLEAR;
        }
 
@@ -306,7 +306,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
                        rc = loopcxt_find_unused(&lc);
                        if (rc)
                                goto done;
-                       DBG(LOOP, ul_debugobj(cxt, "trying to use %s",
+                       DBG_OBJ(LOOP, cxt, ul_debug("trying to use %s",
                                                loopcxt_get_device(&lc)));
                }
 
@@ -322,7 +322,7 @@ static int setup_loopdev(struct libmnt_context *cxt,
                if (!rc)
                        loopcxt_set_flags(&lc, lo_flags);
                if (rc) {
-                       DBG(LOOP, ul_debugobj(cxt, "failed to set loop attributes"));
+                       DBG_OBJ(LOOP, cxt, ul_debug("failed to set loop attributes"));
                        goto done;
                }
 
@@ -332,11 +332,11 @@ static int setup_loopdev(struct libmnt_context *cxt,
                        break;          /* success */
 
                if (loopdev || rc != -EBUSY) {
-                       DBG(LOOP, ul_debugobj(cxt, "failed to set up device"));
+                       DBG_OBJ(LOOP, cxt, ul_debug("failed to set up device"));
                        rc = -MNT_ERR_LOOPDEV;
                        goto done;
                }
-               DBG(LOOP, ul_debugobj(cxt, "device stolen...trying again"));
+               DBG_OBJ(LOOP, cxt, ul_debug("device stolen...trying again"));
        } while (1);
 
 success:
@@ -349,7 +349,7 @@ success:
                         * autoclear flag accepted by the kernel, don't store
                         * the "loop=" option to utab.
                         */
-                       DBG(LOOP, ul_debugobj(cxt, "removing unnecessary loop= from utab"));
+                       DBG_OBJ(LOOP, cxt, ul_debug("removing unnecessary loop= from utab"));
                        mnt_optlist_remove_opt(ol, loopopt);
                        loopopt = NULL;
                }
@@ -370,8 +370,8 @@ success:
                 */
                hd->loopdev_fd = open(lc.device, O_RDONLY | O_CLOEXEC);
                if (hd->loopdev_fd < 0) {
-                       DBG(LOOP,
-                           ul_debugobj(cxt, "failed to reopen loopdev FD"));
+                       DBG_OBJ(LOOP, cxt, 
+                           ul_debug("failed to reopen loopdev FD"));
                        rc = -errno;
                }
        }
@@ -400,7 +400,7 @@ static int delete_loopdev(struct libmnt_context *cxt, struct hook_data *hd)
 
        rc = loopdev_detach(src);       /* see lib/loopdev.c */
 
-       DBG(LOOP, ul_debugobj(cxt, "deleted [rc=%d]", rc));
+       DBG_OBJ(LOOP, cxt, ul_debug("deleted [rc=%d]", rc));
        return rc;
 }
 
@@ -438,7 +438,7 @@ static int is_loopdev_required(struct libmnt_context *cxt, struct libmnt_optlist
 
        /* loop= (sizelimit= or offset=) explicitly specified */
        if (flags & (MNT_MS_LOOP | MNT_MS_OFFSET | MNT_MS_SIZELIMIT)) {
-               DBG(LOOP, ul_debugobj(cxt, "loopdev specific options detected"));
+               DBG_OBJ(LOOP, cxt, ul_debug("loopdev specific options detected"));
                return 1;
        }
 
@@ -459,7 +459,7 @@ static int is_loopdev_required(struct libmnt_context *cxt, struct libmnt_optlist
                rc = mnt_context_guess_srcpath_fstype(cxt, &autotype);
                if (rc) {
                        free(autotype);
-                       DBG(CXT, ul_debugobj(cxt, "failed to guess regfile FS type [rc=%d]", rc));
+                       DBG_OBJ(CXT, cxt, ul_debug("failed to guess regfile FS type [rc=%d]", rc));
                        return 0;
                }
                if (autotype) {
@@ -483,7 +483,7 @@ static int is_loopdev_required(struct libmnt_context *cxt, struct libmnt_optlist
        if (type && !blkid_known_fstype(type))
                return 0;
 
-       DBG(LOOP, ul_debugobj(cxt, "automatically enabling loop= option"));
+       DBG_OBJ(LOOP, cxt, ul_debug("automatically enabling loop= option"));
        mnt_optlist_append_flags(ol, MNT_MS_LOOP, cxt->map_userspace);
        return 1;
 }
@@ -509,7 +509,7 @@ static int hook_cleanup_loopdev(
                /*
                 * mount(2) success, close the device
                 */
-               DBG(LOOP, ul_debugobj(cxt, "closing FD"));
+               DBG_OBJ(LOOP, cxt, ul_debug("closing FD"));
                close(hd->loopdev_fd);
                hd->loopdev_fd = -1;
        }
index da9c407ea2915759e4b05307e532828a04c2a514..b192bd5c0db73fc41b58a51fdfc25f7c29162283 100644 (file)
@@ -19,7 +19,7 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
 {
        void *data = NULL;
 
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks and free hook data */
        while (mnt_context_remove_hook(cxt, hs, 0, &data) == 0) {
@@ -111,7 +111,7 @@ static int hook_prepare_target(
                if (!mnt_context_is_restricted(cxt)) {
                        rc = ul_mkdir_p(tgt, mode);
                        if (rc)
-                               DBG(HOOK, ul_debugobj(hs, "mkdir %s failed: %m", tgt));
+                               DBG_OBJ(HOOK, hs, ul_debug("mkdir %s failed: %m", tgt));
                } else
                        rc = -EPERM;
 
index 374078c97f8a74b19069539d3220f555686fe5a1..322f726ccd5fb38bb73a5f0b8b01cb174718d885 100644 (file)
@@ -119,7 +119,7 @@ static struct libmnt_sysapi *new_hookset_data(
 /* de-initiallize this module */
 static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookset *hs)
 {
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks */
        while (mnt_context_remove_hook(cxt, hs, 0, NULL) == 0);
@@ -148,7 +148,7 @@ static inline int fsconfig_set_value(
                value = s;
        }
 
-       DBG(HOOK, ul_debugobj(hs, "  fsconfig(name=\"%s\" value=\"%s\")", name,
+       DBG_OBJ(HOOK, hs, ul_debug("  fsconfig(name=\"%s\" value=\"%s\")", name,
                                value ? : ""));
        if (value) {
                rc = fsconfig(fd, FSCONFIG_SET_STRING, name, value, 0);
@@ -169,7 +169,7 @@ static int configure_superblock(struct libmnt_context *cxt,
        struct libmnt_opt *opt;
        int rc = 0, has_rwro = 0;
 
-       DBG(HOOK, ul_debugobj(hs, " config FS"));
+       DBG_OBJ(HOOK, hs, ul_debug(" config FS"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -212,7 +212,7 @@ static int configure_superblock(struct libmnt_context *cxt,
                rc = fsconfig_set_value(cxt, hs, fd, "rw", NULL);
 
 done:
-       DBG(HOOK, ul_debugobj(hs, " config done [rc=%d]", rc));
+       DBG_OBJ(HOOK, hs, ul_debug(" config done [rc=%d]", rc));
        return rc != 0 && errno ? -errno : rc;
 }
 
@@ -221,7 +221,7 @@ static int create_superblock(struct libmnt_context *cxt,
 {
        int rc = 0;
 
-       DBG(HOOK, ul_debugobj(hs, " create FS %s",
+       DBG_OBJ(HOOK, hs, ul_debug(" create FS %s",
                        mnt_context_is_exclusive(cxt) ? "excl" : ""));
        errno = 0;
 
@@ -232,7 +232,7 @@ static int create_superblock(struct libmnt_context *cxt,
 
        hookset_set_syscall_status(cxt, "fsconfig", rc == 0);
 
-       DBG(HOOK, ul_debugobj(hs, " create done [rc=%d]", rc));
+       DBG_OBJ(HOOK, hs, ul_debug(" create done [rc=%d]", rc));
        return rc != 0 && errno ? -errno : rc;
 }
 
@@ -285,7 +285,7 @@ static int hook_create_mount(struct libmnt_context *cxt,
        if (!src)
                return -EINVAL;
 
-       DBG(HOOK, ul_debugobj(hs, "init FS"));
+       DBG_OBJ(HOOK, hs, ul_debug("init FS"));
 
        rc = fsconfig(api->fd_fs, FSCONFIG_SET_STRING, "source", src, 0);
        hookset_set_syscall_status(cxt, "fsconfig", rc == 0);
@@ -303,7 +303,7 @@ static int hook_create_mount(struct libmnt_context *cxt,
                        /*
                         * subdir for Linux >= 6.15, see hook_subdir.c for more details.
                         */
-                       DBG(HOOK, ul_debugobj(hs, "opening subdir (detached) '%s'", api->subdir));
+                       DBG_OBJ(HOOK, hs, ul_debug("opening subdir (detached) '%s'", api->subdir));
                        int sub_fd = open_tree(fd, api->subdir,
                                        AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW |
                                        AT_RECURSIVE | OPEN_TREE_CLOEXEC |
@@ -339,7 +339,7 @@ static int hook_create_mount(struct libmnt_context *cxt,
 #endif
 
 done:
-       DBG(HOOK, ul_debugobj(hs, "create FS done [rc=%d, id=%d]", rc, cxt->fs ? cxt->fs->id : -1));
+       DBG_OBJ(HOOK, hs, ul_debug("create FS done [rc=%d, id=%d]", rc, cxt->fs ? cxt->fs->id : -1));
        return rc;
 }
 
@@ -369,12 +369,12 @@ static int hook_reconfigure_mount(struct libmnt_context *cxt,
 
        rc = configure_superblock(cxt, hs, api->fd_fs, 1);
        if (!rc) {
-               DBG(HOOK, ul_debugobj(hs, "reconfigure FS"));
+               DBG_OBJ(HOOK, hs, ul_debug("reconfigure FS"));
                rc = fsconfig(api->fd_fs, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, 0);
                hookset_set_syscall_status(cxt, "fsconfig", rc == 0);
        }
 
-       DBG(HOOK, ul_debugobj(hs, "reconf FS done [rc=%d]", rc));
+       DBG_OBJ(HOOK, hs, ul_debug("reconf FS done [rc=%d]", rc));
        return rc;
 }
 
@@ -402,7 +402,7 @@ static int set_vfsflags(struct libmnt_context *cxt,
        if (recursive)
                callflags |= AT_RECURSIVE;
 
-       DBG(HOOK, ul_debugobj(hs,
+       DBG_OBJ(HOOK, hs, ul_debug(
                        "mount_setattr(set=0x%08" PRIx64" clr=0x%08" PRIx64")", set, clr));
        attr.attr_set = set;
        attr.attr_clr = clr;
@@ -428,7 +428,7 @@ static int hook_set_vfsflags(struct libmnt_context *cxt,
        if (mnt_context_helper_executed(cxt))
                return 0;
 
-       DBG(HOOK, ul_debugobj(hs, "setting VFS flags"));
+       DBG_OBJ(HOOK, hs, ul_debug("setting VFS flags"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -459,7 +459,7 @@ static int hook_set_propagation(struct libmnt_context *cxt,
        struct libmnt_opt *opt;
        int rc = 0;
 
-       DBG(HOOK, ul_debugobj(hs, "setting propagation"));
+       DBG_OBJ(HOOK, hs, ul_debug("setting propagation"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -496,7 +496,7 @@ static int hook_set_propagation(struct libmnt_context *cxt,
                if (ent->id & MS_REC)
                        flgs |= AT_RECURSIVE;
 
-               DBG(HOOK, ul_debugobj(hs,
+               DBG_OBJ(HOOK, hs, ul_debug(
                        "mount_setattr(propagation=0x%08" PRIx64")",
                        (uint64_t) attr.propagation));
 
@@ -532,14 +532,14 @@ static int hook_attach_target(struct libmnt_context *cxt,
        assert(api);
        assert(api->fd_tree >= 0);
 
-       DBG(HOOK, ul_debugobj(hs, "move_mount(to=%s)", target));
+       DBG_OBJ(HOOK, hs, ul_debug("move_mount(to=%s)", target));
 
        /* umount old target if we created a clone */
        if (cxt->force_clone
            && !api->is_new_fs
            && !mnt_optlist_is_bind(cxt->optlist)) {
 
-               DBG(HOOK, ul_debugobj(hs, "remove expired target"));
+               DBG_OBJ(HOOK, hs, ul_debug("remove expired target"));
                umount2(target, MNT_DETACH);
        }
 
@@ -598,12 +598,12 @@ static int init_sysapi(struct libmnt_context *cxt,
        assert(cxt);
        assert(hs);
 
-       DBG(HOOK, ul_debugobj(hs, "initialize API fds"));
+       DBG_OBJ(HOOK, hs, ul_debug("initialize API fds"));
 
        /* A) tree based operation -- the tree is mount point */
        if ((flags & MS_REMOUNT)
            || mnt_context_propagation_only(cxt)) {
-               DBG(HOOK, ul_debugobj(hs, " REMOUNT/propagation"));
+               DBG_OBJ(HOOK, hs, ul_debug(" REMOUNT/propagation"));
                path = mnt_fs_get_target(cxt->fs);
                if (!path)
                        return -EINVAL;
@@ -611,7 +611,7 @@ static int init_sysapi(struct libmnt_context *cxt,
        /* B) tree based operation -- the tree is mount source */
        } else if ((flags & MS_BIND)
            || (flags & MS_MOVE)) {
-               DBG(HOOK, ul_debugobj(hs, " BIND/MOVE"));
+               DBG_OBJ(HOOK, hs, ul_debug(" BIND/MOVE"));
                path = mnt_fs_get_srcpath(cxt->fs);
                if (!path)
                        return -EINVAL;
@@ -651,7 +651,7 @@ static int init_sysapi(struct libmnt_context *cxt,
 
        return 0;
 fail:
-       DBG(HOOK, ul_debugobj(hs, "init fs/tree failed [errno=%d %m]", errno));
+       DBG_OBJ(HOOK, hs, ul_debug("init fs/tree failed [errno=%d %m]", errno));
        return -errno;
 }
 
@@ -713,11 +713,11 @@ static int hook_prepare(struct libmnt_context *cxt,
        assert(hs == &hookset_mount);
 
        if (force_classic_mount(cxt)) {
-               DBG(HOOK, ul_debugobj(hs, "new API disabled"));
+               DBG_OBJ(HOOK, hs, ul_debug("new API disabled"));
                return 0;
        }
 
-       DBG(HOOK, ul_debugobj(hs, "prepare mount"));
+       DBG_OBJ(HOOK, hs, ul_debug("prepare mount"));
 
        ol = mnt_context_get_optlist(cxt);
        if (!ol)
@@ -796,13 +796,13 @@ static int hook_prepare(struct libmnt_context *cxt,
                                        hook_set_propagation);
        }
 
-       DBG(HOOK, ul_debugobj(hs, "prepare mount done [rc=%d]", rc));
+       DBG_OBJ(HOOK, hs, ul_debug("prepare mount done [rc=%d]", rc));
        return rc;
 
 enosys:
        /* we need to recover from this error, so hook_mount_legacy.c
         * can try to continue */
-       DBG(HOOK, ul_debugobj(hs, "failed to init new API"));
+       DBG_OBJ(HOOK, hs, ul_debug("failed to init new API"));
        mnt_context_syscall_reset_status(cxt);
        hookset_deinit(cxt, hs);
        return 1;
index cfdd7af2b2c1db7e4e45cb452b983f33ea3ea148..7d22066c048ddcb09d813ffe81a038474f3ab529 100644 (file)
@@ -26,7 +26,7 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
 {
        void *data = NULL;
 
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks and free hook data */
        while (mnt_context_remove_hook(cxt, hs, 0, &data) == 0) {
@@ -57,7 +57,7 @@ static int hook_propagation(struct libmnt_context *cxt,
        assert(cxt->fs);
        assert(cxt->optlist);
 
-       DBG(HOOK, ul_debugobj(hs, " calling mount(2) for propagation: 0x%08lx %s",
+       DBG_OBJ(HOOK, hs, ul_debug(" calling mount(2) for propagation: 0x%08lx %s",
                                hd->flags,
                                hd->flags & MS_REC ? " (recursive)" : ""));
 
@@ -79,7 +79,7 @@ static int hook_propagation(struct libmnt_context *cxt,
                if (mnt_context_propagation_only(cxt))
                        mnt_context_syscall_save_status(cxt, "mount", rc == 0);
 
-               DBG(HOOK, ul_debugobj(hs, "  mount(2) failed [errno=%d %m]", errno));
+               DBG_OBJ(HOOK, hs, ul_debug("  mount(2) failed [errno=%d %m]", errno));
                rc = -MNT_ERR_APPLYFLAGS;
        }
        return rc;
@@ -121,7 +121,7 @@ static int prepare_propagation(struct libmnt_context *cxt,
 
                data->flags = ent->id;
 
-               DBG(HOOK, ul_debugobj(hs, " adding mount(2) call for %s", ent->name));
+               DBG_OBJ(HOOK, hs, ul_debug(" adding mount(2) call for %s", ent->name));
                rc = mnt_context_append_hook(cxt, hs,
                                        MNT_STAGE_MOUNT_POST,
                                        data,
@@ -129,7 +129,7 @@ static int prepare_propagation(struct libmnt_context *cxt,
                if (rc)
                        return rc;
 
-               DBG(HOOK, ul_debugobj(hs, " removing '%s' flag from primary mount(2)", ent->name));
+               DBG_OBJ(HOOK, hs, ul_debug(" removing '%s' flag from primary mount(2)", ent->name));
                mnt_optlist_remove_opt(ol, opt);
        }
 
@@ -144,7 +144,7 @@ static int hook_bindremount(struct libmnt_context *cxt,
        struct hook_data *hd = (struct hook_data *) data;
        unsigned long extra = 0;
 
-       DBG(HOOK, ul_debugobj(hs, " mount(2) for bind-remount: 0x%08lx %s",
+       DBG_OBJ(HOOK, hs, ul_debug(" mount(2) for bind-remount: 0x%08lx %s",
                                hd->flags,
                                hd->flags & MS_REC ? " (recursive)" : ""));
 
@@ -156,7 +156,7 @@ static int hook_bindremount(struct libmnt_context *cxt,
                        hd->flags | extra, NULL);
 
        if (rc)
-               DBG(HOOK, ul_debugobj(hs, "  mount(2) failed"
+               DBG_OBJ(HOOK, hs, ul_debug("  mount(2) failed"
                                  " [rc=%d errno=%d %m]", rc, errno));
        else
                mnt_fs_mark_attached(cxt->fs);
@@ -176,7 +176,7 @@ static int prepare_bindremount(struct libmnt_context *cxt,
 
        assert(cxt);
 
-       DBG(HOOK, ul_debugobj(hs, " adding mount(2) call for bint-remount"));
+       DBG_OBJ(HOOK, hs, ul_debug(" adding mount(2) call for bint-remount"));
 
        data = new_hook_data();
        if (!data)
@@ -234,7 +234,7 @@ static int hook_mount(struct libmnt_context *cxt,
        if (rc)
                return rc;
 
-       DBG(HOOK, ul_debugobj(hs, "  mount(2) "
+       DBG_OBJ(HOOK, hs, ul_debug("  mount(2) "
                "[source=%s, target=%s, type=%s, flags=0x%08lx, options=%s]",
                src, target, type, flags,
                options ? (cxt->flags & MNT_FL_MOUNTDATA) ? "binary" :
index 11b238c891743287622a42bc1c4501b5c005e5e5..abd21c0aca671b1e0c6f9a7a9a703e75dabca234 100644 (file)
@@ -30,7 +30,7 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
 {
        void *data;
 
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks and free hook data */
        while (mnt_context_remove_hook(cxt, hs, 0, &data) == 0) {
@@ -60,13 +60,13 @@ static int hook_post(
                return 0;
 
        if (hd->owner != (uid_t) -1 || hd->group != (uid_t) -1) {
-               DBG(CXT, ul_debugobj(cxt, " lchown(%s, %u, %u)", target, hd->owner, hd->group));
+               DBG_OBJ(CXT, cxt, ul_debug(" lchown(%s, %u, %u)", target, hd->owner, hd->group));
                if (lchown(target, hd->owner, hd->group) == -1)
                        return -MNT_ERR_CHOWN;
        }
 
        if (hd->mode != (mode_t) -1) {
-               DBG(CXT, ul_debugobj(cxt, " chmod(%s, %04o)", target, hd->mode));
+               DBG_OBJ(CXT, cxt, ul_debug(" chmod(%s, %04o)", target, hd->mode));
                if (chmod(target, hd->mode) == -1)
                        return -MNT_ERR_CHMOD;
        }
@@ -147,7 +147,7 @@ static int hook_prepare_options(
        }
 
        if (hd) {
-               DBG(CXT, ul_debugobj(cxt, " wanted ownership %d:%d, mode %04o",
+               DBG_OBJ(CXT, cxt, ul_debug(" wanted ownership %d:%d, mode %04o",
                                        hd->owner, hd->group, hd->mode));
                rc = mnt_context_append_hook(cxt, hs,
                                MNT_STAGE_POST,
index 11d950c44ee81fb9958258a2eb9543ef3f8c9e1e..0dfd473591e38ffa9fcf1420b3af525109beb181 100644 (file)
@@ -24,7 +24,7 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
 {
        void *data = NULL;
 
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks and free hook data */
        while (mnt_context_remove_hook(cxt, hs, 0, &data) == 0) {
@@ -83,9 +83,9 @@ static int hook_selinux_target(
        rc = getfilecon_raw(tgt, &raw);
        if (rc <= 0 || !raw) {
                rc = errno ? -errno : -EINVAL;
-               DBG(HOOK, ul_debugobj(hs, " SELinux fix @target failed [rc=%d]", rc));
+               DBG_OBJ(HOOK, hs, ul_debug(" SELinux fix @target failed [rc=%d]", rc));
        } else {
-               DBG(HOOK, ul_debugobj(hs, " SELinux fix @target to %s", raw));
+               DBG_OBJ(HOOK, hs, ul_debug(" SELinux fix @target to %s", raw));
                rc = 0; /* getfilecon_raw(3) returns the size of the extended attribute value */
        }
        if (!rc)
@@ -128,7 +128,7 @@ static int hook_prepare_options(
                /* For normal mount, contexts are translated */
                se_fix = 1;
 
-       DBG(HOOK, ul_debugobj(hs, " SELinux fix options"));
+       DBG_OBJ(HOOK, hs, ul_debug(" SELinux fix options"));
 
        /* Fix SELinux contexts */
        if (se_rem || se_fix) {
@@ -172,7 +172,7 @@ static int hook_prepare_options(
                                                rc = -EINVAL;
                                }
                                if (!rc) {
-                                       DBG(HOOK, ul_debugobj(hs, "  %s: %s to %s",
+                                       DBG_OBJ(HOOK, hs, ul_debug("  %s: %s to %s",
                                                                opt_name, val, raw));
                                        rc = mnt_opt_set_quoted_value(opt, raw);
                                }
index 5f419338eb9b053d30656393b6b90bf43c33a8be..030f80ed09dd62d824c8fdaec4207e30ae49d729 100644 (file)
@@ -88,7 +88,7 @@ static struct hookset_data *new_hookset_data(
 /* de-initiallize this module */
 static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookset *hs)
 {
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks */
        while (mnt_context_remove_hook(cxt, hs, 0, NULL) == 0);
@@ -338,7 +338,7 @@ static int hook_mount_pre(
        if (api
            && cxt->helper == NULL
            && get_linux_version() >= KERNEL_VERSION(6, 15, 0)) {
-               DBG(HOOK, ul_debugobj(hs, "detached subdir open (ignore hook)"));
+               DBG_OBJ(HOOK, hs, ul_debug("detached subdir open (ignore hook)"));
                api->subdir = hsd->subdir;
                hsd->subdir = NULL;
                return 0;
@@ -358,7 +358,7 @@ static int hook_mount_pre(
                                MNT_STAGE_MOUNT_POST,
                                NULL, hook_mount_post);
 
-       DBG(HOOK, ul_debugobj(hs, "unshared tmp target %s [rc=%d]",
+       DBG_OBJ(HOOK, hs, ul_debug("unshared tmp target %s [rc=%d]",
                                MNT_PATH_TMPTGT, rc));
        return rc;
 }
@@ -440,7 +440,7 @@ static int hook_prepare_target(
                }
                hsd->subdir = subdir;
 
-               DBG(HOOK, ul_debugobj(hs, "subdir %s wanted", subdir));
+               DBG_OBJ(HOOK, hs, ul_debug("subdir %s wanted", subdir));
 
                rc = mnt_context_append_hook(cxt, hs,
                                MNT_STAGE_MOUNT_PRE,
index 95ea55f8713f69cb0a51279b313f397723f53045..9a8d9f6fe55e0d3ff2257d877d7513cc1c2b3c5a 100644 (file)
@@ -164,7 +164,7 @@ static void libcryptsetup_log(int level __attribute__((__unused__)),
                              const char *msg, void *data)
 {
        const struct libmnt_hookset *hs = (struct libmnt_hookset *) data;
-       DBG(HOOK, ul_debugobj(hs, "cryptsetup: %s", msg));
+       DBG_OBJ(HOOK, hs, ul_debug("cryptsetup: %s", msg));
 }
 
 /* free global data */
@@ -220,7 +220,7 @@ failed:
 /* libmount callback -- cleanup all */
 static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookset *hs)
 {
-       DBG(HOOK, ul_debugobj(hs, "deinit '%s'", hs->name));
+       DBG_OBJ(HOOK, hs, ul_debug("deinit '%s'", hs->name));
 
        /* remove all our hooks */
        while (mnt_context_remove_hook(cxt, hs, 0, NULL) == 0);
@@ -262,7 +262,7 @@ static int is_veritydev_required(struct libmnt_context *cxt,
                return 0;
 
        if (flags & (MNT_MS_HASH_DEVICE | MNT_MS_ROOT_HASH | MNT_MS_HASH_OFFSET)) {
-               DBG(HOOK, ul_debugobj(hs, "verity options detected"));
+               DBG_OBJ(HOOK, hs, ul_debug("verity options detected"));
                return 1;
        }
 
@@ -287,7 +287,7 @@ static void delete_veritydev(struct libmnt_context *cxt,
 
        rc = verity_call( crypt_deactivate_by_name(NULL, hsd->devname, flags) );
 
-       DBG(HOOK, ul_debugobj(hs, "deleted %s [rc=%d%s]",
+       DBG_OBJ(HOOK, hs, ul_debug("deleted %s [rc=%d%s]",
                                hsd->devname, rc,
                                flags & CRYPT_DEACTIVATE_DEFERRED ? " deferred" : "" ));
        if (rc == 0) {
@@ -367,7 +367,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
        if (!backing_file)
                return -EINVAL;
 
-       DBG(HOOK, ul_debugobj(hs, "verity: setup for %s", backing_file));
+       DBG_OBJ(HOOK, hs, ul_debug("verity: setup for %s", backing_file));
 
        /* verity.hashdevice= */
        if (!rc && (opt = mnt_optlist_get_opt(ol, MNT_MS_HASH_DEVICE, cxt->map_userspace)))
@@ -383,7 +383,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
        if (!rc && (opt = mnt_optlist_get_opt(ol, MNT_MS_HASH_OFFSET, cxt->map_userspace))
            && mnt_opt_has_value(opt)) {
                if (strtosize(mnt_opt_get_value(opt), &offset)) {
-                       DBG(HOOK, ul_debugobj(hs, "failed to parse verity.hashoffset="));
+                       DBG_OBJ(HOOK, hs, ul_debug("failed to parse verity.hashoffset="));
                        rc = -MNT_ERR_MOUNTOPT;
                }
        }
@@ -400,7 +400,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
        if (!rc && (opt = mnt_optlist_get_opt(ol, MNT_MS_FEC_OFFSET, cxt->map_userspace))
            && mnt_opt_has_value(opt)
            && strtosize(mnt_opt_get_value(opt), &fec_offset)) {
-               DBG(HOOK, ul_debugobj(hs, "failed to parse verity.fecoffset="));
+               DBG_OBJ(HOOK, hs, ul_debug("failed to parse verity.fecoffset="));
                rc = -MNT_ERR_MOUNTOPT;
        }
 
@@ -408,7 +408,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
        if (!rc && (opt = mnt_optlist_get_opt(ol, MNT_MS_FEC_ROOTS, cxt->map_userspace))
            && mnt_opt_has_value(opt)
            && strtosize(mnt_opt_get_value(opt), &fec_roots)) {
-               DBG(HOOK, ul_debugobj(hs, "failed to parse verity.fecroots="));
+               DBG_OBJ(HOOK, hs, ul_debug("failed to parse verity.fecroots="));
                rc = -MNT_ERR_MOUNTOPT;
        }
 
@@ -417,7 +417,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
            && mnt_opt_has_value(opt)) {
                root_hash_sig_file = mnt_opt_get_value(opt);
 
-               DBG(HOOK, ul_debugobj(hs, "verity: checking %s", root_hash_sig_file));
+               DBG_OBJ(HOOK, hs, ul_debug("verity: checking %s", root_hash_sig_file));
 
                rc = ul_path_stat(NULL, &hash_sig_st, 0, root_hash_sig_file);
                if (rc == 0)
@@ -446,16 +446,16 @@ static int setup_veritydev(       struct libmnt_context *cxt,
 #ifdef CRYPT_ACTIVATE_PANIC_ON_CORRUPTION
                        crypt_activate_flags |= CRYPT_ACTIVATE_PANIC_ON_CORRUPTION;
 #else
-                       DBG(HOOK, ul_debugobj(hs, "verity.oncorruption=panic not supported by libcryptsetup, ignoring"));
+                       DBG_OBJ(HOOK, hs, ul_debug("verity.oncorruption=panic not supported by libcryptsetup, ignoring"));
 #endif
                else {
-                       DBG(HOOK, ul_debugobj(hs, "failed to parse verity.oncorruption="));
+                       DBG_OBJ(HOOK, hs, ul_debug("failed to parse verity.oncorruption="));
                        rc = -MNT_ERR_MOUNTOPT;
                }
        }
 
        if (!rc && root_hash && root_hash_file) {
-               DBG(HOOK, ul_debugobj(hs, "verity.roothash and verity.roothashfile are mutually exclusive"));
+               DBG_OBJ(HOOK, hs, ul_debug("verity.roothash and verity.roothashfile are mutually exclusive"));
                rc = -EINVAL;
        } else if (!rc && root_hash_file) {
                rc = ul_path_read_string(NULL, &root_hash, root_hash_file);
@@ -463,7 +463,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
        }
 
        if (!rc && (!hash_device || !root_hash)) {
-               DBG(HOOK, ul_debugobj(hs, "verity.hashdevice and one of verity.roothash or verity.roothashfile are mandatory"));
+               DBG_OBJ(HOOK, hs, ul_debug("verity.hashdevice and one of verity.roothash or verity.roothashfile are mandatory"));
                rc = -EINVAL;
        }
 
@@ -492,7 +492,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
 
        hash_size = verity_call( crypt_get_volume_key_size(crypt_dev) );
        if (crypt_hex_to_bytes(root_hash, &root_hash_binary) != hash_size) {
-               DBG(HOOK, ul_debugobj(hs, "root hash %s is not of length %zu", root_hash, hash_size));
+               DBG_OBJ(HOOK, hs, ul_debug("root hash %s is not of length %zu", root_hash, hash_size));
                rc = -EINVAL;
                goto done;
        }
@@ -503,7 +503,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
                                hash_sig, hash_sig_size, crypt_activate_flags) );
 #else
                rc = -EINVAL;
-               DBG(HOOK, ul_debugobj(hs, "verity.roothashsig=%s passed but libcryptsetup does not provide crypt_activate_by_signed_key()", hash_sig));
+               DBG_OBJ(HOOK, hs, ul_debug("verity.roothashsig=%s passed but libcryptsetup does not provide crypt_activate_by_signed_key()", hash_sig));
 #endif
        } else
                rc = verity_call( crypt_activate_by_volume_key(crypt_dev, mapper_device, root_hash_binary, hash_size,
@@ -522,7 +522,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
         * Pass through only OOM errors or mismatching root hash errors.
         */
        if (rc == -EEXIST) {
-               DBG(HOOK, ul_debugobj(hs, "%s already in use as /dev/mapper/%s", backing_file, mapper_device));
+               DBG_OBJ(HOOK, hs, ul_debug("%s already in use as /dev/mapper/%s", backing_file, mapper_device));
 
                verity_call( crypt_free(crypt_dev) );
 
@@ -541,7 +541,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
                                rc = verity_call( crypt_volume_key_get(crypt_dev, CRYPT_ANY_SLOT, key, &keysize, NULL, 0) );
                        }
                        if (!rc) {
-                               DBG(HOOK, ul_debugobj(hs, "comparing root hash of existing device with %s", root_hash));
+                               DBG_OBJ(HOOK, hs, ul_debug("comparing root hash of existing device with %s", root_hash));
                                if (memcmp(key, root_hash_binary, hash_size)) {
                                        /* TRANSLATORS: Don't translate "e ". It's a message classifier. */
                                        mnt_context_append_mesg(cxt, _("e device's hash does not match with root hash"));
@@ -549,7 +549,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
                                        goto done;
                                }
                        } else {
-                               DBG(HOOK, ul_debugobj(hs, "libcryptsetup does not support extracting root hash of existing device"));
+                               DBG_OBJ(HOOK, hs, ul_debug("libcryptsetup does not support extracting root hash of existing device"));
                        }
                }
                if (rc) {
@@ -568,7 +568,7 @@ static int setup_veritydev( struct libmnt_context *cxt,
                                goto done;
                        }
 #endif
-                       DBG(HOOK, ul_debugobj(hs, "root hash of %s matches %s, reusing device", mapper_device, root_hash));
+                       DBG_OBJ(HOOK, hs, ul_debug("root hash of %s matches %s, reusing device", mapper_device, root_hash));
                }
        }
 
index 23eca4efdc4db2c017dc4bf87e6cb92a5f7aa538..4d9c4affecadd97718efe259a7c9a6801e03f10e 100644 (file)
@@ -165,7 +165,7 @@ int mnt_context_set_hookset_data(struct libmnt_context *cxt,
        /* deallocate old data */
        if (data == NULL) {
                if (hd) {
-                       DBG(CXT, ul_debugobj(cxt, " free '%s' data", hs->name));
+                       DBG_OBJ(CXT, cxt, ul_debug(" free '%s' data", hs->name));
                        list_del(&hd->datas);
                        free(hd);
                }
@@ -178,7 +178,7 @@ int mnt_context_set_hookset_data(struct libmnt_context *cxt,
                if (!hd)
                        return -ENOMEM;
 
-               DBG(CXT, ul_debugobj(cxt, " alloc '%s' data", hs->name));
+               DBG_OBJ(CXT, cxt, ul_debug(" alloc '%s' data", hs->name));
                INIT_LIST_HEAD(&hd->datas);
                hd->hookset = hs;
                list_add_tail(&hd->datas, &cxt->hooksets_datas);
@@ -215,7 +215,7 @@ static int append_hook(struct libmnt_context *cxt,
        if (!hook)
                return -ENOMEM;
 
-       DBG(CXT, ul_debugobj(cxt, " appending %s hook from %s",
+       DBG_OBJ(CXT, cxt, ul_debug(" appending %s hook from %s",
                                stagenames[stage], hs->name));
 
        INIT_LIST_HEAD(&hook->hooks);
@@ -288,7 +288,7 @@ int mnt_context_remove_hook(struct libmnt_context *cxt,
 
        hook = get_hookset_hook(cxt, hs, stage, NULL);
        if (hook) {
-               DBG(CXT, ul_debugobj(cxt, " removing %s hook from %s",
+               DBG_OBJ(CXT, cxt, ul_debug(" removing %s hook from %s",
                        stagenames[hook->stage], hook->hookset->name));
 
                if (data)
@@ -315,7 +315,7 @@ static int call_hook(struct libmnt_context *cxt, struct hookset_hook *hook)
        int rc = 0;
 
        if (mnt_context_is_fake(cxt))
-               DBG(CXT, ul_debugobj(cxt, " FAKE call"));
+               DBG_OBJ(CXT, cxt, ul_debug(" FAKE call"));
        else
                rc = hook->func(cxt, hook->hookset, hook->data);
 
@@ -337,7 +337,7 @@ static int call_depend_hooks(struct libmnt_context *cxt, const char *name, int s
                    x->after == NULL || strcmp(x->after, name) != 0)
                        continue;
 
-               DBG(CXT, ul_debugobj(cxt, "calling %s [after]", x->hookset->name));
+               DBG_OBJ(CXT, cxt, ul_debug("calling %s [after]", x->hookset->name));
                rc = call_hook(cxt, x);
                if (rc)
                        break;
@@ -352,7 +352,7 @@ int mnt_context_call_hooks(struct libmnt_context *cxt, int stage)
        size_t i;
        int rc = 0;
 
-       DBG(CXT, ul_debugobj(cxt, "---> stage:%s", stagenames[stage]));
+       DBG_OBJ(CXT, cxt, ul_debug("---> stage:%s", stagenames[stage]));
 
        /* call initial hooks */
        for (i = 0; i <  ARRAY_SIZE(hooksets); i++) {
@@ -361,10 +361,10 @@ int mnt_context_call_hooks(struct libmnt_context *cxt, int stage)
                if (hs->firststage != stage)
                        continue;
 
-               DBG(CXT, ul_debugobj(cxt, "calling %s [first]", hs->name));
+               DBG_OBJ(CXT, cxt, ul_debug("calling %s [first]", hs->name));
 
                if (mnt_context_is_fake(cxt))
-                       DBG(CXT, ul_debugobj(cxt, " FAKE call"));
+                       DBG_OBJ(CXT, cxt, ul_debug(" FAKE call"));
                else
                        rc = hs->firstcall(cxt, hs, NULL);
                if (!rc)
@@ -380,7 +380,7 @@ int mnt_context_call_hooks(struct libmnt_context *cxt, int stage)
                if (x->stage != stage || x->executed)
                        continue;
 
-               DBG(CXT, ul_debugobj(cxt, "calling %s [active]", x->hookset->name));
+               DBG_OBJ(CXT, cxt, ul_debug("calling %s [active]", x->hookset->name));
                rc = call_hook(cxt, x);
                if (rc < 0)
                        goto done;
@@ -397,7 +397,7 @@ done:
                x->executed = 0;
        }
 
-       DBG(CXT, ul_debugobj(cxt, "<--- stage:%s [rc=%d status=%d]",
+       DBG_OBJ(CXT, cxt, ul_debug("<--- stage:%s [rc=%d status=%d]",
                                stagenames[stage], rc, cxt->syscall_status));
        return rc;
 }
index 28ff8b788b6c3b2417da1e07dcafae2a00f8b206..d5c68b1792649210f9c0711ec269e02c1feb0880 100644 (file)
@@ -78,7 +78,7 @@ struct libmnt_lock *mnt_new_lock(const char *datafile, pid_t id __attribute__((_
        ml->lockfile_fd = -1;
        ml->lockfile = lo;
 
-       DBG(LOCKS, ul_debugobj(ml, "alloc: lockfile=%s", lo));
+       DBG_OBJ(LOCKS, ml, ul_debug("alloc: lockfile=%s", lo));
        return ml;
 err:
        free(lo);
@@ -101,7 +101,7 @@ void mnt_free_lock(struct libmnt_lock *ml)
        if (!ml)
                return;
 
-       DBG(LOCKS, ul_debugobj(ml, "free%s [refcount=%d]",
+       DBG_OBJ(LOCKS, ml, ul_debug("free%s [refcount=%d]",
                                        ml->locked ? " !!! LOCKED !!!" : "",
                                        ml->refcount));
        free(ml->lockfile);
@@ -120,7 +120,7 @@ void mnt_ref_lock(struct libmnt_lock *ml)
 {
        if (ml) {
                ml->refcount++;
-               /*DBG(FS, ul_debugobj(fs, "ref=%d", ml->refcount));*/
+               /*DBG_OBJ(FS, fs, ul_debug("ref=%d", ml->refcount));*/
        }
 }
 
@@ -135,7 +135,7 @@ void mnt_unref_lock(struct libmnt_lock *ml)
 {
        if (ml) {
                ml->refcount--;
-               /*DBG(FS, ul_debugobj(fs, "unref=%d", ml->refcount));*/
+               /*DBG_OBJ(FS, fs, ul_debug("unref=%d", ml->refcount));*/
                if (ml->refcount <= 0)
                        mnt_free_lock(ml);
        }
@@ -155,7 +155,7 @@ int mnt_lock_block_signals(struct libmnt_lock *ml, int enable)
 {
        if (!ml)
                return -EINVAL;
-       DBG(LOCKS, ul_debugobj(ml, "signals: %s", enable ? "BLOCKED" : "UNBLOCKED"));
+       DBG_OBJ(LOCKS, ml, ul_debug("signals: %s", enable ? "BLOCKED" : "UNBLOCKED"));
        ml->sigblock = enable ? 1 : 0;
        return 0;
 }
@@ -176,7 +176,7 @@ static void unlock_simplelock(struct libmnt_lock *ml)
        assert(ml);
 
        if (ml->lockfile_fd >= 0) {
-               DBG(LOCKS, ul_debugobj(ml, "%s: unflocking",
+               DBG_OBJ(LOCKS, ml, ul_debug("%s: unflocking",
                                        mnt_lock_get_lockfile(ml)));
                close(ml->lockfile_fd);
        }
@@ -193,7 +193,7 @@ static int lock_simplelock(struct libmnt_lock *ml)
 
        lfile = mnt_lock_get_lockfile(ml);
 
-       DBG(LOCKS, ul_debugobj(ml, "%s: locking", lfile));
+       DBG_OBJ(LOCKS, ml, ul_debug("%s: locking", lfile));
 
        if (ml->sigblock) {
                sigset_t sigs;
@@ -272,7 +272,7 @@ void mnt_unlock_file(struct libmnt_lock *ml)
        if (!ml)
                return;
 
-       DBG(LOCKS, ul_debugobj(ml, "(%d) %s", getpid(),
+       DBG_OBJ(LOCKS, ml, ul_debug("(%d) %s", getpid(),
                        ml->locked ? "unlocking" : "cleaning"));
 
        unlock_simplelock(ml);
@@ -281,7 +281,7 @@ void mnt_unlock_file(struct libmnt_lock *ml)
        ml->lockfile_fd = -1;
 
        if (ml->sigblock) {
-               DBG(LOCKS, ul_debugobj(ml, "restoring sigmask"));
+               DBG_OBJ(LOCKS, ml, ul_debug("restoring sigmask"));
                sigprocmask(SIG_SETMASK, &ml->oldsigmask, NULL);
        }
 }
index 194817aacda5ab2a92878548e5931da16c925a30..02de06c847bec1c67ecd9dca05491f82b062b0cf 100644 (file)
@@ -58,7 +58,7 @@ struct libmnt_monitor *mnt_new_monitor(void)
        mn->fd = -1;
        INIT_LIST_HEAD(&mn->ents);
 
-       DBG(MONITOR, ul_debugobj(mn, "alloc"));
+       DBG_OBJ(MONITOR, mn, ul_debug("alloc"));
        return mn;
 }
 
@@ -198,7 +198,7 @@ int monitor_modify_epoll(struct libmnt_monitor *mn,
                if (fd < 0)
                        goto err;
 
-               DBG(MONITOR, ul_debugobj(mn, " add fd=%d (for %s)", fd, me->path));
+               DBG_OBJ(MONITOR, mn, ul_debug(" add fd=%d (for %s)", fd, me->path));
 
                ev.data.ptr = (void *) me;
 
@@ -212,7 +212,7 @@ int monitor_modify_epoll(struct libmnt_monitor *mn,
                        while (epoll_wait(mn->fd, events, 1, 0) > 0);
                }
        } else if (me->fd) {
-               DBG(MONITOR, ul_debugobj(mn, " remove fd=%d (for %s)", me->fd, me->path));
+               DBG_OBJ(MONITOR, mn, ul_debug(" remove fd=%d (for %s)", me->fd, me->path));
                if (epoll_ctl(mn->fd, EPOLL_CTL_DEL, me->fd, NULL) < 0) {
                        if (errno != ENOENT)
                                goto err;
@@ -259,7 +259,7 @@ int mnt_monitor_close_fd(struct libmnt_monitor *mn)
        }
 
        if (mn->fd >= 0) {
-               DBG(MONITOR, ul_debugobj(mn, "closing top-level monitor fd"));
+               DBG_OBJ(MONITOR, mn, ul_debug("closing top-level monitor fd"));
                close(mn->fd);
        }
        mn->fd = -1;
@@ -287,14 +287,14 @@ int mnt_monitor_get_fd(struct libmnt_monitor *mn)
        if (mn->fd >= 0)
                return mn->fd;
 
-       DBG(MONITOR, ul_debugobj(mn, "create top-level monitor fd"));
+       DBG_OBJ(MONITOR, mn, ul_debug("create top-level monitor fd"));
        mn->fd = epoll_create1(EPOLL_CLOEXEC);
        if (mn->fd < 0)
                return -errno;
 
        mnt_reset_iter(&itr, MNT_ITER_FORWARD);
 
-       DBG(MONITOR, ul_debugobj(mn, "adding monitor entries to epoll (fd=%d)", mn->fd));
+       DBG_OBJ(MONITOR, mn, ul_debug("adding monitor entries to epoll (fd=%d)", mn->fd));
        while (monitor_next_entry(mn, &itr, &me) == 0) {
                if (!me->enabled)
                        continue;
@@ -303,13 +303,13 @@ int mnt_monitor_get_fd(struct libmnt_monitor *mn)
                        goto err;
        }
 
-       DBG(MONITOR, ul_debugobj(mn, "successfully created monitor"));
+       DBG_OBJ(MONITOR, mn, ul_debug("successfully created monitor"));
        return mn->fd;
 err:
        rc = errno ? -errno : -EINVAL;
        close(mn->fd);
        mn->fd = -1;
-       DBG(MONITOR, ul_debugobj(mn, "failed to create monitor [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to create monitor [rc=%d]", rc));
        return rc;
 }
 
@@ -324,7 +324,7 @@ static int read_epoll_events(struct libmnt_monitor *mn, int timeout, struct moni
                *act = NULL;
 
        do {
-               DBG(MONITOR, ul_debugobj(mn, "calling epoll_wait(), timeout=%d", timeout));
+               DBG_OBJ(MONITOR, mn, ul_debug("calling epoll_wait(), timeout=%d", timeout));
                rc = epoll_wait(mn->fd, events, 1, timeout);
                if (rc < 0) {
                        rc = -errno;
@@ -355,10 +355,10 @@ static int read_epoll_events(struct libmnt_monitor *mn, int timeout, struct moni
        return 0;
 
 nothing:
-       DBG(MONITOR, ul_debugobj(mn, " *** nothing"));
+       DBG_OBJ(MONITOR, mn, ul_debug(" *** nothing"));
        return 1;
 failed:
-       DBG(MONITOR, ul_debugobj(mn, " *** error"));
+       DBG_OBJ(MONITOR, mn, ul_debug(" *** error"));
        return rc;
 }
 
@@ -449,7 +449,7 @@ int mnt_monitor_next_change(struct libmnt_monitor *mn,
        if (type)
                *type = me->type;
 
-       DBG(MONITOR, ul_debugobj(mn, " *** success [changed: %s, type=%d]", me->path, me->type));
+       DBG_OBJ(MONITOR, mn, ul_debug(" *** success [changed: %s, type=%d]", me->path, me->type));
        return 0;
 }
 
index 5f728ad2b9dce8d2b0973b88577c2fea0892a76e..20d20ff3aa5607b7952e9f441825a15b314a091a 100644 (file)
@@ -104,7 +104,7 @@ static int fanotify_get_fd(struct libmnt_monitor *mn, struct monitor_entry *me)
 
        data = (struct monitor_entrydata *) me->data;
        assert(data->ns_fd >= 0);
-       DBG(MONITOR, ul_debugobj(mn, " opening fanotify for %s", me->path));
+       DBG_OBJ(MONITOR, mn, ul_debug(" opening fanotify for %s", me->path));
 
        me->fd = fanotify_init(FAN_REPORT_MNT | FAN_CLOEXEC | FAN_NONBLOCK, 0);
 
@@ -121,7 +121,7 @@ static int fanotify_get_fd(struct libmnt_monitor *mn, struct monitor_entry *me)
                close(me->fd);
                me->fd = -1;
        }
-       DBG(MONITOR, ul_debugobj(mn, "failed to open fanotify FD [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to open fanotify FD [rc=%d]", rc));
        return rc;
 }
 
@@ -136,14 +136,14 @@ static int fanotify_process_event(
        if (!mn || !me || me->fd < 0 || !me->data)
                return -EINVAL;
 
-       DBG(MONITOR, ul_debugobj(mn, "reading fanotify event"));
+       DBG_OBJ(MONITOR, mn, ul_debug("reading fanotify event"));
 
        data = (struct monitor_entrydata *) me->data;
        data->remaining = 0;
        data->current = data->buf;
 
        if (mn->kernel_veiled && access(MNT_PATH_UTAB ".act", F_OK) == 0) {
-               DBG(MONITOR, ul_debugobj(mn, " kernel event veiled"));
+               DBG_OBJ(MONITOR, mn, ul_debug(" kernel event veiled"));
 
                /* just drain out */
                do {
@@ -160,7 +160,7 @@ static int fanotify_process_event(
                return 1;       /* nothing */
 
        data->remaining = (size_t) len;
-       DBG(MONITOR, ul_debugobj(mn, " fanotify event [len=%zu %p]",
+       DBG_OBJ(MONITOR, mn, ul_debug(" fanotify event [len=%zu %p]",
                                data->remaining, data->current));
 
        return 0;
@@ -179,7 +179,7 @@ static int fanotify_next_fs(struct libmnt_monitor *mn, struct monitor_entry *me,
        if (!mn || !me || me->fd < 0 || !me->data)
                return -EINVAL;
 
-       DBG(MONITOR, ul_debugobj(mn, "next fanotify fs"));
+       DBG_OBJ(MONITOR, mn, ul_debug("next fanotify fs"));
 
        data = (struct monitor_entrydata *) me->data;
        if (!fs || !data->remaining)
@@ -210,7 +210,7 @@ static int fanotify_next_fs(struct libmnt_monitor *mn, struct monitor_entry *me,
        if (meta->mask & FAN_MNT_DETACH)
                fs->flags |= MNT_FS_STATUS_DETACH;
 
-       DBG(MONITOR, ul_debugobj(mn, "fanotify fs id=%ju %s\n",
+       DBG_OBJ(MONITOR, mn, ul_debug("fanotify fs id=%ju %s\n",
                (uintmax_t) mnt_fs_get_uniq_id(fs),
                mnt_fs_is_attached(fs) ? "ATTACHED" :
                mnt_fs_is_detached(fs) ? "DETACHED" :
@@ -280,7 +280,7 @@ int mnt_monitor_enable_fanotify(struct libmnt_monitor *mn, int enable, int ns)
        if (!enable)
                return 0;
 
-       DBG(MONITOR, ul_debugobj(mn, "allocate new fanotify monitor"));
+       DBG_OBJ(MONITOR, mn, ul_debug("allocate new fanotify monitor"));
 
        /* create a new entry */
        me = monitor_new_entry(mn);
@@ -324,7 +324,7 @@ int mnt_monitor_enable_fanotify(struct libmnt_monitor *mn, int enable, int ns)
 err:
        rc = -errno;
        free_monitor_entry(me);
-       DBG(MONITOR, ul_debugobj(mn, "failed to allocate fanotify monitor [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to allocate fanotify monitor [rc=%d]", rc));
        return rc;
 }
 
index 6f3586e8fc929f37fb42db47a7f12cc19c2517d4..5e8b18b6a9347cca74b348a80d9b92a5476f80d4 100644 (file)
@@ -41,7 +41,7 @@ static int mountinfo_get_fd(struct libmnt_monitor *mn,
                return me->fd;          /* already initialized */
 
        assert(me->path);
-       DBG(MONITOR, ul_debugobj(mn, " open kernel monitor for %s", me->path));
+       DBG_OBJ(MONITOR, mn, ul_debug(" open kernel monitor for %s", me->path));
 
        me->fd = open(me->path, O_RDONLY|O_CLOEXEC);
        if (me->fd < 0)
@@ -50,7 +50,7 @@ static int mountinfo_get_fd(struct libmnt_monitor *mn,
        return me->fd;
 err:
        rc = -errno;
-       DBG(MONITOR, ul_debugobj(mn, "failed to create kernel  monitor [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to create kernel  monitor [rc=%d]", rc));
        return rc;
 }
 
@@ -62,7 +62,7 @@ static int mountinfo_process_event(struct libmnt_monitor *mn,
                return -EINVAL;
 
        if (mn->kernel_veiled && access(MNT_PATH_UTAB ".act", F_OK) == 0) {
-               DBG(MONITOR, ul_debugobj(mn, "kernel event veiled"));
+               DBG_OBJ(MONITOR, mn, ul_debug("kernel event veiled"));
                return 1;
        }
        return 0;
@@ -116,7 +116,7 @@ int mnt_monitor_enable_mountinfo(struct libmnt_monitor *mn, int enable)
        if (!enable)
                return 0;
 
-       DBG(MONITOR, ul_debugobj(mn, "allocate new kernel monitor"));
+       DBG_OBJ(MONITOR, mn, ul_debug("allocate new kernel monitor"));
 
        /* create a new entry */
        me = monitor_new_entry(mn);
@@ -147,7 +147,7 @@ int mnt_monitor_enable_mountinfo(struct libmnt_monitor *mn, int enable)
 err:
        rc = -errno;
        free_monitor_entry(me);
-       DBG(MONITOR, ul_debugobj(mn, "failed to allocate kernel monitor [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to allocate kernel monitor [rc=%d]", rc));
        return rc;
 }
 
index 33249d1144adb8493ae62c56aa905658043f6133..c1879fced3233e2e7115d35355364335c1383d6c 100644 (file)
@@ -145,7 +145,7 @@ static int userspace_monitor_get_fd(struct libmnt_monitor *mn,
                return me->fd;          /* already initialized */
 
        assert(me->path);
-       DBG(MONITOR, ul_debugobj(mn, " open userspace monitor for %s", me->path));
+       DBG_OBJ(MONITOR, mn, ul_debug(" open userspace monitor for %s", me->path));
 
        me->fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
        if (me->fd < 0)
@@ -160,7 +160,7 @@ err:
        if (me->fd >= 0)
                close(me->fd);
        me->fd = -1;
-       DBG(MONITOR, ul_debugobj(mn, "failed to create userspace monitor [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to create userspace monitor [rc=%d]", rc));
        return rc;
 }
 
@@ -178,7 +178,7 @@ static int userspace_process_event(struct libmnt_monitor *mn,
        if (!me || me->fd < 0)
                return -EINVAL;
 
-       DBG(MONITOR, ul_debugobj(mn, "process utab event"));
+       DBG_OBJ(MONITOR, mn, ul_debug("process utab event"));
 
        /* the me->fd is non-blocking */
        do {
@@ -196,27 +196,27 @@ static int userspace_process_event(struct libmnt_monitor *mn,
                        int fd = -1;
 
                        e = (const struct inotify_event *) p;
-                       DBG(MONITOR, ul_debugobj(mn, " inotify event 0x%x [%s]\n", e->mask, e->len ? e->name : ""));
+                       DBG_OBJ(MONITOR, mn, ul_debug(" inotify event 0x%x [%s]\n", e->mask, e->len ? e->name : ""));
 
                        if (e->mask & IN_CLOSE_WRITE)
                                status = 0;
                        else {
                                if (e->mask & IN_DELETE_SELF) {
-                                       DBG(MONITOR, ul_debugobj(mn, " resetting watch"));
+                                       DBG_OBJ(MONITOR, mn, ul_debug(" resetting watch"));
                                        userspace_free_data(me);
                                }
 
                                /* add watch for the event file */
                                if (userspace_add_watch(me, &status, &fd) == 0
                                    && fd >= 0 && fd != e->wd) {
-                                       DBG(MONITOR, ul_debugobj(mn, " removing watch [fd=%d]", e->wd));
+                                       DBG_OBJ(MONITOR, mn, ul_debug(" removing watch [fd=%d]", e->wd));
                                        inotify_rm_watch(me->fd, e->wd);
                                }
                        }
                }
        } while (1);
 
-       DBG(MONITOR, ul_debugobj(mn, "%s", status < 0  ? " failed" :
+       DBG_OBJ(MONITOR, mn, ul_debug("%s", status < 0  ? " failed" :
                                           status == 0 ? " success" : " nothing"));
        return status;
 }
@@ -270,12 +270,12 @@ int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, int enable, const ch
        if (!enable)
                return 0;
 
-       DBG(MONITOR, ul_debugobj(mn, "allocate new userspace monitor"));
+       DBG_OBJ(MONITOR, mn, ul_debug("allocate new userspace monitor"));
 
        if (!filename)
                filename = mnt_get_utab_path();         /* /run/mount/utab */
        if (!filename) {
-               DBG(MONITOR, ul_debugobj(mn, "failed to get userspace mount table path"));
+               DBG_OBJ(MONITOR, mn, ul_debug("failed to get userspace mount table path"));
                return -EINVAL;
        }
 
@@ -294,6 +294,6 @@ int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, int enable, const ch
 err:
        rc = -errno;
        free_monitor_entry(me);
-       DBG(MONITOR, ul_debugobj(mn, "failed to allocate userspace monitor [rc=%d]", rc));
+       DBG_OBJ(MONITOR, mn, ul_debug("failed to allocate userspace monitor [rc=%d]", rc));
        return rc;
 }
index 7a6a4fbe2bbf2d5ceb7fbd991dd2c991c7fdad27..6b65909d34023673f6cfe39dfbc981e4e94aedbd 100644 (file)
 #define MNT_DEBUG_ALL          0xFFFFFF
 
 UL_DEBUG_DECLARE_MASK(libmount);
-#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_)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(libmount)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(libmount, MNT_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(libmount, MNT_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(libmount, MNT_DEBUG_, m, x)
+#define DBG_FLUSH              __UL_DBG_FLUSH(libmount, MNT_DEBUG_)
 
 /*
  * NLS -- the library has to be independent on main program, so define
index 5bb32c6a8cf29ac3f6d157690205973012d7c2a3..383219f6259d4604ff519ced0b7dde112c611322 100644 (file)
@@ -86,7 +86,7 @@ struct libmnt_optlist *mnt_new_optlist(void)
 
        ls->linux_map = mnt_get_builtin_optmap(MNT_LINUX_MAP);
 
-       DBG(OPTLIST, ul_debugobj(ls, "alloc"));
+       DBG_OBJ(OPTLIST, ls, ul_debug("alloc"));
        return ls;
 }
 
@@ -143,7 +143,7 @@ int mnt_optlist_register_map(struct libmnt_optlist *ls, const struct libmnt_optm
        if (ls->nmaps + 1 >= MNT_OL_MAXMAPS)
                return -ERANGE;
 
-       DBG(OPTLIST, ul_debugobj(ls, "register map %p", map));
+       DBG_OBJ(OPTLIST, ls, ul_debug("register map %p", map));
        ls->maps[ls->nmaps++] = map;
        return 0;
 }
@@ -183,7 +183,7 @@ int mnt_optlist_remove_opt(struct libmnt_optlist *ls, struct libmnt_opt *opt)
        if (!opt)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, " remove %s", opt->name));
+       DBG_OBJ(OPTLIST, ls, ul_debug(" remove %s", opt->name));
 
        if (opt->map && opt->ent && opt->map == ls->linux_map) {
                if (opt->ent->id & MS_PROPAGATION)
@@ -315,7 +315,7 @@ int mnt_optlist_merge_opts(struct libmnt_optlist *ls)
        if (!ls)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "merging"));
+       DBG_OBJ(OPTLIST, ls, ul_debug("merging"));
        ls->merged = 1;
 
        /* deduplicate, keep last instance of the option only */
@@ -484,10 +484,10 @@ static struct libmnt_opt *optlist_new_opt(struct libmnt_optlist *ls,
                opt->recursive = 1;
 #endif
        if (ent && map) {
-               DBG(OPTLIST, ul_debugobj(ls, " added %s [id=0x%08x map=%p]",
+               DBG_OBJ(OPTLIST, ls, ul_debug(" added %s [id=0x%08x map=%p]",
                                opt->name, ent->id, map));
        } else {
-               DBG(OPTLIST, ul_debugobj(ls, " added %s", opt->name));
+               DBG_OBJ(OPTLIST, ls, ul_debug(" added %s", opt->name));
        }
        return opt;
 fail:
@@ -550,7 +550,7 @@ int mnt_optlist_set_optstr(struct libmnt_optlist *ls, const char *optstr,
        if (!ls)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "set %s", optstr));
+       DBG_OBJ(OPTLIST, ls, ul_debug("set %s", optstr));
 
        /* remove all already set options */
        list_for_each_safe(p, next, &ls->opts) {
@@ -573,7 +573,7 @@ int mnt_optlist_append_optstr(struct libmnt_optlist *ls, const char *optstr,
        if (!ls)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "append %s", optstr));
+       DBG_OBJ(OPTLIST, ls, ul_debug("append %s", optstr));
        return optlist_add_optstr(ls, optstr, map, NULL);
 }
 
@@ -583,7 +583,7 @@ int mnt_optlist_prepend_optstr(struct libmnt_optlist *ls, const char *optstr,
        if (!ls)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "prepend %s", optstr));
+       DBG_OBJ(OPTLIST, ls, ul_debug("prepend %s", optstr));
        return optlist_add_optstr(ls, optstr, map, &ls->opts);
 }
 
@@ -644,7 +644,7 @@ int mnt_optlist_append_flags(struct libmnt_optlist *ls, unsigned long flags,
        if (!ls || !map)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "append 0x%08lx", flags));
+       DBG_OBJ(OPTLIST, ls, ul_debug("append 0x%08lx", flags));
        return optlist_add_flags(ls, flags, map, NULL);
 }
 
@@ -657,7 +657,7 @@ int mnt_optlist_set_flags(struct libmnt_optlist *ls, unsigned long flags,
        if (!ls || !map)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "set 0x%08lx", flags));
+       DBG_OBJ(OPTLIST, ls, ul_debug("set 0x%08lx", flags));
 
        /* remove all already set options */
        list_for_each_safe(p, next, &ls->opts) {
@@ -682,7 +682,7 @@ int mnt_optlist_remove_flags(struct libmnt_optlist *ls, unsigned long flags,
        if (!ls || !map)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "remove 0x%08lx", flags));
+       DBG_OBJ(OPTLIST, ls, ul_debug("remove 0x%08lx", flags));
 
        list_for_each_safe(p, next, &ls->opts) {
                struct libmnt_opt *opt = list_entry(p, struct libmnt_opt, opts);
@@ -711,7 +711,7 @@ int mnt_optlist_insert_flags(struct libmnt_optlist *ls, unsigned long flags,
        if (!opt)
                return -EINVAL;
 
-       DBG(OPTLIST, ul_debugobj(ls, "insert 0x%08lx (after %s)",
+       DBG_OBJ(OPTLIST, ls, ul_debug("insert 0x%08lx (after %s)",
                                flags, opt->ent ? opt->ent->name : "???"));
 
        return optlist_add_flags(ls, flags, map, &opt->opts);
@@ -815,7 +815,7 @@ int mnt_optlist_get_flags(struct libmnt_optlist *ls, unsigned long *flags,
 
        *flags = cache->flags;
 
-       DBG(OPTLIST, ul_debugobj(ls, "return flags 0x%08lx [map=%p]", *flags, map));
+       DBG_OBJ(OPTLIST, ls, ul_debug("return flags 0x%08lx [map=%p]", *flags, map));
        return 0;
 }
 
@@ -883,7 +883,7 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
                        remount_reset &= ~x;
 
                if (opt->ent->mask & MNT_INVERT) {
-                       DBG(OPTLIST, ul_debugobj(ls, " clr: %s 0x%08" PRIx64,
+                       DBG_OBJ(OPTLIST, ls, ul_debug(" clr: %s 0x%08" PRIx64,
                                                opt->ent->name, x));
 
                        if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
@@ -898,12 +898,12 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
                                 * the last option wins and MOUNT_ATTR__ATIME
                                 * is required in clr mask.
                                 */
-                               DBG(OPTLIST, ul_debugobj(ls, " atime: %s 0x%08" PRIx64,
+                               DBG_OBJ(OPTLIST, ls, ul_debug(" atime: %s 0x%08" PRIx64,
                                                        opt->ent->name, x));
                                *clr |= MOUNT_ATTR__ATIME;
                                atime_set = x;
                        } else {
-                               DBG(OPTLIST, ul_debugobj(ls, " set: %s 0x%08" PRIx64,
+                               DBG_OBJ(OPTLIST, ls, ul_debug(" set: %s 0x%08" PRIx64,
                                                        opt->ent->name, x));
                                *set |= x;
                        }
@@ -911,13 +911,13 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
        }
 
        if (atime_set) {
-               DBG(OPTLIST, ul_debugobj(ls, " set atime 0x%08" PRIx64, atime_set));
+               DBG_OBJ(OPTLIST, ls, ul_debug(" set atime 0x%08" PRIx64, atime_set));
                *set |= atime_set;
        }
        if (remount_reset)
                *clr |= remount_reset;
 
-       DBG(OPTLIST, ul_debugobj(ls, "return attrs set=0x%08" PRIx64
+       DBG_OBJ(OPTLIST, ls, ul_debug("return attrs set=0x%08" PRIx64
                                      ", clr=0x%08" PRIx64 " %s",
                                *set, *clr,
                                rec == MNT_OL_REC ? "[rec]" :
@@ -1107,7 +1107,7 @@ int mnt_optlist_is_propagation_only(struct libmnt_optlist *ls)
                return 0;
 
        rest = flags & ~MS_PROPAGATION;
-       DBG(OPTLIST, ul_debugobj(ls, " propagation-only: %s",
+       DBG_OBJ(OPTLIST, ls, ul_debug(" propagation-only: %s",
                (rest == 0 || (rest & (MS_SILENT | MS_REC)) ? "y" : "n")));
 
        return (rest == 0 || (rest & (MS_SILENT | MS_REC)));
index 0d2b0ecd40622669f9c98627dc961473dcdb3d2b..9edcfac1c16b0e4132b23781c9a1fe9ef2550b84 100644 (file)
@@ -87,7 +87,7 @@ struct libmnt_table *mnt_new_table(void)
        if (!tb)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "alloc"));
+       DBG_OBJ(TAB, tb, ul_debug("alloc"));
        tb->refcount = 1;
        INIT_LIST_HEAD(&tb->ents);
        return tb;
@@ -107,7 +107,7 @@ int mnt_reset_table(struct libmnt_table *tb)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "reset"));
+       DBG_OBJ(TAB, tb, ul_debug("reset"));
 
        while (!list_empty(&tb->ents)) {
                struct libmnt_fs *fs = list_entry(tb->ents.next,
@@ -131,7 +131,7 @@ void mnt_ref_table(struct libmnt_table *tb)
 {
        if (tb) {
                tb->refcount++;
-               /*DBG(FS, ul_debugobj(tb, "ref=%d", tb->refcount));*/
+               /*DBG_OBJ(FS, tb, ul_debug("ref=%d", tb->refcount));*/
        }
 }
 
@@ -146,7 +146,7 @@ void mnt_unref_table(struct libmnt_table *tb)
 {
        if (tb) {
                tb->refcount--;
-               /*DBG(FS, ul_debugobj(tb, "unref=%d", tb->refcount));*/
+               /*DBG_OBJ(FS, tb, ul_debug("unref=%d", tb->refcount));*/
                if (tb->refcount <= 0)
                        mnt_free_table(tb);
        }
@@ -169,7 +169,7 @@ void mnt_free_table(struct libmnt_table *tb)
                return;
 
        mnt_reset_table(tb);
-       DBG(TAB, ul_debugobj(tb, "free [refcount=%d]", tb->refcount));
+       DBG_OBJ(TAB, tb, ul_debug("free [refcount=%d]", tb->refcount));
 
        mnt_unref_cache(tb->cache);
        free(tb->comm_intro);
@@ -431,7 +431,7 @@ int mnt_table_refer_statmnt(struct libmnt_table *tb, struct libmnt_statmnt *sm)
        mnt_unref_statmnt(tb->stmnt);
        mnt_ref_statmnt(sm);
 
-       DBG(TAB, ul_debugobj(tb, "refer statmnt"));
+       DBG_OBJ(TAB, tb, ul_debug("refer statmnt"));
 
        tb->stmnt = sm;
        return 0;
@@ -495,7 +495,7 @@ int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs)
        fs->tab = tb;
        tb->nents++;
 
-       DBG(TAB, ul_debugobj(tb, "add entry: %s %s",
+       DBG_OBJ(TAB, tb, ul_debug("add entry: %s %s",
                        mnt_fs_get_source(fs), mnt_fs_get_target(fs)));
        if (tb->stmnt)
                mnt_fs_refer_statmnt(fs, tb->stmnt);
@@ -518,9 +518,9 @@ static int __table_insert_fs(
        tb->nents++;
 
        if (mnt_fs_get_uniq_id(fs)) {
-               DBG(TAB, ul_debugobj(tb, "insert entry: %" PRIu64, mnt_fs_get_uniq_id(fs)));
+               DBG_OBJ(TAB, tb, ul_debug("insert entry: %" PRIu64, mnt_fs_get_uniq_id(fs)));
        } else {
-               DBG(TAB, ul_debugobj(tb, "insert entry: %s %s",
+               DBG_OBJ(TAB, tb, ul_debug("insert entry: %s %s",
                        mnt_fs_get_source(fs), mnt_fs_get_target(fs)));
        }
 
@@ -668,7 +668,7 @@ int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
        if (!tb || !is_mountinfo(tb))
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "lookup root fs"));
+       DBG_OBJ(TAB, tb, ul_debug("lookup root fs"));
 
        /* get smallest possible ID from the table */
        mnt_reset_iter(&itr, MNT_ITER_FORWARD);
@@ -686,7 +686,7 @@ int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
                struct libmnt_fs *x = get_parent_fs(tb, root_fs);
                if (!x || x == root_fs)
                        break;
-               DBG(TAB, ul_debugobj(tb, " messy mountinfo, walk to %s", mnt_fs_get_target(x)));
+               DBG_OBJ(TAB, tb, ul_debug(" messy mountinfo, walk to %s", mnt_fs_get_target(x)));
                root_fs = x;
        }
 
@@ -718,7 +718,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, ul_debugobj(tb, "lookup next child of '%s'",
+       DBG_OBJ(TAB, tb, ul_debug("lookup next child of '%s'",
                                mnt_fs_get_target(parent)));
        parent_id = mnt_fs_get_id(parent);
        direction = mnt_iter_get_direction(itr);
@@ -942,7 +942,7 @@ int mnt_table_find_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
        if (!tb || !itr || !match_func)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "lookup next fs"));
+       DBG_OBJ(TAB, tb, ul_debug("lookup next fs"));
 
        if (fs)
                *fs = NULL;
@@ -974,7 +974,7 @@ static int mnt_table_move_parent(struct libmnt_table *tb, int oldid, int newid)
        if (list_empty(&tb->ents))
                return 0;
 
-       DBG(TAB, ul_debugobj(tb, "moving parent ID from %d -> %d", oldid, newid));
+       DBG_OBJ(TAB, tb, ul_debug("moving parent ID from %d -> %d", oldid, newid));
        mnt_reset_iter(&itr, MNT_ITER_FORWARD);
 
        while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
@@ -1019,7 +1019,7 @@ int mnt_table_uniq_fs(struct libmnt_table *tb, int flags,
        if (flags & MNT_UNIQ_FORWARD)
                direction = MNT_ITER_FORWARD;
 
-       DBG(TAB, ul_debugobj(tb, "de-duplicate"));
+       DBG_OBJ(TAB, tb, ul_debug("de-duplicate"));
        mnt_reset_iter(&itr, direction);
 
        if ((flags & MNT_UNIQ_KEEPTREE) && !is_mountinfo(tb))
@@ -1042,7 +1042,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, ul_debugobj(tb, "remove duplicate %s",
+                       DBG_OBJ(TAB, tb, ul_debug("remove duplicate %s",
                                                mnt_fs_get_target(fs)));
                        mnt_table_remove_fs(tb, fs);
                }
@@ -1097,7 +1097,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, ul_debugobj(tb, "lookup MOUNTPOINT: '%s'", path));
+       DBG_OBJ(TAB, tb, ul_debug("lookup MOUNTPOINT: '%s'", path));
 
        if (!mnt_is_path(path))
                return NULL;
@@ -1151,7 +1151,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, ul_debugobj(tb, "lookup TARGET: '%s'", path));
+       DBG_OBJ(TAB, tb, ul_debug("lookup TARGET: '%s'", path));
 
        /* native @target */
        mnt_reset_iter(&itr, direction);
@@ -1162,7 +1162,7 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
 
        /* try absolute path */
        if (ul_is_relative_path(path) && (cn = ul_absolute_path(path))) {
-               DBG(TAB, ul_debugobj(tb, "lookup absolute TARGET: '%s'", cn));
+               DBG_OBJ(TAB, tb, ul_debug("lookup absolute TARGET: '%s'", cn));
                mnt_reset_iter(&itr, direction);
                while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
                        if (mnt_fs_streq_target(fs, cn)) {
@@ -1176,7 +1176,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, ul_debugobj(tb, "lookup canonical TARGET: '%s'", cn));
+       DBG_OBJ(TAB, tb, ul_debug("lookup canonical TARGET: '%s'", cn));
 
        /* canonicalized paths in struct libmnt_table */
        mnt_reset_iter(&itr, direction);
@@ -1240,7 +1240,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, ul_debugobj(tb, "lookup SRCPATH: '%s'", path));
+       DBG_OBJ(TAB, tb, ul_debug("lookup SRCPATH: '%s'", path));
 
        /* native paths */
        mnt_reset_iter(&itr, direction);
@@ -1261,7 +1261,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
                                        uint64_t subvol_id;
 
                                        if (mnt_parse_offset(val, len, &subvol_id)) {
-                                               DBG(TAB, ul_debugobj(tb, "failed to parse subvolid="));
+                                               DBG_OBJ(TAB, tb, ul_debug("failed to parse subvolid="));
                                                continue;
                                        }
                                        if (subvol_id != default_id)
@@ -1278,7 +1278,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, ul_debugobj(tb, "lookup canonical SRCPATH: '%s'", cn));
+       DBG_OBJ(TAB, tb, ul_debug("lookup canonical SRCPATH: '%s'", cn));
 
        nents = mnt_table_get_nents(tb);
 
@@ -1370,7 +1370,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, ul_debugobj(tb, "lookup by TAG: %s %s", tag, val));
+       DBG_OBJ(TAB, tb, ul_debug("lookup by TAG: %s %s", tag, val));
 
        /* look up by TAG */
        mnt_reset_iter(&itr, direction);
@@ -1420,7 +1420,7 @@ struct libmnt_fs *mnt_table_find_target_with_option(
        if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "lookup TARGET: '%s' with OPTION %s %s", path, option, val));
+       DBG_OBJ(TAB, tb, ul_debug("lookup TARGET: '%s' with OPTION %s %s", path, option, val));
 
        /* look up by native @target with OPTION */
        mnt_reset_iter(&itr, direction);
@@ -1457,7 +1457,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, ul_debugobj(tb, "lookup SOURCE: '%s'", source));
+       DBG_OBJ(TAB, tb, ul_debug("lookup SOURCE: '%s'", source));
 
        if (blkid_parse_tag_string(source, &t, &v) || !mnt_valid_tagname(t))
                fs = mnt_table_find_srcpath(tb, source, direction);
@@ -1494,7 +1494,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, ul_debugobj(tb, "lookup SOURCE: %s TARGET: %s", source, target));
+       DBG_OBJ(TAB, tb, ul_debug("lookup SOURCE: %s TARGET: %s", source, target));
 
        mnt_reset_iter(&itr, direction);
        while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
@@ -1529,7 +1529,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, ul_debugobj(tb, "lookup DEVNO: %d", (int) devno));
+       DBG_OBJ(TAB, tb, ul_debug("lookup DEVNO: %d", (int) devno));
 
        mnt_reset_iter(&itr, direction);
 
@@ -1560,7 +1560,7 @@ struct libmnt_fs *mnt_table_find_id(struct libmnt_table *tb, int id)
        if (!tb)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "lookup ID: %d", id));
+       DBG_OBJ(TAB, tb, ul_debug("lookup ID: %d", id));
        mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
 
        while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
@@ -1590,7 +1590,7 @@ struct libmnt_fs *mnt_table_find_uniq_id(struct libmnt_table *tb, uint64_t id)
        if (!tb)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "lookup uniq-ID: %" PRIu64, id));
+       DBG_OBJ(TAB, tb, ul_debug("lookup uniq-ID: %" PRIu64, id));
        mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
 
        while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
@@ -1816,7 +1816,7 @@ struct libmnt_fs *mnt_table_get_fs_root(struct libmnt_table *tb,
                 */
                src_root = mnt_fs_get_root(src_fs);
 
-               DBG(FS, ul_debugobj(fs, "source root: %s, source FS root: %s", root, src_root));
+               DBG_OBJ(FS, fs, ul_debug("source root: %s, source FS root: %s", root, src_root));
 
                if (src_root && root && !ul_startswith(root, src_root)) {
                        if (strcmp(root, "/") == 0) {
@@ -1875,12 +1875,12 @@ int __mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_f
        int rc = 0;
        dev_t devno = 0;
 
-       DBG(FS, ul_debugobj(fstab_fs, "mnt_table_is_fs_mounted: target=%s, source=%s",
+       DBG_OBJ(FS, fstab_fs, ul_debug("mnt_table_is_fs_mounted: target=%s, source=%s",
                                mnt_fs_get_target(fstab_fs),
                                mnt_fs_get_source(fstab_fs)));
 
        if (mnt_fs_is_swaparea(fstab_fs) || mnt_table_is_empty(tb)) {
-               DBG(FS, ul_debugobj(fstab_fs, "- ignore (swap or no data)"));
+               DBG_OBJ(FS, fstab_fs, ul_debug("- ignore (swap or no data)"));
                return 0;
        }
 
@@ -1924,12 +1924,12 @@ int __mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_f
        tgt = mnt_fs_get_target(fstab_fs);
 
        if (!tgt || !src) {
-               DBG(FS, ul_debugobj(fstab_fs, "- ignore (no source/target)"));
+               DBG_OBJ(FS, fstab_fs, ul_debug("- ignore (no source/target)"));
                goto done;
        }
        mnt_reset_iter(&itr, MNT_ITER_FORWARD);
 
-       DBG(FS, ul_debugobj(fstab_fs, "mnt_table_is_fs_mounted: src=%s, tgt=%s, root=%s", src, tgt, root));
+       DBG_OBJ(FS, fstab_fs, ul_debug("mnt_table_is_fs_mounted: src=%s, tgt=%s, root=%s", src, tgt, root));
 
        while (mnt_table_next_fs(tb, &itr, &fs) == 0) {
 
@@ -1953,18 +1953,18 @@ int __mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_f
 
                        if (mnt_fs_get_option(fstab_fs, "offset", &val, &len) == 0) {
                                if (mnt_parse_offset(val, len, &offset)) {
-                                       DBG(FS, ul_debugobj(fstab_fs, "failed to parse offset="));
+                                       DBG_OBJ(FS, fstab_fs, ul_debug("failed to parse offset="));
                                        continue;
                                }
                                flags = LOOPDEV_FL_OFFSET;
                        }
 
-                       DBG(FS, ul_debugobj(fs, "checking for loop: src=%s", mnt_fs_get_srcpath(fs)));
+                       DBG_OBJ(FS, fs, ul_debug("checking for loop: src=%s", mnt_fs_get_srcpath(fs)));
 #if __linux__
                        if (!loopdev_is_used(mnt_fs_get_srcpath(fs), src, offset, 0, flags))
                                continue;
 
-                       DBG(FS, ul_debugobj(fs, "used loop"));
+                       DBG_OBJ(FS, fs, ul_debug("used loop"));
 #endif
                }
 
@@ -2021,7 +2021,7 @@ done:
        free(root);
        free(tgt_buf);
 
-       DBG(TAB, ul_debugobj(tb, "mnt_table_is_fs_mounted: %s [rc=%d]", src, rc));
+       DBG_OBJ(TAB, tb, ul_debug("mnt_table_is_fs_mounted: %s [rc=%d]", src, rc));
        free(src2);
        return rc;
 }
index 2765caf7111acd8cd7ba602348388b0b7324d421..624593ebd2436b428408c803ccc948faffc5c354 100644 (file)
@@ -47,7 +47,7 @@ struct libmnt_tabdiff *mnt_new_tabdiff(void)
        if (!df)
                return NULL;
 
-       DBG(DIFF, ul_debugobj(df, "alloc"));
+       DBG_OBJ(DIFF, df, ul_debug("alloc"));
 
        INIT_LIST_HEAD(&df->changes);
        INIT_LIST_HEAD(&df->unused);
@@ -75,7 +75,7 @@ void mnt_free_tabdiff(struct libmnt_tabdiff *df)
        if (!df)
                return;
 
-       DBG(DIFF, ul_debugobj(df, "free"));
+       DBG_OBJ(DIFF, df, ul_debug("free"));
 
        while (!list_empty(&df->changes)) {
                struct tabdiff_entry *de = list_entry(df->changes.next,
@@ -129,7 +129,7 @@ static int tabdiff_reset(struct libmnt_tabdiff *df)
 {
        assert(df);
 
-       DBG(DIFF, ul_debugobj(df, "resetting"));
+       DBG_OBJ(DIFF, df, ul_debug("resetting"));
 
        /* zeroize all entries and move them to the list of unused
         */
@@ -158,7 +158,7 @@ static int tabdiff_add_entry(struct libmnt_tabdiff *df, struct libmnt_fs *old,
 
        assert(df);
 
-       DBG(DIFF, ul_debugobj(df, "add change on %s",
+       DBG_OBJ(DIFF, df, ul_debug("add change on %s",
                                mnt_fs_get_target(new ? new : old)));
 
        if (!list_empty(&df->unused)) {
@@ -243,7 +243,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, ul_debugobj(df, "analyze new (%d entries), "
+       DBG_OBJ(DIFF, df, ul_debug("analyze new (%d entries), "
                                          "old (%d entries)",
                                nn, no));
 
@@ -303,7 +303,7 @@ int mnt_diff_tables(struct libmnt_tabdiff *df, struct libmnt_table *old_tab,
                }
        }
 done:
-       DBG(DIFF, ul_debugobj(df, "%d changes detected", df->nchanges));
+       DBG_OBJ(DIFF, df, ul_debug("%d changes detected", df->nchanges));
        return df->nchanges;
 }
 
index bf60d521a631d1acd014e0b68e340573c4d0a253..dbbc2b8f67445f20369bdb3bf2bd39976f24b371 100644 (file)
@@ -93,9 +93,9 @@ static int table_init_listmount(struct libmnt_table *tb, size_t stepsiz)
        /* check if supported by current kernel */
        if (!ls && !has_listmount()) {
                if (errno == ENOSYS)
-                       DBG(TAB, ul_debugobj(tb, "listmount: unsuppported"));
+                       DBG_OBJ(TAB, tb, ul_debug("listmount: unsuppported"));
                if (errno == EINVAL)
-                       DBG(TAB, ul_debugobj(tb, "listmount: reverse unsuppported"));
+                       DBG_OBJ(TAB, tb, ul_debug("listmount: reverse unsuppported"));
                errno = ENOSYS;
                return -ENOSYS;
        }
@@ -129,7 +129,7 @@ static int table_init_listmount(struct libmnt_table *tb, size_t stepsiz)
                tb->lsmnt = ls;
        }
 
-       DBG(TAB, ul_debugobj(tb, "listmount: init [step=%zu]", ls->stepsiz));
+       DBG_OBJ(TAB, tb, ul_debug("listmount: init [step=%zu]", ls->stepsiz));
        return 0;
 }
 
@@ -233,7 +233,7 @@ int mnt_table_enable_listmount(struct libmnt_table *tb, int enable)
        if (tb && tb->lsmnt) {
                old = tb->lsmnt->enabled;
                tb->lsmnt->enabled = enable;
-               DBG(TAB, ul_debugobj(tb, "listmount() %s",
+               DBG_OBJ(TAB, tb, ul_debug("listmount() %s",
                                        enable ? "on" : "off"));
        }
        return old;
@@ -263,7 +263,7 @@ static int lsmnt_to_table(
        if (prev)
                mnt_ref_fs(prev);
 
-       DBG(TAB, ul_debugobj(tb, "listmount: insert %zu", nitems));
+       DBG_OBJ(TAB, tb, ul_debug("listmount: insert %zu", nitems));
 
        for (i = 0; rc == 0 && i < nitems; i++) {
                struct libmnt_fs *fs;
@@ -321,7 +321,7 @@ int mnt_table_next_lsmnt(struct libmnt_table *tb, int direction)
 
        ls->reverse = reverse;
 
-       DBG(TAB, ul_debugobj(tb, "listmount: call "
+       DBG_OBJ(TAB, tb, ul_debug("listmount: call "
                                 "[id=%" PRIu64", ns=%" PRIu64
                                 "last=%" PRIu64", sz=%zu %s]",
                                ls->id, ls->ns,
@@ -345,7 +345,7 @@ int mnt_table_next_lsmnt(struct libmnt_table *tb, int direction)
 done:
        mnt_table_enable_listmount(tb, 1);
 
-       DBG(TAB, ul_debugobj(tb, "listmount: on-demand done [rc=%d]", rc));
+       DBG_OBJ(TAB, tb, ul_debug("listmount: on-demand done [rc=%d]", rc));
        return rc;              /* nothing */
 }
 
@@ -371,7 +371,7 @@ int mnt_table_fetch_listmount(struct libmnt_table *tb)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "listmount: fetching all"));
+       DBG_OBJ(TAB, tb, ul_debug("listmount: fetching all"));
 
        if (!tb->lsmnt && (rc = table_init_listmount(tb, 0)) != 0)
                return rc;
@@ -387,7 +387,7 @@ int mnt_table_fetch_listmount(struct libmnt_table *tb)
        ls = tb->lsmnt;
 
        do {
-               DBG(TAB, ul_debugobj(tb, "listmount: call "
+               DBG_OBJ(TAB, tb, ul_debug("listmount: call "
                                 "[id=%" PRIu64", ns=%" PRIu64
                                 "last=%" PRIu64", sz=%zu]",
                                ls->id, ls->ns,
@@ -413,7 +413,7 @@ int mnt_table_fetch_listmount(struct libmnt_table *tb)
                mnt_statmnt_disable_fetching(tb->stmnt, stmnt_status);
        mnt_table_enable_listmount(tb, lsmnt_status);
 
-       DBG(TAB, ul_debugobj(tb, "listmount: fetching done [rc=%d]", rc));
+       DBG_OBJ(TAB, tb, ul_debug("listmount: fetching done [rc=%d]", rc));
 
        return rc;
 }
index 7ec4c401635a471716daf48afa59d005b625ab3b..5077e9a350d274db1d3a8fa51c98dfde78a99ad3 100644 (file)
@@ -532,7 +532,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, ul_debugobj(tb, "appending %s comment",
+       DBG_OBJ(TAB, tb, ul_debug("appending %s comment",
                        intro ? "intro" :
                        eof ? "trailing" : "fs"));
        if (intro)
@@ -571,7 +571,7 @@ next_line:
                pa->line++;
                s = strchr(pa->buf, '\n');
                if (!s) {
-                       DBG(TAB, ul_debugobj(tb, "%s:%zu: no final newline",
+                       DBG_OBJ(TAB, tb, ul_debug("%s:%zu: no final newline",
                                                pa->filename, pa->line));
 
                        /* Missing final newline?  Otherwise an extremely */
@@ -633,7 +633,7 @@ next_line:
        if (rc == 0)
                return 0;
 err:
-       DBG(TAB, ul_debugobj(tb, "%s:%zu: %s parse error", pa->filename, pa->line,
+       DBG_OBJ(TAB, tb, ul_debug("%s:%zu: %s parse error", pa->filename, pa->line,
                                tb->fmt == MNT_FMT_MOUNTINFO ? "mountinfo" :
                                tb->fmt == MNT_FMT_SWAPS ? "swaps" :
                                tb->fmt == MNT_FMT_FSTAB ? "tab" : "utab"));
@@ -714,7 +714,7 @@ static int kernel_fs_postparse(struct libmnt_parser *pa,
                        if (!real)
                                return -ENOMEM;
 
-                       DBG(TAB, ul_debugobj(tb, "canonical root FS: %s", real));
+                       DBG_OBJ(TAB, tb, ul_debug("canonical root FS: %s", real));
                        rc = __mnt_fs_set_source_ptr(fs, real);
 
                } else if (rc == 1) {
@@ -746,7 +746,7 @@ int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filenam
        assert(f);
        assert(filename);
 
-       DBG(TAB, ul_debugobj(tb, "%s: start parsing [entries=%d, filter=%s]",
+       DBG_OBJ(TAB, tb, ul_debug("%s: start parsing [entries=%d, filter=%s]",
                                filename, mnt_table_get_nents(tb),
                                tb->fltrcb ? "yes" : "not"));
 
@@ -765,7 +765,7 @@ int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filenam
                struct libmnt_fs *fs;
 
                if (feof(f)) {
-                       DBG(TAB, ul_debugobj(tb, "end-of-file"));
+                       DBG_OBJ(TAB, tb, ul_debug("end-of-file"));
                        break;
                }
                fs = mnt_new_fs();
@@ -803,23 +803,23 @@ int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filenam
 
                /* recoverable error */
                if (rc > 0) {
-                       DBG(TAB, ul_debugobj(tb, "recoverable error (continue)"));
+                       DBG_OBJ(TAB, tb, ul_debug("recoverable error (continue)"));
                        continue;
                }
 
                /* fatal errors */
                if (rc < 0 && !feof(f)) {
-                       DBG(TAB, ul_debugobj(tb, "fatal error"));
+                       DBG_OBJ(TAB, tb, ul_debug("fatal error"));
                        goto err;
                }
        } while (1);
 
-       DBG(TAB, ul_debugobj(tb, "%s: stop parsing (%d entries)",
+       DBG_OBJ(TAB, tb, ul_debug("%s: stop parsing (%d entries)",
                                filename, mnt_table_get_nents(tb)));
        parser_cleanup(&pa);
        return 0;
 err:
-       DBG(TAB, ul_debugobj(tb, "%s: parse error (rc=%d)", filename, rc));
+       DBG_OBJ(TAB, tb, ul_debug("%s: parse error (rc=%d)", filename, rc));
        parser_cleanup(&pa);
        return rc;
 }
@@ -851,7 +851,7 @@ int mnt_table_parse_file(struct libmnt_table *tb, const char *filename)
        } else
                rc = -errno;
 
-       DBG(TAB, ul_debugobj(tb, "parsing done [filename=%s, rc=%d]", filename, rc));
+       DBG_OBJ(TAB, tb, ul_debug("parsing done [filename=%s, rc=%d]", filename, rc));
        return rc;
 }
 
@@ -991,7 +991,7 @@ struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt, in
 
        tb = mnt_new_table();
        if (tb) {
-               DBG(TAB, ul_debugobj(tb, "new tab for file: %s", filename));
+               DBG_OBJ(TAB, tb, ul_debug("new tab for file: %s", filename));
                tb->fmt = fmt;
                if (mnt_table_parse_file(tb, filename) != 0) {
                        mnt_unref_table(tb);
@@ -1076,7 +1076,7 @@ int mnt_table_set_parser_fltrcb(struct libmnt_table *tb,
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "%s table parser filter", cb ? "set" : "unset"));
+       DBG_OBJ(TAB, tb, ul_debug("%s table parser filter", cb ? "set" : "unset"));
        tb->fltrcb = cb;
        tb->fltrcb_data = data;
        return 0;
@@ -1192,7 +1192,7 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
        if (!tb || !uf)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "merging user fs"));
+       DBG_OBJ(TAB, tb, ul_debug("merging user fs"));
 
        src = mnt_fs_get_srcpath(uf);
        target = mnt_fs_get_target(uf);
@@ -1214,12 +1214,12 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
                        continue;
 
                if (uniq_id > 0 && mnt_fs_get_uniq_id(fs)) {
-                       DBG(TAB, ul_debugobj(tb, " using uniq ID"));
+                       DBG_OBJ(TAB, tb, ul_debug(" using uniq ID"));
                        if (mnt_fs_get_uniq_id(fs) == uniq_id)
                                break;
 
                } else if (id > 0 && mnt_fs_get_id(fs)) {
-                       DBG(TAB, ul_debugobj(tb, " using ID"));
+                       DBG_OBJ(TAB, tb, ul_debug(" using ID"));
                        if (mnt_fs_get_id(fs) == id)
                                break;
 
@@ -1230,7 +1230,7 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
        }
 
        if (fs) {
-               DBG(TAB, ul_debugobj(tb, " found"));
+               DBG_OBJ(TAB, tb, ul_debug(" found"));
                mnt_fs_append_options(fs, optstr);
                mnt_fs_append_attributes(fs, attrs);
                mnt_fs_set_bindsrc(fs, mnt_fs_get_bindsrc(uf));
@@ -1252,12 +1252,12 @@ int __mnt_table_parse_mountinfo(struct libmnt_table *tb, const char *filename,
        assert(tb);
 
        if (filename)
-               DBG(TAB, ul_debugobj(tb, "%s requested as mount table", filename));
+               DBG_OBJ(TAB, tb, ul_debug("%s requested as mount table", filename));
 
        if (!filename || strcmp(filename, _PATH_PROC_MOUNTINFO) == 0) {
                filename = _PATH_PROC_MOUNTINFO;
                tb->fmt = MNT_FMT_MOUNTINFO;
-               DBG(TAB, ul_debugobj(tb, "mountinfo parse: #1 read mountinfo"));
+               DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #1 read mountinfo"));
        } else
                tb->fmt = MNT_FMT_GUESS;
 
@@ -1273,7 +1273,7 @@ int __mnt_table_parse_mountinfo(struct libmnt_table *tb, const char *filename,
 
        if (!is_mountinfo(tb))
                return 0;
-       DBG(TAB, ul_debugobj(tb, "mountinfo parse: #2 read utab"));
+       DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #2 read utab"));
 
        if (mnt_table_get_nents(tb) == 0)
                return 0;                       /* empty, ignore utab */
@@ -1297,7 +1297,7 @@ int __mnt_table_parse_mountinfo(struct libmnt_table *tb, const char *filename,
                priv_utab = 1;
        }
 
-       DBG(TAB, ul_debugobj(tb, "mountinfo parse: #3 merge utab"));
+       DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #3 merge utab"));
 
        if (rc == 0) {
                struct libmnt_fs *u_fs;
index 3cb5b30f956c327cfeb65cefaeb3371eddc9fac3..4beeaff6f072eb3b637c1e2a0097927dd3efa428 100644 (file)
@@ -63,7 +63,7 @@ struct libmnt_update *mnt_new_update(void)
                return NULL;
 
        upd->act_fd = -1;
-       DBG(UPDATE, ul_debugobj(upd, "allocate"));
+       DBG_OBJ(UPDATE, upd, ul_debug("allocate"));
        return upd;
 }
 
@@ -78,7 +78,7 @@ void mnt_free_update(struct libmnt_update *upd)
        if (!upd)
                return;
 
-       DBG(UPDATE, ul_debugobj(upd, "free"));
+       DBG_OBJ(UPDATE, upd, ul_debug("free"));
 
        mnt_unref_lock(upd->lock);
        mnt_unref_fs(upd->fs);
@@ -174,11 +174,11 @@ int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
        if (target && fs)
                return -EINVAL;
 
-       DBG(UPDATE, ul_debugobj(upd,
+       DBG_OBJ(UPDATE, upd, ul_debug(
                        "resetting FS [target=%s, flags=0x%08lx]",
                        target, mountflags));
        if (fs) {
-               DBG(UPDATE, ul_debugobj(upd, "FS template:"));
+               DBG_OBJ(UPDATE, upd, ul_debug("FS template:"));
                DBG(UPDATE, mnt_fs_print_debug(fs, stderr));
        }
 
@@ -196,7 +196,7 @@ int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
 
        rc = mnt_update_set_filename(upd, NULL);
        if (rc) {
-               DBG(UPDATE, ul_debugobj(upd, "no writable file available [rc=%d]", rc));
+               DBG_OBJ(UPDATE, upd, ul_debug("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, ul_debugobj(upd, "ready"));
+       DBG_OBJ(UPDATE, upd, ul_debug("ready"));
        upd->ready = 1;
        return 0;
 }
@@ -510,7 +510,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
        if (!tb || !upd->filename)
                return -EINVAL;
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: updating", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: updating", upd->filename));
 
        fd = mnt_open_uniq_filename(upd->filename, &uq);
        if (fd < 0)
@@ -530,7 +530,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
                while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
                        rc = fprintf_utab_fs(f, fs);
                        if (rc) {
-                               DBG(UPDATE, ul_debugobj(upd,
+                               DBG_OBJ(UPDATE, upd, ul_debug(
                                        "%s: write entry failed: %m", uq));
                                goto leave;
                        }
@@ -540,7 +540,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
 
                if (fflush(f) != 0) {
                        rc = -errno;
-                       DBG(UPDATE, ul_debugobj(upd, "%s: fflush failed: %m", uq));
+                       DBG_OBJ(UPDATE, upd, ul_debug("%s: fflush failed: %m", uq));
                        goto leave;
                }
 
@@ -566,7 +566,7 @@ leave:
 
        unlink(uq);     /* be paranoid */
        free(uq);
-       DBG(UPDATE, ul_debugobj(upd, "%s: done [rc=%d]", upd->filename, rc));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: done [rc=%d]", upd->filename, rc));
        return rc;
 }
 
@@ -600,7 +600,7 @@ int mnt_table_write_file(struct libmnt_table *tb, FILE *file)
        if (fflush(file) != 0)
                rc = -errno;
 
-       DBG(TAB, ul_debugobj(tb, "write file done [rc=%d]", rc));
+       DBG_OBJ(TAB, tb, ul_debug("write file done [rc=%d]", rc));
        return rc;
 }
 
@@ -619,7 +619,7 @@ int mnt_table_replace_file(struct libmnt_table *tb, const char *filename)
        FILE *f;
        char *uq = NULL;
 
-       DBG(TAB, ul_debugobj(tb, "%s: replacing", filename));
+       DBG_OBJ(TAB, tb, ul_debug("%s: replacing", filename));
 
        fd = mnt_open_uniq_filename(filename, &uq);
        if (fd < 0)
@@ -659,7 +659,7 @@ leave:
        unlink(uq);
        free(uq);
 
-       DBG(TAB, ul_debugobj(tb, "replace done [rc=%d]", rc));
+       DBG_OBJ(TAB, tb, ul_debug("replace done [rc=%d]", rc));
        return rc;
 }
 
@@ -688,7 +688,7 @@ static int update_add_entry(struct libmnt_update *upd)
        assert(upd->fs);
        assert(upd->lock);
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: add entry", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: add entry", upd->filename));
 
        rc = mnt_lock_file(upd->lock);
        if (rc)
@@ -712,7 +712,7 @@ static int update_remove_entry(struct libmnt_update *upd)
        assert(upd->target);
        assert(upd->lock);
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: remove entry", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: remove entry", upd->filename));
 
        rc = mnt_lock_file(upd->lock);
        if (rc)
@@ -739,7 +739,7 @@ static int update_modify_target(struct libmnt_update *upd)
 
        assert(upd);
        assert(upd->lock);
-       DBG(UPDATE, ul_debugobj(upd, "%s: modify target", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: modify target", upd->filename));
 
        rc = mnt_lock_file(upd->lock);
        if (rc)
@@ -806,7 +806,7 @@ static int update_modify_options(struct libmnt_update *upd)
        assert(upd->fs);
        assert(upd->lock);
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: modify options", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: modify options", upd->filename));
 
        fs = upd->fs;
 
@@ -848,7 +848,7 @@ static int update_add_options(struct libmnt_update *upd)
        if (!upd->fs->user_optstr)
                return 0;
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: add options", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: add options", upd->filename));
 
        fs = upd->fs;
 
@@ -866,7 +866,7 @@ static int update_add_options(struct libmnt_update *upd)
 
                        rc = mnt_optstr_get_missing(cur->user_optstr, upd->fs->user_optstr, &u);
                        if (!rc && u) {
-                               DBG(UPDATE, ul_debugobj(upd, " add missing: %s", u));
+                               DBG_OBJ(UPDATE, upd, ul_debug(" add missing: %s", u));
                                rc = mnt_optstr_append_option(&cur->user_optstr, u, NULL);
                        }
                        if (!rc && u)
@@ -925,7 +925,7 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc)
        if (!upd->ready)
                return 0;
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: update tab", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: update tab", upd->filename));
        if (upd->fs) {
                DBG(UPDATE, mnt_fs_print_debug(upd->fs, stderr));
        }
@@ -947,7 +947,7 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc)
 
        upd->ready = 1;
 done:
-       DBG(UPDATE, ul_debugobj(upd, "%s: update tab: done [rc=%d]",
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: update tab: done [rc=%d]",
                                upd->filename, rc));
        return rc;
 }
@@ -960,7 +960,7 @@ int mnt_update_already_done(struct libmnt_update *upd)
        if (!upd || !upd->filename || (!upd->fs && !upd->target))
                return -EINVAL;
 
-       DBG(UPDATE, ul_debugobj(upd, "%s: checking for previous update", upd->filename));
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: checking for previous update", upd->filename));
 
        tb = __mnt_new_table_from_file(upd->filename, MNT_FMT_UTAB, 1);
        if (!tb)
@@ -976,14 +976,14 @@ int mnt_update_already_done(struct libmnt_update *upd)
 
                fs = mnt_table_find_pair(tb, src, tgt, MNT_ITER_BACKWARD);
                if (fs) {
-                       DBG(UPDATE, ul_debugobj(upd, "%s: found %s %s",
+                       DBG_OBJ(UPDATE, upd, ul_debug("%s: found %s %s",
                                                upd->filename, src, tgt));
 
                        /* Check if utab entry (probably written by /sbin/mount.<type>
                         * helper) contains all options expected by this update */
                        if (mnt_optstr_get_missing(fs->user_optstr, upd->fs->user_optstr, NULL) == 0) {
                                upd->missing_options = 1;
-                               DBG(UPDATE, ul_debugobj(upd, " missing options detected"));
+                               DBG_OBJ(UPDATE, upd, ul_debug(" missing options detected"));
                        } else
                                rc = 1;
                }
@@ -991,7 +991,7 @@ int mnt_update_already_done(struct libmnt_update *upd)
        } else if (upd->target) {
                /* umount */
                if (!mnt_table_find_target(tb, upd->target, MNT_ITER_BACKWARD)) {
-                       DBG(UPDATE, ul_debugobj(upd, "%s: not-found (umounted) %s",
+                       DBG_OBJ(UPDATE, upd, ul_debug("%s: not-found (umounted) %s",
                                                upd->filename, upd->target));
                        rc = 1;
                }
@@ -999,7 +999,7 @@ int mnt_update_already_done(struct libmnt_update *upd)
 
        mnt_unref_table(tb);
 done:
-       DBG(UPDATE, ul_debugobj(upd, "%s: previous update check done [rc=%d]",
+       DBG_OBJ(UPDATE, upd, ul_debug("%s: previous update check done [rc=%d]",
                                upd->filename, rc));
        return rc;
 }
@@ -1015,7 +1015,7 @@ int mnt_update_emit_event(struct libmnt_update *upd)
        if (asprintf(&filename, "%s.event", upd->filename) <= 0)
                return -ENOMEM;
 
-       DBG(UPDATE, ul_debugobj(upd, "emitting utab event"));
+       DBG_OBJ(UPDATE, upd, ul_debug("emitting utab event"));
 
        fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC,
                            S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
@@ -1064,7 +1064,7 @@ int mnt_update_start(struct libmnt_update *upd)
        if (rc)
                return -MNT_ERR_LOCK;
 
-       DBG(UPDATE, ul_debugobj(upd, "creating act file"));
+       DBG_OBJ(UPDATE, upd, ul_debug("creating act file"));
 
        oldmask = umask(S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
        upd->act_fd = open(upd->act_filename, O_WRONLY|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR);
@@ -1085,7 +1085,7 @@ int mnt_update_start(struct libmnt_update *upd)
        mnt_unlock_file(upd->lock);
        return 0;
 fail:
-       DBG(UPDATE, ul_debugobj(upd, "act file failed [rc=%d]", rc));
+       DBG_OBJ(UPDATE, upd, ul_debug("act file failed [rc=%d]", rc));
        mnt_unlock_file(upd->lock);
        unlink(upd->act_filename);
        if (upd->act_fd >= 0)
@@ -1101,7 +1101,7 @@ int mnt_update_end(struct libmnt_update *upd)
        if (!upd || upd->act_fd < 0)
                return -EINVAL;
 
-       DBG(UPDATE, ul_debugobj(upd, "removing act file"));
+       DBG_OBJ(UPDATE, upd, ul_debug("removing act file"));
 
        /* make sure nobody else will use the file */
        rc = mnt_lock_file(upd->lock);
@@ -1115,9 +1115,9 @@ int mnt_update_end(struct libmnt_update *upd)
        /* check if nobody else need the file (if yes, then the file is under LOCK_SH) )*/
        if (flock(upd->act_fd, LOCK_EX | LOCK_NB) != 0) {
                if (errno == EWOULDBLOCK)
-                       DBG(UPDATE, ul_debugobj(upd, "act file used, no unlink"));
+                       DBG_OBJ(UPDATE, upd, ul_debug("act file used, no unlink"));
        } else {
-               DBG(UPDATE, ul_debugobj(upd, "unlinking act file"));
+               DBG_OBJ(UPDATE, upd, ul_debug("unlinking act file"));
                unlink(upd->act_filename);
        }
 
index efcb5b6afd2dfd4973edba7851cf0bab305e18e3..a39aa4ca1abde5c8dd424540e12ba260588141e8 100644 (file)
@@ -6,13 +6,13 @@ static void dbg_column(struct libscols_table *tb, struct libscols_column *cl)
        struct libscols_wstat *st;
 
        if (scols_column_is_hidden(cl)) {
-               DBG(COL, ul_debugobj(cl, "%s (hidden) ignored", cl->header.data));
+               DBG_OBJ(COL, cl, ul_debug("%s (hidden) ignored", cl->header.data));
                return;
        }
 
        st = &cl->wstat;
 
-       DBG(COL, ul_debugobj(cl, "#%zu %12s: width=%zd "
+       DBG_OBJ(COL, cl, ul_debug("#%zu %12s: width=%zd "
                                 "hint=%d max=%zu min=%zu "
                                 "0x04%x [%s%s%s]",
 
@@ -137,7 +137,7 @@ static void count_column_deviation(struct libscols_table *tb, struct libscols_co
                st->width_deviation = sqrtroot(variance);
        }
 
-       DBG(COL, ul_debugobj(cl, "%15s avg=%g, deviation=%g",
+       DBG_OBJ(COL, cl, ul_debug("%15s avg=%g, deviation=%g",
                                cl->header.data,
                                st->width_avg,
                                st->width_deviation));
@@ -400,7 +400,7 @@ static int reduce_column(struct libscols_table *tb,
                cl->flags |= SCOLS_FL_HIDDEN;
 
        if (cl->width != org_width)
-               DBG(COL, ul_debugobj(cl, " [%02zd] %s reduced %zu-->%zu",
+               DBG_OBJ(COL, cl, ul_debug(" [%02zd] %s reduced %zu-->%zu",
                                        cl->seqnum,
                                        cl->header.data, org_width, cl->width));
 
@@ -421,7 +421,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
        size_t colsepsz;
        int sorted = 0;
 
-       DBG(TAB, ul_debugobj(tb, "-----calculate-(termwidth=%zu, outwidth=%zu)-----", tb->termwidth, tb->outwidth));
+       DBG_OBJ(TAB, tb, ul_debug("-----calculate-(termwidth=%zu, outwidth=%zu)-----", tb->termwidth, tb->outwidth));
        tb->is_dummy_print = 1;
        colsepsz = scols_table_is_noencoding(tb) ?
                        mbs_width(colsep(tb)) :
@@ -461,13 +461,13 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
        }
 
        if (!tb->is_term) {
-               DBG(TAB, ul_debugobj(tb, " non-terminal output"));
+               DBG_OBJ(TAB, tb, ul_debug(" non-terminal output"));
                goto done;
        }
 
        /* be paranoid */
        if (width_min > tb->outwidth && scols_table_is_maxout(tb)) {
-               DBG(TAB, ul_debugobj(tb, " min width larger than terminal! [width=%zu, term=%zu, avail=%zu]",
+               DBG_OBJ(TAB, tb, ul_debug(" min width larger than terminal! [width=%zu, term=%zu, avail=%zu]",
                                        width_min, tb->termwidth, tb->outwidth));
                scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
                while (width_min > tb->outwidth
@@ -478,7 +478,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
                        width_min--;
                        cl->wstat.width_min--;
                }
-               DBG(TAB, ul_debugobj(tb, " min width reduced to %zu", width_min));
+               DBG_OBJ(TAB, tb, ul_debug(" min width reduced to %zu", width_min));
        }
 
        /* calculate statistics */
@@ -500,13 +500,13 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
                int xrc = 0, n = 0;
 
                if (!sorted) {
-                       DBG(TAB, ul_debugobj(tb, "sorting by deviation"));
+                       DBG_OBJ(TAB, tb, ul_debug("sorting by deviation"));
                        sort_columns(tb, cmp_deviation);
                        ON_DBG(TAB, dbg_columns(tb));
                        sorted = 1;
                }
 
-               DBG(TAB, ul_debugobj(tb, "#%d reduce stage (width=%zu, avail=%zu)",
+               DBG_OBJ(TAB, tb, ul_debug("#%d reduce stage (width=%zu, avail=%zu)",
                        stage, width, tb->outwidth));
 
                scols_reset_iter(&itr, SCOLS_ITER_BACKWARD);
@@ -525,7 +525,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
 
        /* enlarge */
        if (width < tb->outwidth) {
-               DBG(TAB, ul_debugobj(tb, " enlarge (extreme, available %zu)",
+               DBG_OBJ(TAB, tb, ul_debug(" enlarge (extreme, available %zu)",
                                        tb->outwidth - width));
                if (ignore_extremes) {
                        if (!sorted) {
@@ -551,7 +551,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
 
                                if (!add)
                                        continue;
-                               DBG(COL, ul_debugobj(cl, "  add +%zd (%s)",
+                               DBG_OBJ(COL, cl, ul_debug("  add +%zd (%s)",
                                                        add, cl->header.data));
                                cl->width += add;
                                width += add;
@@ -562,7 +562,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
                }
 
                if (width < tb->outwidth) {
-                       DBG(TAB, ul_debugobj(tb, " enlarge (absolute, available %zu)",
+                       DBG_OBJ(TAB, tb, ul_debug(" enlarge (absolute, available %zu)",
                                                tb->outwidth - width));
 
                        /* try enlarging all columns with absolute hint */
@@ -577,7 +577,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
                                                continue;
                                        if (cl->width >= (size_t) cl->width_hint)
                                                continue;
-                                       DBG(COL, ul_debugobj(cl, "  add +1 (%s)",
+                                       DBG_OBJ(COL, cl, ul_debug("  add +1 (%s)",
                                                                cl->header.data));
                                        cl->width++;
                                        width++;
@@ -591,7 +591,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
 
                }
                if (width < tb->outwidth && scols_table_is_maxout(tb)) {
-                       DBG(TAB, ul_debugobj(tb, " enlarge (max-out, available %zu)",
+                       DBG_OBJ(TAB, tb, ul_debug(" enlarge (max-out, available %zu)",
                                                tb->outwidth - width));
 
                        /* try enlarging all columns */
@@ -600,7 +600,7 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
                                while (scols_table_next_column(tb, &itr, &cl) == 0) {
                                        if (scols_column_is_hidden(cl))
                                                continue;
-                                       DBG(COL, ul_debugobj(cl, "  add +1 (%s)",
+                                       DBG_OBJ(COL, cl, ul_debug("  add +1 (%s)",
                                                                cl->header.data));
                                        cl->width++;
                                        width++;
@@ -611,11 +611,11 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf)
 
                } else if (width < tb->outwidth) {
                        /* enlarge the last column */
-                       DBG(TAB, ul_debugobj(tb, " enlarge (last column, available %zu)",
+                       DBG_OBJ(TAB, tb, ul_debug(" enlarge (last column, available %zu)",
                                                tb->outwidth - width));
 
                        if (!scols_column_is_right(last_cl)) {
-                               DBG(COL, ul_debugobj(last_cl, "  add +%zu (%s)",
+                               DBG_OBJ(COL, last_cl, ul_debug("  add +%zu (%s)",
                                                        tb->outwidth - width,
                                                        last_cl->header.data));
                                last_cl->width += tb->outwidth - width;
@@ -657,7 +657,7 @@ done:
                sort_columns(tb, cmp_seqnum);
 
        tb->is_dummy_print = 0;
-       DBG(TAB, ul_debugobj(tb, "-----final width: %zu (rc=%d)-----", width, rc));
+       DBG_OBJ(TAB, tb, ul_debug("-----final width: %zu (rc=%d)-----", width, rc));
        ON_DBG(TAB, dbg_columns(tb));
 
        return rc;
index 4c279166e8ed04c19b19bfbe98462420f4331f8d..41e3d87c3c7f6d403377aec7ef41c22bee388192 100644 (file)
@@ -44,7 +44,7 @@ int scols_reset_cell(struct libscols_cell *ce)
        if (!ce)
                return -EINVAL;
 
-       /*DBG(CELL, ul_debugobj(ce, "reset"));*/
+       /*DBG_OBJ(CELL, ce, ul_debug("reset"));*/
        free(ce->data);
        free(ce->color);
        free(ce->uri);
@@ -386,6 +386,6 @@ int scols_cell_copy_content(struct libscols_cell *dest,
        if (!rc)
                dest->userdata = src->userdata;
 
-       DBG(CELL, ul_debugobj(src, "copy"));
+       DBG_OBJ(CELL, src, ul_debug("copy"));
        return rc;
 }
index 461b6a69004851e04b1d8895c56d11421353ef48..2ae4c6227a905ff82ad73dec895ac06901f970e3 100644 (file)
@@ -40,7 +40,7 @@ struct libscols_column *scols_new_column(void)
        cl = calloc(1, sizeof(*cl));
        if (!cl)
                return NULL;
-       DBG(COL, ul_debugobj(cl, "alloc"));
+       DBG_OBJ(COL, cl, ul_debug("alloc"));
        cl->refcount = 1;
        INIT_LIST_HEAD(&cl->cl_columns);
        return cl;
@@ -68,7 +68,7 @@ void scols_ref_column(struct libscols_column *cl)
 void scols_unref_column(struct libscols_column *cl)
 {
        if (cl && --cl->refcount <= 0) {
-               DBG(COL, ul_debugobj(cl, "dealloc"));
+               DBG_OBJ(COL, cl, ul_debug("dealloc"));
                list_del(&cl->cl_columns);
                scols_reset_cell(&cl->header);
                free(cl->color);
@@ -99,7 +99,7 @@ struct libscols_column *scols_copy_column(const struct libscols_column *cl)
        if (!ret)
                return NULL;
 
-       DBG(COL, ul_debugobj(cl, "copy"));
+       DBG_OBJ(COL, cl, ul_debug("copy"));
 
        if (scols_column_set_color(ret, cl->color))
                goto err;
@@ -173,7 +173,7 @@ int scols_column_set_flags(struct libscols_column *cl, int flags)
                        cl->table->ntreecols--;
        }
 
-       DBG(COL, ul_debugobj(cl, "setting flags from 0x%04x to 0x%04x", cl->flags, flags));
+       DBG_OBJ(COL, cl, ul_debug("setting flags from 0x%04x to 0x%04x", cl->flags, flags));
        cl->flags = flags;
        return 0;
 }
@@ -965,7 +965,7 @@ int scols_column_set_properties(struct libscols_column *cl, const char *opts)
        unsigned int flags = 0;
        int rc = 0;
 
-       DBG(COL, ul_debugobj(cl, "apply properties '%s'", opts));
+       DBG_OBJ(COL, cl, ul_debug("apply properties '%s'", opts));
 
        while (rc == 0
               && !ul_optstr_next(&str, &name, &namesz, &value, &valuesz)) {
index f24fc76648c0b03ab4f314b96451227506a58714..c6c8146165b1dd99899abbf97c2e4f1c6be0dc4c 100644 (file)
@@ -171,7 +171,7 @@ static int guess_expr_datatype(struct filter_expr *n)
                        type = SCOLS_DATA_FLOAT;
        }
 
-       DBG(FPARAM, ul_debugobj(n, " expr datatype: %d", type));
+       DBG_OBJ(FPARAM, n, ul_debug(" expr datatype: %d", type));
        return type;
 }
 
index b4700da1be10d16b443f77dced1ff1fbaaf1b590..5a46ffa7dfce4613344a4529d6bb8267fafc8122 100644 (file)
@@ -56,7 +56,7 @@ static int param_set_data(struct filter_param *n, int type, const void *data)
 {
        const char *p;
 
-       /*DBG(FPARAM, ul_debugobj(n, " set %s data", datatype2str(type)));*/
+       /*DBG_OBJ(FPARAM, n, ul_debug(" set %s data", datatype2str(type)));*/
 
        switch (type) {
        case SCOLS_DATA_STRING:
@@ -113,7 +113,7 @@ struct filter_node *filter_new_param(
 
        if (holder == F_HOLDER_COLUMN) {
                n->holder_name = strdup((char *) data);
-               DBG(FLTR, ul_debugobj(fltr, "new %s holder", n->holder_name));
+               DBG_OBJ(FLTR, fltr, ul_debug("new %s holder", n->holder_name));
        }
 
        if (fltr)
@@ -167,7 +167,7 @@ static struct filter_param *copy_param(struct filter_param *n)
                break;
        }
 
-       DBG(FPARAM, ul_debugobj(n, "copying"));
+       DBG_OBJ(FPARAM, n, ul_debug("copying"));
        return (struct filter_param *) filter_new_param(NULL, n->type, F_HOLDER_NONE, data);
 }
 
@@ -272,7 +272,7 @@ int filter_param_reset_holder(struct filter_param *n)
                }
        }
 
-       DBG(FPARAM, ul_debugobj(n, "holder %s type: %s", n->holder_name, datatype2str(n->type)));
+       DBG_OBJ(FPARAM, n, ul_debug("holder %s type: %s", n->holder_name, datatype2str(n->type)));
        return 0;
 }
 
@@ -287,13 +287,13 @@ static int fetch_holder_data(struct libscols_filter *fltr __attribute__((__unuse
        if (n->fetched || n->holder != F_HOLDER_COLUMN)
                return 0;
        if (!cl) {
-               DBG(FPARAM, ul_debugobj(n, "no column for %s holder", n->holder_name));
+               DBG_OBJ(FPARAM, n, ul_debug("no column for %s holder", n->holder_name));
                return -EINVAL;
        }
-       DBG(FPARAM, ul_debugobj(n, "fetching %s data", n->holder_name));
+       DBG_OBJ(FPARAM, n, ul_debug("fetching %s data", n->holder_name));
 
        if (fltr->filler_cb && !scols_line_is_filled(ln, cl->seqnum)) {
-               DBG(FPARAM, ul_debugobj(n, "  by callback"));
+               DBG_OBJ(FPARAM, n, ul_debug("  by callback"));
                rc = fltr->filler_cb(fltr, ln, cl->seqnum, fltr->filler_data);
                if (rc)
                        return rc;
@@ -304,13 +304,13 @@ static int fetch_holder_data(struct libscols_filter *fltr __attribute__((__unuse
        if (scols_column_has_data_func(cl)) {
                struct libscols_cell *ce = scols_line_get_column_cell(ln, cl);
 
-               DBG(FPARAM, ul_debugobj(n, " using datafunc()"));
+               DBG_OBJ(FPARAM, n, ul_debug(" using datafunc()"));
                if (ce)
                        data = cl->datafunc(n->col, ce, cl->datafunc_data);
                if (data)
                        rc = param_set_data(n, scols_column_get_data_type(cl), data);
        } else {
-               DBG(FPARAM, ul_debugobj(n, " using as string"));
+               DBG_OBJ(FPARAM, n, ul_debug(" using as string"));
                data = scols_line_get_column_data(ln, n->col);
                rc = param_set_data(n, SCOLS_DATA_STRING, data);
        }
@@ -328,7 +328,7 @@ int filter_eval_param(struct libscols_filter *fltr,
 {
        int rc = 0;
 
-       DBG(FLTR, ul_debugobj(fltr, "eval param"));
+       DBG_OBJ(FLTR, fltr, ul_debug("eval param"));
 
        rc = fetch_holder_data(fltr, n, ln);
        if (n->empty || rc) {
@@ -355,7 +355,7 @@ int filter_eval_param(struct libscols_filter *fltr,
        }
 done:
        if (rc)
-               DBG(FLTR, ul_debugobj(fltr, "failed eval param [rc=%d]", rc));
+               DBG_OBJ(FLTR, fltr, ul_debug("failed eval param [rc=%d]", rc));
        return rc;
 }
 
@@ -405,7 +405,7 @@ int filter_count_param(struct libscols_filter *fltr,
        }
 
        ct->has_result = 1;
-       DBG(FLTR, ul_debugobj(fltr, "counted '%s' [result: %llu]", ct->name, ct->result));
+       DBG_OBJ(FLTR, fltr, ul_debug("counted '%s' [result: %llu]", ct->name, ct->result));
        return 0;
 }
 
@@ -723,9 +723,9 @@ static int cast_param(int type, struct filter_param *n)
                return 0;
 
        if (orgtype == SCOLS_DATA_STRING)
-               DBG(FPARAM, ul_debugobj(n, " casting \"%s\" to %s", n->val.str, datatype2str(type)));
+               DBG_OBJ(FPARAM, n, ul_debug(" casting \"%s\" to %s", n->val.str, datatype2str(type)));
        else
-               DBG(FPARAM, ul_debugobj(n, " casting %s to %s", datatype2str(orgtype), datatype2str(type)));
+               DBG_OBJ(FPARAM, n, ul_debug(" casting %s to %s", datatype2str(orgtype), datatype2str(type)));
 
        switch (orgtype) {
        case SCOLS_DATA_STRING:
@@ -749,7 +749,7 @@ static int cast_param(int type, struct filter_param *n)
                n->type = type;
 
        if (rc)
-               DBG(FPARAM, ul_debugobj(n, "cast done [rc=%d]", rc));
+               DBG_OBJ(FPARAM, n, ul_debug("cast done [rc=%d]", rc));
        return rc;
 }
 
@@ -762,7 +762,7 @@ int filter_cast_param(struct libscols_filter *fltr,
        int rc;
        int orgtype = n->type;
 
-       DBG(FPARAM, ul_debugobj(n, "casting param to %s", datatype2str(type)));
+       DBG_OBJ(FPARAM, n, ul_debug("casting param to %s", datatype2str(type)));
        rc = fetch_holder_data(fltr, n, ln);
        if (rc)
                return rc;
@@ -778,7 +778,7 @@ int filter_cast_param(struct libscols_filter *fltr,
                return -ENOMEM;
        rc = cast_param(type, *result);
 
-       DBG(FPARAM, ul_debugobj(n, "cast done [rc=%d]", rc));
+       DBG_OBJ(FPARAM, n, ul_debug("cast done [rc=%d]", rc));
        return rc;
 }
 
@@ -844,7 +844,7 @@ int scols_filter_assign_column(struct libscols_filter *fltr,
                if (n->col)
                        scols_unref_column(n->col);
 
-               DBG(FPARAM, ul_debugobj(n, "assign %s to column %s", name,
+               DBG_OBJ(FPARAM, n, ul_debug("assign %s to column %s", name,
                                        scols_column_get_name(col)));
                n->col = col;
                scols_ref_column(col);
index 70bc57cdcd6e72cb12c2a841a7a44b1daa506994..2ce28ebd73b219d05e03833599a62b64f9cb1600 100644 (file)
@@ -42,7 +42,7 @@ struct libscols_filter *scols_new_filter(const char *str)
        if (!fltr)
                return NULL;
 
-       DBG(FLTR, ul_debugobj(fltr, "alloc"));
+       DBG_OBJ(FLTR, fltr, ul_debug("alloc"));
        fltr->refcount = 1;
        INIT_LIST_HEAD(&fltr->params);
        INIT_LIST_HEAD(&fltr->counters);
@@ -89,7 +89,7 @@ static void remove_counters(struct libscols_filter *fltr)
        if (!fltr)
                return;
 
-       DBG(FLTR, ul_debugobj(fltr, "remove all counters"));
+       DBG_OBJ(FLTR, fltr, ul_debug("remove all counters"));
        while (!list_empty(&fltr->counters)) {
                struct libscols_counter *ct = list_entry(fltr->counters.next,
                                struct libscols_counter, counters);
@@ -113,7 +113,7 @@ static void remove_counters(struct libscols_filter *fltr)
 void scols_unref_filter(struct libscols_filter *fltr)
 {
        if (fltr && --fltr->refcount <= 0) {
-               DBG(FLTR, ul_debugobj(fltr, "dealloc"));
+               DBG_OBJ(FLTR, fltr, ul_debug("dealloc"));
                reset_filter(fltr);
                remove_counters(fltr);
                free(fltr);
@@ -309,7 +309,7 @@ int scols_line_apply_filter(struct libscols_line *ln,
 
        if (status)
                *status = res;
-       DBG(FLTR, ul_debugobj(fltr, "filter done [rc=%d, status=%d]", rc, res));
+       DBG_OBJ(FLTR, fltr, ul_debug("filter done [rc=%d, status=%d]", rc, res));
        return rc;
 }
 
@@ -382,7 +382,7 @@ struct libscols_counter *scols_filter_new_counter(struct libscols_filter *fltr)
        if (!ct)
                return NULL;
 
-       DBG(FLTR, ul_debugobj(fltr, "alloc counter"));
+       DBG_OBJ(FLTR, fltr, ul_debug("alloc counter"));
 
        ct->filter = fltr;              /* don't use ref.counting here */
        INIT_LIST_HEAD(&ct->counters);
index 7e004b6477d025e9e92fc76da4949e8211ee0f91..b83f61f74e5268a92f6ec7e4d5b318c647b2fee3 100644 (file)
@@ -30,7 +30,7 @@ void scols_group_remove_children(struct libscols_group *gr)
                struct libscols_line *ln = list_entry(gr->gr_children.next,
                                                struct libscols_line, ln_children);
 
-               DBG(GROUP, ul_debugobj(gr, "remove child"));
+               DBG_OBJ(GROUP, gr, ul_debug("remove child"));
                list_del_init(&ln->ln_children);
                scols_ref_group(ln->parent_group);
                ln->parent_group = NULL;
@@ -47,7 +47,7 @@ void scols_group_remove_members(struct libscols_group *gr)
                struct libscols_line *ln = list_entry(gr->gr_members.next,
                                                struct libscols_line, ln_groups);
 
-               DBG(GROUP, ul_debugobj(gr, "remove member [%p]", ln));
+               DBG_OBJ(GROUP, gr, ul_debug("remove member [%p]", ln));
                list_del_init(&ln->ln_groups);
 
                scols_unref_group(ln->group);
@@ -62,7 +62,7 @@ void scols_group_remove_members(struct libscols_group *gr)
 void scols_unref_group(struct libscols_group *gr)
 {
        if (gr && --gr->refcount <= 0) {
-               DBG(GROUP, ul_debugobj(gr, "dealloc"));
+               DBG_OBJ(GROUP, gr, ul_debug("dealloc"));
                scols_group_remove_children(gr);
                list_del(&gr->gr_groups);
                free(gr);
@@ -79,7 +79,7 @@ static void groups_fix_members_order(struct libscols_line *ln)
        if (ln->group) {
                INIT_LIST_HEAD(&ln->ln_groups);
                list_add_tail(&ln->ln_groups, &ln->group->gr_members);
-               DBG(GROUP, ul_debugobj(ln->group, "fixing member line=%p [%zu/%zu]",
+               DBG_OBJ(GROUP, ln->group, ul_debug("fixing member line=%p [%zu/%zu]",
                                        ln, ln->group->nmembers,
                                        list_count_entries(&ln->group->gr_members)));
        }
@@ -96,7 +96,7 @@ static void groups_fix_members_order(struct libscols_line *ln)
            && is_last_group_member(ln)
            && ln->group->nmembers == list_count_entries(&ln->group->gr_members)) {
 
-               DBG(GROUP, ul_debugobj(ln->group, "fixing childs"));
+               DBG_OBJ(GROUP, ln->group, ul_debug("fixing childs"));
                scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
                while (scols_line_next_group_child(ln, &itr, &child) == 0)
                        groups_fix_members_order(child);
@@ -168,13 +168,13 @@ static void grpset_debug(struct libscols_table *tb, struct libscols_line *ln)
                        struct libscols_group *gr = tb->grpset[i];
 
                        if (ln)
-                               DBG(LINE, ul_debugobj(ln, "grpset[%zu]: %p %s", i,
+                               DBG_OBJ(LINE, ln, ul_debug("grpset[%zu]: %p %s", i,
                                        gr, group_state_to_string(gr->state)));
                        else
                                DBG(LINE, ul_debug("grpset[%zu]: %p %s", i,
                                        gr, group_state_to_string(gr->state)));
                } else if (ln) {
-                       DBG(LINE, ul_debugobj(ln, "grpset[%zu]: free", i));
+                       DBG_OBJ(LINE, ln, ul_debug("grpset[%zu]: free", i));
                } else
                        DBG(LINE, ul_debug("grpset[%zu]: free", i));
        }
@@ -228,7 +228,7 @@ static void grpset_apply_group_state(struct libscols_group **xx, int state, stru
 {
        size_t i;
 
-       DBG(GROUP, ul_debugobj(gr, "   applying state to grpset"));
+       DBG_OBJ(GROUP, gr, ul_debug("   applying state to grpset"));
 
        /* gr->state holds the old state, @state is the new state
         */
@@ -247,7 +247,7 @@ static struct libscols_group **grpset_locate_freespace(struct libscols_table *tb
        if (!tb->grpset_size)
                prepend = 0;
        /*
-       DBG(TAB, ul_debugobj(tb, "orig grpset:"));
+       DBG_OBJ(TAB, tb, ul_debug("orig grpset:"));
        grpset_debug(tb, NULL);
        */
        if (prepend) {
@@ -275,7 +275,7 @@ static struct libscols_group **grpset_locate_freespace(struct libscols_table *tb
                }
        }
 
-       DBG(TAB, ul_debugobj(tb, "   realocate grpset [sz: old=%zu, new=%zu, new_chunks=%d]",
+       DBG_OBJ(TAB, tb, ul_debug("   realocate grpset [sz: old=%zu, new=%zu, new_chunks=%d]",
                                tb->grpset_size, tb->grpset_size + wanted, chunks));
 
        tmp = reallocarray(tb->grpset, tb->grpset_size + wanted, sizeof(struct libscols_group *));
@@ -285,7 +285,7 @@ static struct libscols_group **grpset_locate_freespace(struct libscols_table *tb
        tb->grpset = tmp;
 
        if (prepend) {
-               DBG(TAB, ul_debugobj(tb, "   prepending free space"));
+               DBG_OBJ(TAB, tb, ul_debug("   prepending free space"));
                char *dest = (char *) tb->grpset;
 
                memmove(        dest + (wanted * sizeof(struct libscols_group *)),
@@ -301,7 +301,7 @@ static struct libscols_group **grpset_locate_freespace(struct libscols_table *tb
 
 done:
        /*
-       DBG(TAB, ul_debugobj(tb, "new grpset:"));
+       DBG_OBJ(TAB, tb, ul_debug("new grpset:"));
        grpset_debug(tb, NULL);
        */
        return first;
@@ -325,20 +325,20 @@ static int grpset_update(struct libscols_table *tb, struct libscols_line *ln, st
        struct libscols_group **xx;
        int state;
 
-       DBG(LINE, ul_debugobj(ln, "   group [%p] grpset update [grpset size=%zu]", gr, tb->grpset_size));
+       DBG_OBJ(LINE, ln, ul_debug("   group [%p] grpset update [grpset size=%zu]", gr, tb->grpset_size));
 
        /* new state, note that gr->state still holds the original state */
        state = group_state_for_line(gr, ln);
-       DBG(LINE, ul_debugobj(ln, "    state %s --> %s",
+       DBG_OBJ(LINE, ln, ul_debug("    state %s --> %s",
                        group_state_to_string(gr->state),
                        group_state_to_string(state)));
 
        if (state == SCOLS_GSTATE_FIRST_MEMBER && gr->state != SCOLS_GSTATE_NONE) {
-               DBG(LINE, ul_debugobj(ln, "wrong group initialization (%s)", group_state_to_string(gr->state)));
+               DBG_OBJ(LINE, ln, ul_debug("wrong group initialization (%s)", group_state_to_string(gr->state)));
                abort();
        }
        if (state != SCOLS_GSTATE_NONE && gr->state == SCOLS_GSTATE_LAST_CHILD) {
-               DBG(LINE, ul_debugobj(ln, "wrong group termination (%s)", group_state_to_string(gr->state)));
+               DBG_OBJ(LINE, ln, ul_debug("wrong group termination (%s)", group_state_to_string(gr->state)));
                abort();
        }
        if (gr->state == SCOLS_GSTATE_LAST_MEMBER &&
@@ -346,7 +346,7 @@ static int grpset_update(struct libscols_table *tb, struct libscols_line *ln, st
              state == SCOLS_GSTATE_CONT_CHILDREN ||
              state == SCOLS_GSTATE_MIDDLE_CHILD ||
              state == SCOLS_GSTATE_NONE)) {
-               DBG(LINE, ul_debugobj(ln, "wrong group member->child order"));
+               DBG_OBJ(LINE, ln, ul_debug("wrong group member->child order"));
                abort();
        }
 
@@ -360,7 +360,7 @@ static int grpset_update(struct libscols_table *tb, struct libscols_line *ln, st
        else
                xx = grpset_locate_group(tb, gr);
        if (!xx) {
-               DBG(LINE, ul_debugobj(ln, "failed to locate group or reallocate grpset"));
+               DBG_OBJ(LINE, ln, ul_debug("failed to locate group or reallocate grpset"));
                return -ENOMEM;
        }
 
@@ -375,7 +375,7 @@ static int grpset_update_active_groups(struct libscols_table *tb, struct libscol
        size_t i;
        struct libscols_group *last = NULL;
 
-       DBG(LINE, ul_debugobj(ln, "   update for active groups"));
+       DBG_OBJ(LINE, ln, ul_debug("   update for active groups"));
 
        for (i = 0; i < tb->grpset_size; i++) {
                struct libscols_group *gr = tb->grpset[i];
@@ -388,7 +388,7 @@ static int grpset_update_active_groups(struct libscols_table *tb, struct libscol
                        break;
        }
 
-       DBG(LINE, ul_debugobj(ln, "   <- active groups updated [rc=%d]", rc));
+       DBG_OBJ(LINE, ln, ul_debug("   <- active groups updated [rc=%d]", rc));
        return rc;
 }
 
@@ -396,12 +396,12 @@ int scols_groups_update_grpset(struct libscols_table *tb, struct libscols_line *
 {
        int rc = 0;
 
-       DBG(LINE, ul_debugobj(ln, "  grpset update [line: group=%p, parent_group=%p",
+       DBG_OBJ(LINE, ln, ul_debug("  grpset update [line: group=%p, parent_group=%p",
                                ln->group, ln->parent_group));
 
        rc = grpset_update_active_groups(tb, ln);
        if (!rc && ln->group && ln->group->state == SCOLS_GSTATE_NONE) {
-               DBG(LINE, ul_debugobj(ln, " introduce a new group"));
+               DBG_OBJ(LINE, ln, ul_debug(" introduce a new group"));
                rc = grpset_update(tb, ln, ln->group);
        }
        return rc;
@@ -412,16 +412,16 @@ void scols_groups_reset_state(struct libscols_table *tb)
        struct libscols_iter itr;
        struct libscols_group *gr;
 
-       DBG(TAB, ul_debugobj(tb, "reset groups states"));
+       DBG_OBJ(TAB, tb, ul_debug("reset groups states"));
 
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
        while (scols_table_next_group(tb, &itr, &gr) == 0) {
-               DBG(GROUP, ul_debugobj(gr, " reset to NONE"));
+               DBG_OBJ(GROUP, gr, ul_debug(" reset to NONE"));
                gr->state = SCOLS_GSTATE_NONE;
        }
 
        if (tb->grpset) {
-               DBG(TAB, ul_debugobj(tb, " zeroize grpset"));
+               DBG_OBJ(TAB, tb, ul_debug(" zeroize grpset"));
                memset(tb->grpset, 0, tb->grpset_size * sizeof(struct libscols_group *));
        }
        tb->ngrpchlds_pending = 0;
@@ -429,7 +429,7 @@ void scols_groups_reset_state(struct libscols_table *tb)
 
 static void add_member(struct libscols_group *gr, struct libscols_line *ln)
 {
-       DBG(GROUP, ul_debugobj(gr, "add member %p", ln));
+       DBG_OBJ(GROUP, gr, ul_debug("add member %p", ln));
 
        ln->group = gr;
        gr->nmembers++;
@@ -496,16 +496,16 @@ int scols_table_group_lines(      struct libscols_table *tb,
        struct libscols_group *gr = NULL;
 
        if (!tb || !member) {
-               DBG(GROUP, ul_debugobj(gr, "failed group lines (no table or member)"));
+               DBG_OBJ(GROUP, gr, ul_debug("failed group lines (no table or member)"));
                return -EINVAL;
        }
        if (ln)  {
                if (ln->group && !member->group) {
-                       DBG(GROUP, ul_debugobj(gr, "failed group lines (new group, line member of another)"));
+                       DBG_OBJ(GROUP, gr, ul_debug("failed group lines (new group, line member of another)"));
                        return -EINVAL;
                }
                if (ln->group && member->group && ln->group != member->group) {
-                       DBG(GROUP, ul_debugobj(gr, "failed group lines (groups mismatch between member and line)"));
+                       DBG_OBJ(GROUP, gr, ul_debug("failed group lines (groups mismatch between member and line)"));
                        return -EINVAL;
                }
        }
@@ -517,7 +517,7 @@ int scols_table_group_lines(        struct libscols_table *tb,
                gr = calloc(1, sizeof(*gr));
                if (!gr)
                        return -ENOMEM;
-               DBG(GROUP, ul_debugobj(gr, "alloc"));
+               DBG_OBJ(GROUP, gr, ul_debug("alloc"));
                gr->refcount = 1;
                INIT_LIST_HEAD(&gr->gr_members);
                INIT_LIST_HEAD(&gr->gr_children);
@@ -563,7 +563,7 @@ int scols_line_link_group(struct libscols_line *ln, struct libscols_line *member
        if (!list_empty(&ln->ln_children))
                return -EINVAL;
 
-       DBG(GROUP, ul_debugobj(member->group, "add child"));
+       DBG_OBJ(GROUP, member->group, ul_debug("add child"));
 
        list_add_tail(&ln->ln_children, &member->group->gr_children);
        scols_ref_line(ln);
index ffefcfba018a14fac8342bad856f83b4a4e0e5e9..bc3ef08cc7fbeb325268e5aae9190fe4c03b8cd1 100644 (file)
@@ -42,7 +42,7 @@ struct libscols_line *scols_new_line(void)
        if (!ln)
                return NULL;
 
-       DBG(LINE, ul_debugobj(ln, "alloc"));
+       DBG_OBJ(LINE, ln, ul_debug("alloc"));
        ln->refcount = 1;
        INIT_LIST_HEAD(&ln->ln_lines);
        INIT_LIST_HEAD(&ln->ln_children);
@@ -73,7 +73,7 @@ void scols_ref_line(struct libscols_line *ln)
 void scols_unref_line(struct libscols_line *ln)
 {
        if (ln && --ln->refcount <= 0) {
-               DBG(CELL, ul_debugobj(ln, "dealloc"));
+               DBG_OBJ(CELL, ln, ul_debug("dealloc"));
                list_del(&ln->ln_lines);
                list_del(&ln->ln_children);
                list_del(&ln->ln_groups);
@@ -98,7 +98,7 @@ void scols_line_free_cells(struct libscols_line *ln)
        if (!ln || !ln->cells)
                return;
 
-       DBG(LINE, ul_debugobj(ln, "free cells"));
+       DBG_OBJ(LINE, ln, ul_debug("free cells"));
 
        for (i = 0; i < ln->ncells; i++)
                scols_reset_cell(&ln->cells[i]);
@@ -134,7 +134,7 @@ int scols_line_alloc_cells(struct libscols_line *ln, size_t n)
                return 0;
        }
 
-       DBG(LINE, ul_debugobj(ln, "alloc %zu cells", n));
+       DBG_OBJ(LINE, ln, ul_debug("alloc %zu cells", n));
 
        ce = reallocarray(ln->cells, n, sizeof(struct libscols_cell));
        if (!ce)
@@ -158,7 +158,7 @@ int scols_line_move_cells(struct libscols_line *ln, size_t newn, size_t oldn)
        if (oldn == newn)
                return 0;
 
-       DBG(LINE, ul_debugobj(ln, "move cells[%zu] -> cells[%zu]", oldn, newn));
+       DBG_OBJ(LINE, ln, ul_debug("move cells[%zu] -> cells[%zu]", oldn, newn));
 
        /* remember data from old position */
        memcpy(&ce, &ln->cells[oldn], sizeof(struct libscols_cell));
@@ -220,7 +220,7 @@ int scols_line_remove_child(struct libscols_line *ln, struct libscols_line *chil
        if (!ln || !child)
                return -EINVAL;
 
-       DBG(LINE, ul_debugobj(ln, "remove child"));
+       DBG_OBJ(LINE, ln, ul_debug("remove child"));
 
        list_del_init(&child->ln_children);
        child->parent = NULL;
@@ -244,7 +244,7 @@ int scols_line_add_child(struct libscols_line *ln, struct libscols_line *child)
        if (!ln || !child)
                return -EINVAL;
 
-       DBG(LINE, ul_debugobj(ln, "add child"));
+       DBG_OBJ(LINE, ln, ul_debug("add child"));
        scols_ref_line(child);
        scols_ref_line(ln);
 
@@ -667,7 +667,7 @@ struct libscols_line *scols_copy_line(const struct libscols_line *ln)
        ret->ncells   = ln->ncells;
        ret->seqnum   = ln->seqnum;
 
-       DBG(LINE, ul_debugobj(ln, "copy"));
+       DBG_OBJ(LINE, ln, ul_debug("copy"));
 
        for (i = 0; i < ret->ncells; ++i) {
                if (scols_cell_copy_content(&ret->cells[i], &ln->cells[i]))
index 4aa5b91aa959966b782d236e3704c09158677ff1..9f7b37474e50d147352e9dd59f2dd0432e401e1f 100644 (file)
@@ -22,7 +22,7 @@ int scols_table_print_range(  struct libscols_table *tb,
        if (scols_table_is_tree(tb))
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "printing range from API"));
+       DBG_OBJ(TAB, tb, ul_debug("printing range from API"));
 
        rc = __scols_initialize_printing(tb, &buf);
        if (rc)
@@ -72,7 +72,7 @@ int scols_table_print_range_to_string(        struct libscols_table *tb,
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "printing range to string"));
+       DBG_OBJ(TAB, tb, ul_debug("printing range to string"));
 
        /* create a stream for output */
        stream = open_memstream(data, &sz);
@@ -132,7 +132,7 @@ int scols_table_calculate(struct libscols_table *tb)
        if (list_empty(&tb->tb_lines))
                return 0;
 
-       DBG(TAB, ul_debugobj(tb, "pre-calculate"));
+       DBG_OBJ(TAB, tb, ul_debug("pre-calculate"));
 
        rc = __scols_initialize_printing(tb, &buf);
        __scols_cleanup_printing(tb, &buf);
@@ -151,16 +151,16 @@ static int do_print_table(struct libscols_table *tb, int *is_empty)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "printing"));
+       DBG_OBJ(TAB, tb, ul_debug("printing"));
        if (is_empty)
                *is_empty = 0;
 
        if (list_empty(&tb->tb_columns)) {
-               DBG(TAB, ul_debugobj(tb, "error -- no columns"));
+               DBG_OBJ(TAB, tb, ul_debug("error -- no columns"));
                return -EINVAL;
        }
        if (list_empty(&tb->tb_lines)) {
-               DBG(TAB, ul_debugobj(tb, "ignore -- no lines"));
+               DBG_OBJ(TAB, tb, ul_debug("ignore -- no lines"));
                if (scols_table_is_json(tb)) {
                        ul_jsonwrt_init(&tb->json, tb->out, 0, tb->json_format);
                        if (tb->json_format != UL_JSON_LINE) {
@@ -247,7 +247,7 @@ int scols_print_table_to_string(struct libscols_table *tb, char **data)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "printing to string"));
+       DBG_OBJ(TAB, tb, ul_debug("printing to string"));
 
        /* create a stream for output */
        stream = open_memstream(data, &sz);
index bdc38120ebad72ec4474b943099ba75fb335aac5..e824cd528f226d43dc7eb9ea74975d780da472c6 100644 (file)
@@ -142,7 +142,7 @@ static int groups_ascii_art_to_buffer(      struct libscols_table *tb,
        if (!has_groups(tb))
                return 0;
 
-       DBG(LINE, ul_debugobj(ln, "printing groups chart"));
+       DBG_OBJ(LINE, ln, ul_debug("printing groups chart"));
 
        if (tb->is_dummy_print)
                return 0;               /* allocate grpset[] only */
@@ -361,7 +361,7 @@ static void print_empty_cell(struct libscols_table *tb,
 {
        size_t len_pad = 0;             /* in screen cells as opposed to bytes */
 
-       DBG(COL, ul_debugobj(cl, " printing empty cell"));
+       DBG_OBJ(COL, cl, ul_debug(" printing empty cell"));
 
        fputs_color_cell_open(tb, cl, ln, ce);
 
@@ -439,7 +439,7 @@ static void print_newline_padding(struct libscols_table *tb,
        assert(tb);
        assert(cl);
 
-       DBG(LINE, ul_debugobj(ln, "printing newline padding"));
+       DBG_OBJ(LINE, ln, ul_debug("printing newline padding"));
 
        fputs(linesep(tb), tb->out);            /* line break */
        tb->termlines_used++;
@@ -468,7 +468,7 @@ static int print_pending_data(struct libscols_table *tb, struct ul_buffer *buf)
        if (!width)
                return -EINVAL;
 
-       DBG(COL, ul_debugobj(cl, "printing pending data"));
+       DBG_OBJ(COL, cl, ul_debug("printing pending data"));
 
        if (scols_column_get_uri(cl) || scols_cell_get_uri(ce))
                uri = mk_cell_uri(cl, ce, buf);
@@ -733,7 +733,7 @@ static int print_data(struct libscols_table *tb, struct ul_buffer *buf)
        fputs_color_cell_close(tb, cl, ln, ce);
 
        if (len > width && !scols_column_is_trunc(cl)) {
-               DBG(COL, ul_debugobj(cl, "*** data len=%zu > column width=%zu", len, width));
+               DBG_OBJ(COL, cl, ul_debug("*** data len=%zu > column width=%zu", len, width));
                print_newline_padding(tb, cl, ln, ce, ul_buffer_get_bufsiz(buf));       /* next column starts on next line */
 
        } else if (!is_last)
@@ -862,7 +862,7 @@ done:
        if (cal && scols_column_is_wrap(cl))
                scols_column_reset_wrap(cl);
 
-       DBG(COL, ul_debugobj(cl, "__cursor_to_buffer rc=%d len=%zu", rc,
+       DBG_OBJ(COL, cl, ul_debug("__cursor_to_buffer rc=%d len=%zu", rc,
                                ul_buffer_get_datasiz(buf)));
        return rc;
 }
@@ -881,7 +881,7 @@ static int print_line(struct libscols_table *tb,
 
        assert(ln);
 
-       DBG(LINE, ul_debugobj(ln, "     printing line"));
+       DBG_OBJ(LINE, ln, ul_debug("     printing line"));
 
        fputs_color_line_open(tb, ln);
 
@@ -908,7 +908,7 @@ static int print_line(struct libscols_table *tb,
 
        /* extra lines of the multi-line cells */
        while (rc == 0 && pending) {
-               DBG(LINE, ul_debugobj(ln, "printing pending data"));
+               DBG_OBJ(LINE, ln, ul_debug("printing pending data"));
                pending = 0;
                fputs(linesep(tb), tb->out);
                fputs_color_line_open(tb, ln);
@@ -953,7 +953,7 @@ int __scols_print_title(struct libscols_table *tb)
        if (!tb->title.data)
                return 0;
 
-       DBG(TAB, ul_debugobj(tb, "printing title"));
+       DBG_OBJ(TAB, tb, ul_debug("printing title"));
 
        /* encode data */
        if (tb->no_encode) {
@@ -966,7 +966,7 @@ int __scols_print_title(struct libscols_table *tb)
        } else {
                bufsz = mbs_safe_encode_size(strlen(tb->title.data)) + 1;
                if (bufsz == 1) {
-                       DBG(TAB, ul_debugobj(tb, "title is empty string -- ignore"));
+                       DBG_OBJ(TAB, tb, ul_debug("title is empty string -- ignore"));
                        return 0;
                }
                buf = malloc(bufsz);
@@ -1038,7 +1038,7 @@ int __scols_print_title(struct libscols_table *tb)
 done:
        free(buf);
        free(title);
-       DBG(TAB, ul_debugobj(tb, "printing title done [rc=%d]", rc));
+       DBG_OBJ(TAB, tb, ul_debug("printing title done [rc=%d]", rc));
        return rc;
 }
 
@@ -1057,7 +1057,7 @@ int __scols_print_header(struct libscols_table *tb, struct ul_buffer *buf)
            list_empty(&tb->tb_lines))
                return 0;
 
-       DBG(TAB, ul_debugobj(tb, "printing header"));
+       DBG_OBJ(TAB, tb, ul_debug("printing header"));
 
        /* set the width according to the size of the data */
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -1097,7 +1097,7 @@ int __scols_print_header(struct libscols_table *tb, struct ul_buffer *buf)
        tb->header_printed = 1;
        tb->header_next = tb->termlines_used + tb->termheight;
        if (tb->header_repeat)
-               DBG(TAB, ul_debugobj(tb, "\tnext header: %zu [current=%zu, rc=%d]",
+               DBG_OBJ(TAB, tb, ul_debug("\tnext header: %zu [current=%zu, rc=%d]",
                                        tb->header_next, tb->termlines_used, rc));
        return rc;
 }
@@ -1112,7 +1112,7 @@ int __scols_print_range(struct libscols_table *tb,
        struct libscols_line *ln;
 
        assert(tb);
-       DBG(TAB, ul_debugobj(tb, "printing range"));
+       DBG_OBJ(TAB, tb, ul_debug("printing range"));
 
        while (rc == 0 && scols_table_next_line(tb, itr, &ln) == 0) {
 
@@ -1158,7 +1158,7 @@ static int print_tree_line(struct libscols_table *tb,
        struct ul_buffer *buf = (struct ul_buffer *) data;
        int rc;
 
-       DBG(LINE, ul_debugobj(ln, "   printing tree line"));
+       DBG_OBJ(LINE, ln, ul_debug("   printing tree line"));
 
        if (scols_table_is_json(tb))
                ul_jsonwrt_object_open(&tb->json, NULL);
@@ -1207,7 +1207,7 @@ static int print_tree_line(struct libscols_table *tb,
 int __scols_print_tree(struct libscols_table *tb, struct ul_buffer *buf)
 {
        assert(tb);
-       DBG(TAB, ul_debugobj(tb, "----printing-tree-----"));
+       DBG_OBJ(TAB, tb, ul_debug("----printing-tree-----"));
 
        return scols_walk_tree(tb, NULL, print_tree_line, (void *) buf);
 }
@@ -1248,7 +1248,7 @@ int __scols_initialize_printing(struct libscols_table *tb, struct ul_buffer *buf
        struct libscols_iter itr;
        int rc;
 
-       DBG(TAB, ul_debugobj(tb, "initialize printing"));
+       DBG_OBJ(TAB, tb, ul_debug("initialize printing"));
 
        if (!tb->symbols) {
                rc = scols_table_set_default_symbols(tb);
index 2c70c336612464524621dbfe3a99de1dd1061a78..2f4a50ddfac9252df4ad4e62fa3248cde5651330 100644 (file)
 #define SCOLS_DEBUG_ALL                0xFFFF
 
 UL_DEBUG_DECLARE_MASK(libsmartcols);
-#define DBG(m, x)      __UL_DBG(libsmartcols, SCOLS_DEBUG_, m, x)
-#define ON_DBG(m, x)   __UL_DBG_CALL(libsmartcols, SCOLS_DEBUG_, m, x)
-#define DBG_FLUSH      __UL_DBG_FLUSH(libsmartcols, SCOLS_DEBUG_)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(libsmartcols)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(libsmartcols, SCOLS_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(libsmartcols, SCOLS_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(libsmartcols, SCOLS_DEBUG_, m, x)
+#define DBG_FLUSH              __UL_DBG_FLUSH(libsmartcols, SCOLS_DEBUG_)
 
 #define SCOLS_BUFPTR_TREEEND   0
 
index 2b22cec24efceb39b590f9f7486c333742178935..d98e00cd0fde450933ec80d1c8636bd18425f128 100644 (file)
@@ -56,7 +56,7 @@ static void check_padding_debug(struct libscols_table *tb)
        if (!str || (strcmp(str, "on") != 0 && strcmp(str, "1") != 0))
                return;
 
-       DBG(INIT, ul_debugobj(tb, "padding debug: ENABLE"));
+       DBG_OBJ(INIT, tb, ul_debug("padding debug: ENABLE"));
        tb->padding_debug = 1;
 }
 
@@ -101,7 +101,7 @@ struct libscols_table *scols_new_table(void)
        INIT_LIST_HEAD(&tb->tb_columns);
        INIT_LIST_HEAD(&tb->tb_groups);
 
-       DBG(TAB, ul_debugobj(tb, "alloc"));
+       DBG_OBJ(TAB, tb, ul_debug("alloc"));
        ON_DBG(INIT, check_padding_debug(tb));
        tb->json_format = get_json_format();
 
@@ -141,7 +141,7 @@ static void scols_table_remove_groups(struct libscols_table *tb)
 void scols_unref_table(struct libscols_table *tb)
 {
        if (tb && (--tb->refcount <= 0)) {
-               DBG(TAB, ul_debugobj(tb, "dealloc <-"));
+               DBG_OBJ(TAB, tb, ul_debug("dealloc <-"));
                scols_table_remove_groups(tb);
                scols_table_remove_lines(tb);
                scols_table_remove_columns(tb);
@@ -248,7 +248,7 @@ int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl
        if (cl->flags & SCOLS_FL_TREE)
                tb->ntreecols++;
 
-       DBG(TAB, ul_debugobj(tb, "add column"));
+       DBG_OBJ(TAB, tb, ul_debug("add column"));
        list_add_tail(&cl->cl_columns, &tb->tb_columns);
        cl->seqnum = tb->ncols++;
        cl->table = tb;
@@ -290,7 +290,7 @@ int scols_table_remove_column(struct libscols_table *tb,
        if (tb->dflt_sort_column == cl)
                tb->dflt_sort_column = NULL;
 
-       DBG(TAB, ul_debugobj(tb, "remove column"));
+       DBG_OBJ(TAB, tb, ul_debug("remove column"));
        list_del_init(&cl->cl_columns);
        tb->ncols--;
        cl->table = NULL;
@@ -311,7 +311,7 @@ int scols_table_remove_columns(struct libscols_table *tb)
        if (!tb || !list_empty(&tb->tb_lines))
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "remove all columns"));
+       DBG_OBJ(TAB, tb, ul_debug("remove all columns"));
        while (!list_empty(&tb->tb_columns)) {
                struct libscols_column *cl = list_entry(tb->tb_columns.next,
                                        struct libscols_column, cl_columns);
@@ -351,7 +351,7 @@ int scols_table_move_column(struct libscols_table *tb,
        if (pre == NULL && cl->seqnum == 0)
                return 0;
 
-       DBG(TAB, ul_debugobj(tb, "move column %zu behind %zu",
+       DBG_OBJ(TAB, tb, ul_debug("move column %zu behind %zu",
                                cl->seqnum, pre? pre->seqnum : 0));
 
        list_del_init(&cl->cl_columns);         /* remove from old position */
@@ -448,7 +448,7 @@ struct libscols_column *scols_table_new_column(struct libscols_table *tb,
        if (!tb)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "new column name=%s, whint=%g, flags=0x%04x",
+       DBG_OBJ(TAB, tb, ul_debug("new column name=%s, whint=%g, flags=0x%04x",
                                name, whint, flags));
        cl = scols_new_column();
        if (!cl)
@@ -609,7 +609,7 @@ int scols_table_set_stream(struct libscols_table *tb, FILE *stream)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "setting alternative stream"));
+       DBG_OBJ(TAB, tb, ul_debug("setting alternative stream"));
        tb->out = stream;
        return 0;
 }
@@ -649,7 +649,7 @@ int scols_table_reduce_termwidth(struct libscols_table *tb, size_t reduce)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "reduce terminal width: %zu", reduce));
+       DBG_OBJ(TAB, tb, ul_debug("reduce terminal width: %zu", reduce));
        tb->termreduce = reduce;
        return 0;
 }
@@ -742,7 +742,7 @@ int scols_table_add_line(struct libscols_table *tb, struct libscols_line *ln)
                        return rc;
        }
 
-       DBG(TAB, ul_debugobj(tb, "add line"));
+       DBG_OBJ(TAB, tb, ul_debug("add line"));
        list_add_tail(&ln->ln_lines, &tb->tb_lines);
        ln->seqnum = tb->nlines++;
        scols_ref_line(ln);
@@ -765,7 +765,7 @@ int scols_table_remove_line(struct libscols_table *tb,
        if (!tb || !ln)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "remove line"));
+       DBG_OBJ(TAB, tb, ul_debug("remove line"));
        list_del_init(&ln->ln_lines);
        tb->nlines--;
        scols_unref_line(ln);
@@ -783,7 +783,7 @@ void scols_table_remove_lines(struct libscols_table *tb)
        if (!tb)
                return;
 
-       DBG(TAB, ul_debugobj(tb, "remove all lines"));
+       DBG_OBJ(TAB, tb, ul_debug("remove all lines"));
        while (!list_empty(&tb->tb_lines)) {
                struct libscols_line *ln = list_entry(tb->tb_lines.next,
                                                struct libscols_line, ln_lines);
@@ -912,7 +912,7 @@ struct libscols_table *scols_copy_table(struct libscols_table *tb)
        if (!ret)
                return NULL;
 
-       DBG(TAB, ul_debugobj(tb, "copy"));
+       DBG_OBJ(TAB, tb, ul_debug("copy"));
 
        if (tb->symbols)
                scols_table_set_symbols(ret, tb->symbols);
@@ -977,7 +977,7 @@ int scols_table_set_default_symbols(struct libscols_table *tb)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "setting default symbols"));
+       DBG_OBJ(TAB, tb, ul_debug("setting default symbols"));
 
        sy = scols_new_symbols();
        if (!sy)
@@ -1046,14 +1046,14 @@ int scols_table_set_symbols(struct libscols_table *tb,
 
        /* remove old */
        if (tb->symbols) {
-               DBG(TAB, ul_debugobj(tb, "remove symbols reference"));
+               DBG_OBJ(TAB, tb, ul_debug("remove symbols reference"));
                scols_unref_symbols(tb->symbols);
                tb->symbols = NULL;
        }
 
        /* set new */
        if (sy) {                                       /* ref user defined */
-               DBG(TAB, ul_debugobj(tb, "set symbols"));
+               DBG_OBJ(TAB, tb, ul_debug("set symbols"));
                tb->symbols = sy;
                scols_ref_symbols(sy);
        }
@@ -1093,7 +1093,7 @@ int scols_table_enable_nolinesep(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "nolinesep: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("nolinesep: %s", enable ? "ENABLE" : "DISABLE"));
        tb->no_linesep = enable ? 1 : 0;
        return 0;
 }
@@ -1125,7 +1125,7 @@ int scols_table_enable_colors(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "colors: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("colors: %s", enable ? "ENABLE" : "DISABLE"));
        tb->colors_wanted = enable;
        return 0;
 }
@@ -1145,7 +1145,7 @@ int scols_table_enable_raw(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "raw: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("raw: %s", enable ? "ENABLE" : "DISABLE"));
        if (enable)
                tb->format = SCOLS_FMT_RAW;
        else if (tb->format == SCOLS_FMT_RAW)
@@ -1170,7 +1170,7 @@ int scols_table_enable_json(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "json: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("json: %s", enable ? "ENABLE" : "DISABLE"));
        if (enable)
                tb->format = SCOLS_FMT_JSON;
        else if (tb->format == SCOLS_FMT_JSON)
@@ -1199,7 +1199,7 @@ int scols_table_enable_export(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "export: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("export: %s", enable ? "ENABLE" : "DISABLE"));
        if (enable)
                tb->format = SCOLS_FMT_EXPORT;
        else if (tb->format == SCOLS_FMT_EXPORT)
@@ -1224,7 +1224,7 @@ int scols_table_enable_shellvar(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "shellvar: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("shellvar: %s", enable ? "ENABLE" : "DISABLE"));
        tb->is_shellvar = enable ? 1 : 0;
        return 0;
 }
@@ -1250,7 +1250,7 @@ int scols_table_enable_ascii(struct libscols_table *tb, int enable)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "ascii: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("ascii: %s", enable ? "ENABLE" : "DISABLE"));
        tb->ascii = enable ? 1 : 0;
        return 0;
 }
@@ -1268,7 +1268,7 @@ int scols_table_enable_noheadings(struct libscols_table *tb, int enable)
 {
        if (!tb)
                return -EINVAL;
-       DBG(TAB, ul_debugobj(tb, "noheading: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("noheading: %s", enable ? "ENABLE" : "DISABLE"));
        tb->no_headings = enable ? 1 : 0;
        return 0;
 }
@@ -1290,7 +1290,7 @@ int scols_table_enable_header_repeat(struct libscols_table *tb, int enable)
 {
        if (!tb)
                return -EINVAL;
-       DBG(TAB, ul_debugobj(tb, "header-repeat: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("header-repeat: %s", enable ? "ENABLE" : "DISABLE"));
        tb->header_repeat = enable ? 1 : 0;
        return 0;
 }
@@ -1312,7 +1312,7 @@ int scols_table_enable_maxout(struct libscols_table *tb, int enable)
        if (!tb || tb->minout)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "maxout: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("maxout: %s", enable ? "ENABLE" : "DISABLE"));
        tb->maxout = enable ? 1 : 0;
        return 0;
 }
@@ -1337,7 +1337,7 @@ int scols_table_enable_minout(struct libscols_table *tb, int enable)
        if (!tb || tb->maxout)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "minout: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("minout: %s", enable ? "ENABLE" : "DISABLE"));
        tb->minout = enable ? 1 : 0;
        return 0;
 }
@@ -1357,7 +1357,7 @@ int scols_table_enable_nowrap(struct libscols_table *tb, int enable)
 {
        if (!tb)
                return -EINVAL;
-       DBG(TAB, ul_debugobj(tb, "nowrap: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("nowrap: %s", enable ? "ENABLE" : "DISABLE"));
        tb->no_wrap = enable ? 1 : 0;
        return 0;
 }
@@ -1390,7 +1390,7 @@ int scols_table_enable_noencoding(struct libscols_table *tb, int enable)
 {
        if (!tb)
                return -EINVAL;
-       DBG(TAB, ul_debugobj(tb, "encoding: %s", enable ? "ENABLE" : "DISABLE"));
+       DBG_OBJ(TAB, tb, ul_debug("encoding: %s", enable ? "ENABLE" : "DISABLE"));
        tb->no_encode = enable ? 1 : 0;
        return 0;
 }
@@ -1701,7 +1701,7 @@ int scols_sort_table(struct libscols_table *tb, struct libscols_column *cl)
        if (!cl || !cl->cmpfunc)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "sorting table by %zu column", cl->seqnum));
+       DBG_OBJ(TAB, tb, ul_debug("sorting table by %zu column", cl->seqnum));
        list_sort(&tb->tb_lines, cells_cmp_wrapper_lines, cl);
 
        if (scols_table_is_tree(tb))
@@ -1759,7 +1759,7 @@ int scols_sort_table_by_tree(struct libscols_table *tb)
        if (!tb)
                return -EINVAL;
 
-       DBG(TAB, ul_debugobj(tb, "sorting table by tree"));
+       DBG_OBJ(TAB, tb, ul_debug("sorting table by tree"));
 
        if (tb->dflt_sort_column)
                __scols_sort_tree(tb, tb->dflt_sort_column);
@@ -1819,7 +1819,7 @@ int scols_table_get_termforce(const struct libscols_table *tb)
  */
 int scols_table_set_termwidth(struct libscols_table *tb, size_t width)
 {
-       DBG(TAB, ul_debugobj(tb, "set terminatl width: %zu", width));
+       DBG_OBJ(TAB, tb, ul_debug("set terminatl width: %zu", width));
        tb->termwidth = width;
        return 0;
 }
@@ -1849,7 +1849,7 @@ size_t scols_table_get_termwidth(const struct libscols_table *tb)
  */
 int scols_table_set_termheight(struct libscols_table *tb, size_t height)
 {
-       DBG(TAB, ul_debugobj(tb, "set terminatl height: %zu", height));
+       DBG_OBJ(TAB, tb, ul_debug("set terminatl height: %zu", height));
        tb->termheight = height;
        return 0;
 }
index 0b51fed5fc2ffa9506266aa7d2c5ee0c7c1a6b91..5dbb9e5058cb48cd60f10f18c7a96012b36ff649 100644 (file)
@@ -11,7 +11,7 @@ static int walk_line(struct libscols_table *tb,
 {
        int rc = 0;
 
-/*     DBG(LINE, ul_debugobj(ln, " wall line")); */
+/*     DBG_OBJ(LINE, ln, ul_debug(" wall line")); */
 
        /* we list group children in __scols_print_tree() after tree root node */
        if (is_group_member(ln) && is_last_group_member(ln) && has_group_children(ln))
@@ -26,7 +26,7 @@ static int walk_line(struct libscols_table *tb,
        if (rc == 0 && has_children(ln)) {
                struct list_head *p;
 
-/*             DBG(LINE, ul_debugobj(ln, " children walk"));*/
+/*             DBG_OBJ(LINE, ln, ul_debug(" children walk"));*/
 
                list_for_each(p, &ln->ln_branch) {
                        struct libscols_line *chld = list_entry(p,
@@ -38,7 +38,7 @@ static int walk_line(struct libscols_table *tb,
                }
        }
 
-/*     DBG(LINE, ul_debugobj(ln, "<- walk line done [rc=%d]", rc)); */
+/*     DBG_OBJ(LINE, ln, ul_debug("<- walk line done [rc=%d]", rc)); */
        return rc;
 }
 
@@ -73,7 +73,7 @@ int scols_walk_is_last(struct libscols_table *tb, struct libscols_line *ln)
        if (is_group_child(ln) && !is_last_group_child(ln))
                return 0;
 
-       DBG(LINE, ul_debugobj(ln, "last in table"));
+       DBG_OBJ(LINE, ln, ul_debug("last in table"));
        return 1;
 }
 
@@ -90,7 +90,7 @@ int scols_walk_tree(struct libscols_table *tb,
        struct libscols_iter itr;
 
        assert(tb);
-/*     DBG(TAB, ul_debugobj(tb, ">> walk start"));*/
+/*     DBG_OBJ(TAB, tb, ul_debug(">> walk start"));*/
 
        /* init */
        tb->ngrpchlds_pending = 0;
@@ -125,9 +125,9 @@ int scols_walk_tree(struct libscols_table *tb,
                        struct libscols_group *gr = scols_grpset_get_printable_children(tb);
                        struct list_head *p;
 
-                       DBG(LINE, ul_debugobj(ln, " walk group children [pending=%zu]", tb->ngrpchlds_pending));
+                       DBG_OBJ(LINE, ln, ul_debug(" walk group children [pending=%zu]", tb->ngrpchlds_pending));
                        if (!gr) {
-                               DBG(LINE, ul_debugobj(ln, " *** ngrpchlds_pending counter invalid"));
+                               DBG_OBJ(LINE, ln, ul_debug(" *** ngrpchlds_pending counter invalid"));
                                tb->ngrpchlds_pending = 0;
                                break;
                        }
@@ -147,6 +147,6 @@ int scols_walk_tree(struct libscols_table *tb,
 
        tb->ngrpchlds_pending = 0;
        tb->walk_last_done = 0;
-/*     DBG(TAB, ul_debugobj(tb, "<< walk end [rc=%d]", rc));*/
+/*     DBG_OBJ(TAB, tb, ul_debug("<< walk end [rc=%d]", rc));*/
        return rc;
 }
index 5e9d38da1dca174b44f1385ad6380c44cb469f56..c4ad802112a63994370b54b61017cf77c62ca374 100644 (file)
@@ -47,7 +47,7 @@ struct lsblk_device *lsblk_new_device(void)
        INIT_LIST_HEAD(&dev->ls_roots);
        INIT_LIST_HEAD(&dev->ls_devices);
 
-       DBG(DEV, ul_debugobj(dev, "alloc"));
+       DBG_OBJ(DEV, dev, ul_debug("alloc"));
        return dev;
 }
 
@@ -63,7 +63,7 @@ static int remove_dependence(struct lsblk_devdep *dep)
        if (!dep)
                return -EINVAL;
 
-       DBG(DEP, ul_debugobj(dep, "   dealloc"));
+       DBG_OBJ(DEP, dep, ul_debug("   dealloc"));
 
        list_del_init(&dep->ls_childs);
        list_del_init(&dep->ls_parents);
@@ -78,7 +78,7 @@ static int device_remove_dependences(struct lsblk_device *dev)
                return -EINVAL;
 
        if (!list_empty(&dev->childs))
-               DBG(DEV, ul_debugobj(dev, "  %s: remove all children deps", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("  %s: remove all children deps", dev->name));
        while (!list_empty(&dev->childs)) {
                struct lsblk_devdep *dp = list_entry(dev->childs.next,
                                        struct lsblk_devdep, ls_childs);
@@ -86,7 +86,7 @@ static int device_remove_dependences(struct lsblk_device *dev)
        }
 
        if (!list_empty(&dev->parents))
-               DBG(DEV, ul_debugobj(dev, "  %s: remove all parents deps", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("  %s: remove all parents deps", dev->name));
        while (!list_empty(&dev->parents)) {
                struct lsblk_devdep *dp = list_entry(dev->parents.next,
                                        struct lsblk_devdep, ls_parents);
@@ -102,7 +102,7 @@ void lsblk_unref_device(struct lsblk_device *dev)
                return;
 
        if (--dev->refcount <= 0) {
-               DBG(DEV, ul_debugobj(dev, " freeing [%s] <<", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug(" freeing [%s] <<", dev->name));
 
                device_remove_dependences(dev);
                lsblk_device_free_properties(dev->properties);
@@ -116,7 +116,7 @@ void lsblk_unref_device(struct lsblk_device *dev)
 
                ul_unref_path(dev->sysfs);
 
-               DBG(DEV, ul_debugobj(dev, " >> dealloc [%s]", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug(" >> dealloc [%s]", dev->name));
                free(dev->name);
                free(dev);
        }
@@ -160,7 +160,7 @@ int lsblk_device_new_dependence(struct lsblk_device *parent, struct lsblk_device
        dp->parent = parent;
        list_add_tail(&dp->ls_parents, &child->parents);
 
-       DBG(DEV, ul_debugobj(parent, "add dependence 0x%p [%s->%s]", dp, parent->name, child->name));
+       DBG_OBJ(DEV, parent, ul_debug("add dependence 0x%p [%s->%s]", dp, parent->name, child->name));
 
        return 0;
 }
@@ -247,7 +247,7 @@ struct lsblk_devtree *lsblk_new_devtree(void)
        INIT_LIST_HEAD(&tr->devices);
        INIT_LIST_HEAD(&tr->pktcdvd_map);
 
-       DBG(TREE, ul_debugobj(tr, "alloc"));
+       DBG_OBJ(TREE, tr, ul_debug("alloc"));
        return tr;
 }
 
@@ -263,7 +263,7 @@ void lsblk_unref_devtree(struct lsblk_devtree *tr)
                return;
 
        if (--tr->refcount <= 0) {
-               DBG(TREE, ul_debugobj(tr, "dealloc"));
+               DBG_OBJ(TREE, tr, ul_debug("dealloc"));
 
                while (!list_empty(&tr->devices)) {
                        struct lsblk_device *dev = list_entry(tr->devices.next,
@@ -307,7 +307,7 @@ int lsblk_devtree_add_root(struct lsblk_devtree *tr, struct lsblk_device *dev)
        /* We don't increment reference counter for tr->roots list. The primary
         * reference is tr->devices */
 
-       DBG(TREE, ul_debugobj(tr, "add root device 0x%p [%s]", dev, dev->name));
+       DBG_OBJ(TREE, tr, ul_debug("add root device 0x%p [%s]", dev, dev->name));
        list_add_tail(&dev->ls_roots, &tr->roots);
        return 0;
 }
@@ -315,7 +315,7 @@ int lsblk_devtree_add_root(struct lsblk_devtree *tr, struct lsblk_device *dev)
 int lsblk_devtree_remove_root(struct lsblk_devtree *tr __attribute__((unused)),
                              struct lsblk_device *dev)
 {
-       DBG(TREE, ul_debugobj(tr, "remove root device 0x%p [%s]", dev, dev->name));
+       DBG_OBJ(TREE, tr, ul_debug("remove root device 0x%p [%s]", dev, dev->name));
        list_del_init(&dev->ls_roots);
 
        return 0;
@@ -343,7 +343,7 @@ int lsblk_devtree_add_device(struct lsblk_devtree *tr, struct lsblk_device *dev)
 {
        lsblk_ref_device(dev);
 
-       DBG(TREE, ul_debugobj(tr, "add device 0x%p [%s]", dev, dev->name));
+       DBG_OBJ(TREE, tr, ul_debug("add device 0x%p [%s]", dev, dev->name));
        list_add_tail(&dev->ls_devices, &tr->devices);
        return 0;
 }
@@ -398,7 +398,7 @@ struct lsblk_device *lsblk_devtree_get_device(struct lsblk_devtree *tr, const ch
 
 int lsblk_devtree_remove_device(struct lsblk_devtree *tr, struct lsblk_device *dev)
 {
-       DBG(TREE, ul_debugobj(tr, "remove device 0x%p [%s]", dev, dev->name));
+       DBG_OBJ(TREE, tr, ul_debug("remove device 0x%p [%s]", dev, dev->name));
 
        if (!lsblk_devtree_has_device(tr, dev))
                return 1;
@@ -478,7 +478,7 @@ static int device_dedupkey_is_equal(
                if (!device_is_partition(dev) ||
                    !dev->wholedisk->dedupkey ||
                     strcmp(dev->dedupkey, dev->wholedisk->dedupkey) != 0) {
-                       DBG(DEV, ul_debugobj(dev, "%s: match deduplication pattern", dev->name));
+                       DBG_OBJ(DEV, dev, ul_debug("%s: match deduplication pattern", dev->name));
                        return 1;
                }
        }
@@ -498,7 +498,7 @@ static void device_dedup_dependencies(
                struct lsblk_device *child = dp->child;
 
                if (device_dedupkey_is_equal(child, pattern)) {
-                       DBG(DEV, ul_debugobj(dev, "remove duplicate dependence: 0x%p [%s]",
+                       DBG_OBJ(DEV, dev, ul_debug("remove duplicate dependence: 0x%p [%s]",
                                                dp->child, dp->child->name));
                        remove_dependence(dp);
                } else
@@ -513,11 +513,11 @@ static void devtree_dedup(struct lsblk_devtree *tr, struct lsblk_device *pattern
 
        lsblk_reset_iter(&itr, LSBLK_ITER_FORWARD);
 
-       DBG(TREE, ul_debugobj(tr, "de-duplicate by key: %s", pattern->dedupkey));
+       DBG_OBJ(TREE, tr, ul_debug("de-duplicate by key: %s", pattern->dedupkey));
 
        while (lsblk_devtree_next_root(tr, &itr, &dev) == 0) {
                if (device_dedupkey_is_equal(dev, pattern)) {
-                       DBG(TREE, ul_debugobj(tr, "remove duplicate device: 0x%p [%s]",
+                       DBG_OBJ(TREE, tr, ul_debug("remove duplicate device: 0x%p [%s]",
                                                dev, dev->name));
                        /* Note that root list does not use ref-counting; the
                         * primary reference is ls_devices */
index 0a5d86c72206e72d5a6f15cc71a22272c5432768..b408fd2c378ded632ac70bd63b36334505ad91f5 100644 (file)
@@ -70,7 +70,7 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld)
        if (ld->udev_requested)
                return ld->properties;
 
-       DBG(DEV, ul_debugobj(ld, " properties by udev"));
+       DBG_OBJ(DEV, ld, ul_debug(" properties by udev"));
 
        if (!udev)
                udev = udev_new();      /* global handler */
@@ -81,7 +81,7 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld)
        if (!dev)
                goto done;
 
-       DBG(DEV, ul_debugobj(ld, "%s: found udev properties", ld->name));
+       DBG_OBJ(DEV, ld, ul_debug("%s: found udev properties", ld->name));
 
        if (ld->properties)
                lsblk_device_free_properties(ld->properties);
@@ -174,7 +174,7 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld)
 done:
        ld->udev_requested = 1;
 
-       DBG(DEV, ul_debugobj(ld, " from udev"));
+       DBG_OBJ(DEV, ld, ul_debug(" from udev"));
        return ld->properties;
 }
 #endif /* HAVE_LIBUDEV */
@@ -222,7 +222,7 @@ static struct lsblk_devprop *get_properties_by_file(struct lsblk_device *ld)
        if (ld->file_requested)
                return ld->properties;
 
-       DBG(DEV, ul_debugobj(ld, " properties by file"));
+       DBG_OBJ(DEV, ld, ul_debug(" properties by file"));
 
        if (ld->properties || ld->filename) {
                lsblk_device_free_properties(ld->properties);
@@ -285,7 +285,7 @@ done:
        ul_unref_path(pc);
        ld->file_requested = 1;
 
-       DBG(DEV, ul_debugobj(ld, " from fake-file"));
+       DBG_OBJ(DEV, ld, ul_debug(" from fake-file"));
        return ld->properties;
 }
 
@@ -302,7 +302,7 @@ static struct lsblk_devprop *get_properties_by_blkid(struct lsblk_device *dev)
        if (getuid() != 0)
                goto done;                              /* no permissions to read from the device */
 
-       DBG(DEV, ul_debugobj(dev, " properties by blkid"));
+       DBG_OBJ(DEV, dev, ul_debug(" properties by blkid"));
 
        pr = blkid_new_probe_from_filename(dev->filename);
        if (!pr)
@@ -349,13 +349,13 @@ static struct lsblk_devprop *get_properties_by_blkid(struct lsblk_device *dev)
                    !blkid_probe_lookup_value(pr, "PART_ENTRY_SCHEME", &data, NULL))
                        prop->pttype = xstrdup(data);
 
-               DBG(DEV, ul_debugobj(dev, "%s: found blkid properties", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: found blkid properties", dev->name));
        }
 
 done:
        blkid_free_probe(pr);
 
-       DBG(DEV, ul_debugobj(dev, " from blkid"));
+       DBG_OBJ(DEV, dev, ul_debug(" from blkid"));
        dev->blkid_requested = 1;
        return dev->properties;
 }
@@ -393,7 +393,7 @@ struct lsblk_devprop *lsblk_device_get_properties(struct lsblk_device *dev)
 {
        size_t i;
 
-       DBG(DEV, ul_debugobj(dev, "%s: properties requested", dev->filename));
+       DBG_OBJ(DEV, dev, ul_debug("%s: properties requested", dev->filename));
 
        for (i = 0; i < __LSBLK_NMETHODS; i++) {
                struct lsblk_devprop *p = NULL;
index d6954f1af8e34036b74b754e51f7d77d5649ef64..e041169b42cad545406f77df9712dca1b0c64afc 100644 (file)
@@ -807,16 +807,16 @@ static void process_mq(struct lsblk_device *dev, char **str)
 {
        unsigned int queues = 0;
 
-       DBG(DEV, ul_debugobj(dev, "%s: process mq", dev->name));
+       DBG_OBJ(DEV, dev, ul_debug("%s: process mq", dev->name));
 
        queues = ul_path_count_dirents(dev->sysfs, "mq");
        if (!queues) {
                *str = xstrdup("1");
-               DBG(DEV, ul_debugobj(dev, "%s: no mq supported, use a single queue", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: no mq supported, use a single queue", dev->name));
                return;
        }
 
-       DBG(DEV, ul_debugobj(dev, "%s: has %d queues", dev->name, queues));
+       DBG_OBJ(DEV, dev, ul_debug("%s: has %d queues", dev->name, queues));
        xasprintf(str, "%3u", queues);
 }
 
@@ -1275,7 +1275,7 @@ static void device_fill_scols_cell(struct lsblk_device *dev,
 
        if (!data)
                return;
-       DBG(DEV, ul_debugobj(dev, " refer data[%zu]=\"%s\"", colnum, data));
+       DBG_OBJ(DEV, dev, ul_debug(" refer data[%zu]=\"%s\"", colnum, data));
        ce = scols_line_get_cell(ln, colnum);
        if (!ce)
                return;
@@ -1317,8 +1317,13 @@ static void device_to_scols(
        int link_group = 0, nocount = 0;
 
 
-       DBG(DEV, ul_debugobj(dev, "add '%s' to scols", dev->name));
-       ON_DBG(DEV, if (ul_path_isopen_dirfd(dev->sysfs)) ul_debugobj(dev, "%s ---> is open!", dev->name));
+       DBG_OBJ(DEV, dev, ul_debug("add '%s' to scols", dev->name));
+       ON_DBG(DEV,
+               if (ul_path_isopen_dirfd(dev->sysfs)) {
+                       ul_debugobj(dev, UL_DEBUG_MASK(lsblk));
+                       ul_debug("%s ---> is open!", dev->name);
+               }
+       );
 
        if (!parent && dev->wholedisk)
                parent = dev->wholedisk;
@@ -1375,19 +1380,19 @@ static void device_to_scols(
                struct libscols_line *gr = parent_line;
 
                /* Merge all my parents to the one group */
-               DBG(DEV, ul_debugobj(dev, " grouping parents [--merge]"));
+               DBG_OBJ(DEV, dev, ul_debug(" grouping parents [--merge]"));
                lsblk_reset_iter(&itr, LSBLK_ITER_FORWARD);
                while (lsblk_device_next_parent(dev, &itr, &p) == 0) {
                        if (!p->scols_line) {
-                               DBG(DEV, ul_debugobj(dev, " *** ignore '%s' no scols line yet", p->name));
+                               DBG_OBJ(DEV, dev, ul_debug(" *** ignore '%s' no scols line yet", p->name));
                                continue;
                        }
-                       DBG(DEV, ul_debugobj(dev, " group '%s'", p->name));
+                       DBG_OBJ(DEV, dev, ul_debug(" group '%s'", p->name));
                        scols_table_group_lines(tab, p->scols_line, gr, 0);
                }
 
                /* Link the group -- this makes group->child connection */
-               DBG(DEV, ul_debugobj(dev, " linking the group [--merge]"));
+               DBG_OBJ(DEV, dev, ul_debug(" linking the group [--merge]"));
                scols_line_link_group(ln, gr, 0);
        }
 
@@ -1404,9 +1409,9 @@ static void device_to_scols(
 
        lsblk_reset_iter(&itr, LSBLK_ITER_FORWARD);
        while (lsblk_device_next_child(dev, &itr, &child) == 0) {
-               DBG(DEV, ul_debugobj(dev, "%s -> continue to child", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s -> continue to child", dev->name));
                device_to_scols(child, dev, tab, ln);
-               DBG(DEV, ul_debugobj(dev, "%s <- child done", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s <- child done", dev->name));
        }
 
        /* apply highlighter */
@@ -1468,11 +1473,11 @@ static int initialize_device(struct lsblk_device *dev,
 {
        dev_t devno;
 
-       DBG(DEV, ul_debugobj(dev, "initialize %s [wholedisk=%p %s]",
+       DBG_OBJ(DEV, dev, ul_debug("initialize %s [wholedisk=%p %s]",
                        name, wholedisk, wholedisk ? wholedisk->name : ""));
 
        if (sysfs_devname_is_hidden(lsblk->sysroot, name)) {
-               DBG(DEV, ul_debugobj(dev, "%s: hidden, ignore", name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: hidden, ignore", name));
                return -1;
        }
 
@@ -1485,20 +1490,20 @@ static int initialize_device(struct lsblk_device *dev,
 
        dev->filename = get_device_path(dev);
        if (!dev->filename) {
-               DBG(DEV, ul_debugobj(dev, "%s: failed to get device path", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: failed to get device path", dev->name));
                return -1;
        }
-       DBG(DEV, ul_debugobj(dev, "%s: filename=%s", dev->name, dev->filename));
+       DBG_OBJ(DEV, dev, ul_debug("%s: filename=%s", dev->name, dev->filename));
 
        devno = __sysfs_devname_to_devno(lsblk->sysroot, dev->name, wholedisk ? wholedisk->name : NULL);
        if (!devno) {
-               DBG(DEV, ul_debugobj(dev, "%s: unknown device name", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: unknown device name", dev->name));
                return -1;
        }
 
        dev->sysfs = ul_new_sysfs_path(devno, wholedisk ? wholedisk->sysfs : NULL, lsblk->sysroot);
        if (!dev->sysfs) {
-               DBG(DEV, ul_debugobj(dev, "%s: failed to initialize sysfs handler", dev->name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: failed to initialize sysfs handler", dev->name));
                return -1;
        }
 
@@ -1511,13 +1516,13 @@ static int initialize_device(struct lsblk_device *dev,
 
        /* Ignore devices of zero size */
        if (!lsblk->all_devices && ignore_empty(dev)) {
-               DBG(DEV, ul_debugobj(dev, "zero size device -- ignore"));
+               DBG_OBJ(DEV, dev, ul_debug("zero size device -- ignore"));
                return -1;
        }
        if (is_dm(dev->name)) {
                ul_path_read_string(dev->sysfs, &dev->dm_name, "dm/name");
                if (!dev->dm_name) {
-                       DBG(DEV, ul_debugobj(dev, "%s: failed to get dm name", dev->name));
+                       DBG_OBJ(DEV, dev, ul_debug("%s: failed to get dm name", dev->name));
                        return -1;
                }
        }
@@ -1526,12 +1531,12 @@ static int initialize_device(struct lsblk_device *dev,
        dev->nholders = ul_path_count_dirents(dev->sysfs, "holders");
        dev->nslaves = ul_path_count_dirents(dev->sysfs, "slaves");
 
-       DBG(DEV, ul_debugobj(dev, "%s: npartitions=%d, nholders=%d, nslaves=%d",
+       DBG_OBJ(DEV, dev, ul_debug("%s: npartitions=%d, nholders=%d, nslaves=%d",
                        dev->name, dev->npartitions, dev->nholders, dev->nslaves));
 
        /* ignore non-SCSI devices */
        if (lsblk->scsi && sysfs_blkdev_scsi_get_hctl(dev->sysfs, NULL, NULL, NULL, NULL)) {
-               DBG(DEV, ul_debugobj(dev, "non-scsi device -- ignore"));
+               DBG_OBJ(DEV, dev, ul_debug("non-scsi device -- ignore"));
                return -1;
        }
 
@@ -1540,7 +1545,7 @@ static int initialize_device(struct lsblk_device *dev,
                const char *transport = get_transport(dev);
 
                if (!transport || strcmp(transport, "nvme")) {
-                       DBG(DEV, ul_debugobj(dev, "non-nvme device -- ignore"));
+                       DBG_OBJ(DEV, dev, ul_debug("non-nvme device -- ignore"));
                        return -1;
                }
        }
@@ -1550,12 +1555,12 @@ static int initialize_device(struct lsblk_device *dev,
                const char *transport = get_transport(dev);
 
                if (!transport || strcmp(transport, "virtio")) {
-                       DBG(DEV, ul_debugobj(dev, "non-virtio device -- ignore"));
+                       DBG_OBJ(DEV, dev, ul_debug("non-virtio device -- ignore"));
                        return -1;
                }
        }
 
-       DBG(DEV, ul_debugobj(dev, "%s: context successfully initialized", dev->name));
+       DBG_OBJ(DEV, dev, ul_debug("%s: context successfully initialized", dev->name));
        return 0;
 }
 
@@ -1577,7 +1582,7 @@ static struct lsblk_device *devtree_get_device_or_new(struct lsblk_devtree *tr,
                lsblk_devtree_add_device(tr, dev);
                lsblk_unref_device(dev);                /* keep it referenced by devtree only */
        } else
-               DBG(DEV, ul_debugobj(dev, "%s: already processed", name));
+               DBG_OBJ(DEV, dev, ul_debug("%s: already processed", name));
 
        return dev;
 }
@@ -1624,7 +1629,7 @@ static int process_partitions(struct lsblk_devtree *tr, struct lsblk_device *dis
        if (!disk->npartitions || device_is_partition(disk))
                return -EINVAL;
 
-       DBG(DEV, ul_debugobj(disk, "%s: probe whole-disk for partitions", disk->name));
+       DBG_OBJ(DEV, disk, ul_debug("%s: probe whole-disk for partitions", disk->name));
 
        dir = ul_path_opendir(disk->sysfs, NULL);
        if (!dir)
@@ -1636,7 +1641,7 @@ static int process_partitions(struct lsblk_devtree *tr, struct lsblk_device *dis
                if (!(sysfs_blkdev_is_partition_dirent(dir, d, disk->name)))
                        continue;
 
-               DBG(DEV, ul_debugobj(disk, "  checking %s", d->d_name));
+               DBG_OBJ(DEV, disk, ul_debug("  checking %s", d->d_name));
 
                part = devtree_get_device_or_new(tr, disk, d->d_name);
                if (!part)
@@ -1652,7 +1657,7 @@ static int process_partitions(struct lsblk_devtree *tr, struct lsblk_device *dis
         * often, so close it now when all is done */
        ul_path_close_dirfd(disk->sysfs);
 
-       DBG(DEV, ul_debugobj(disk, "probe whole-disk for partitions -- done"));
+       DBG_OBJ(DEV, disk, ul_debug("probe whole-disk for partitions -- done"));
        closedir(dir);
        return 0;
 }
@@ -1703,22 +1708,22 @@ static int process_dependencies(
        if (do_partitions && dev->npartitions)
                process_partitions(tr, dev);
 
-       DBG(DEV, ul_debugobj(dev, "%s: reading dependencies", dev->name));
+       DBG_OBJ(DEV, dev, ul_debug("%s: reading dependencies", dev->name));
 
        if (!(lsblk->inverse ? dev->nslaves : dev->nholders)) {
-               DBG(DEV, ul_debugobj(dev, " ignore (no slaves/holders)"));
+               DBG_OBJ(DEV, dev, ul_debug(" ignore (no slaves/holders)"));
                goto done;
        }
 
        depname = lsblk->inverse ? "slaves" : "holders";
        dir = ul_path_opendir(dev->sysfs, depname);
        if (!dir) {
-               DBG(DEV, ul_debugobj(dev, " ignore (no slaves/holders directory)"));
+               DBG_OBJ(DEV, dev, ul_debug(" ignore (no slaves/holders directory)"));
                goto done;
        }
        ul_path_close_dirfd(dev->sysfs);
 
-       DBG(DEV, ul_debugobj(dev, " %s: checking for '%s' dependence", dev->name, depname));
+       DBG_OBJ(DEV, dev, ul_debug(" %s: checking for '%s' dependence", dev->name, depname));
 
        while ((d = xreaddir(dir))) {
                struct lsblk_device *disk = NULL;
@@ -1729,13 +1734,13 @@ static int process_dependencies(
                        char buf[PATH_MAX];
                        char *diskname;
 
-                       DBG(DEV, ul_debugobj(dev, " %s: dependence is partition", d->d_name));
+                       DBG_OBJ(DEV, dev, ul_debug(" %s: dependence is partition", d->d_name));
 
                        diskname = get_wholedisk_from_partition_dirent(dir, d, buf, sizeof(buf));
                        if (diskname)
                                disk = devtree_get_device_or_new(tr, NULL, diskname);
                        if (!disk) {
-                               DBG(DEV, ul_debugobj(dev, "  ignore no wholedisk ???"));
+                               DBG_OBJ(DEV, dev, ul_debug("  ignore no wholedisk ???"));
                                goto next;
                        }
 
@@ -1752,7 +1757,7 @@ static int process_dependencies(
                }
                /* The dependency is a whole device. */
                else {
-                       DBG(DEV, ul_debugobj(dev, " %s: %s: dependence is whole-disk",
+                       DBG_OBJ(DEV, dev, ul_debug(" %s: %s: dependence is whole-disk",
                                                                dev->name, d->d_name));
 
                        dep = devtree_get_device_or_new(tr, NULL, d->d_name);
@@ -2095,7 +2100,7 @@ static void device_set_dedupkey(
 
        dev->dedupkey = device_get_data(dev, parent, id, NULL, NULL);
        if (dev->dedupkey)
-               DBG(DEV, ul_debugobj(dev, "%s: de-duplication key: %s", dev->name, dev->dedupkey));
+               DBG_OBJ(DEV, dev, ul_debug("%s: de-duplication key: %s", dev->name, dev->dedupkey));
 
        if (dev->npartitions == 0)
                /* For partitions we often read from parental whole-disk sysfs,
index 90d2df1a135c10072a89caa7172b5518b368ef94..709537c9dbd96211375d4ee2b6c8a7d3491c342d 100644 (file)
 #define LSBLK_DEBUG_ALL                0xFFFF
 
 UL_DEBUG_DECLARE_MASK(lsblk);
-#define DBG(m, x)       __UL_DBG(lsblk, LSBLK_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(lsblk, LSBLK_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(lsblk)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(lsblk, LSBLK_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(lsblk, LSBLK_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(lsblk, LSBLK_DEBUG_, m, x)
 
 /* --properties-by items */
 enum lsblk_devprop_method {
index 2e2ecda9e988540dc95ead1f50c4417faaef10cf..3062fc20f76c59b1084e8733d6199fc4e3de861e 100644 (file)
@@ -73,11 +73,9 @@ UL_DEBUG_DEFINE_MASKNAMES(whereis) = UL_DEBUG_EMPTY_MASKNAMES;
 #define WHEREIS_DEBUG_LIST     (1 << 7)
 #define WHEREIS_DEBUG_ALL      0xFFFF
 
-#define DBG(m, x)       __UL_DBG(whereis, WHEREIS_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(whereis, WHEREIS_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(whereis)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(whereis, WHEREIS_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(whereis, WHEREIS_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(whereis, WHEREIS_DEBUG_, m, x)
 
 static char uflag;
 static char use_glob;
@@ -240,7 +238,7 @@ static void dirlist_add_dir(struct wh_dirlist **ls0, int type, const char *dir)
                if (ls->st_ino == st.st_ino &&
                    ls->st_dev == st.st_dev &&
                    ls->type == type) {
-                       DBG(LIST, ul_debugobj(*ls0, "  ignore (already in list): %s", dir));
+                       DBG_OBJ(LIST, *ls0, ul_debug("  ignore (already in list): %s", dir));
                        return;
                }
                prev = ls;
@@ -261,7 +259,7 @@ static void dirlist_add_dir(struct wh_dirlist **ls0, int type, const char *dir)
                prev->next = ls;        /* add to the end of the list */
        }
 
-       DBG(LIST, ul_debugobj(*ls0, "  add dir: %s", ls->path));
+       DBG_OBJ(LIST, *ls0, ul_debug("  add dir: %s", ls->path));
 }
 
 /* special case for '*' in the paths */
@@ -294,7 +292,7 @@ static void dirlist_add_subdir(struct wh_dirlist **ls, int type, const char *dir
        if (!dirp)
                goto ignore;
 
-       DBG(LIST, ul_debugobj(*ls, " scanning subdirs: %s [%s<subdir>%s]",
+       DBG_OBJ(LIST, *ls, ul_debug(" scanning subdirs: %s [%s<subdir>%s]",
                                dir, buf, postfix ? postfix : ""));
 
        while ((dp = readdir(dirp)) != NULL) {
@@ -310,7 +308,7 @@ static void dirlist_add_subdir(struct wh_dirlist **ls, int type, const char *dir
        closedir(dirp);
        return;
 ignore:
-       DBG(LIST, ul_debugobj(*ls, " ignore path: %s", dir));
+       DBG_OBJ(LIST, *ls, ul_debug(" ignore path: %s", dir));
 }
 
 static void construct_dirlist_from_env(const char *env,
@@ -323,7 +321,7 @@ static void construct_dirlist_from_env(const char *env,
                return;
        pathcp = xstrdup(path);
 
-       DBG(ENV, ul_debugobj(*ls, "construct %s dirlist from: %s",
+       DBG_OBJ(ENV, *ls, ul_debug("construct %s dirlist from: %s",
                                whereis_type_to_name(type), path));
 
        for (tok = strtok_r(pathcp, ":", &key); tok;
@@ -341,14 +339,14 @@ static void construct_dirlist_from_argv(struct wh_dirlist **ls,
 {
        int i;
 
-       DBG(ARGV, ul_debugobj(*ls, "construct %s dirlist from argv[%d..]",
+       DBG_OBJ(ARGV, *ls, ul_debug("construct %s dirlist from argv[%d..]",
                                whereis_type_to_name(type), *idx));
 
        for (i = *idx; i < argc; i++) {
                if (*argv[i] == '-')                    /* end of the list */
                        break;
 
-               DBG(ARGV, ul_debugobj(*ls, "  using argv[%d]: %s", *idx, argv[*idx]));
+               DBG_OBJ(ARGV, *ls, ul_debug("  using argv[%d]: %s", *idx, argv[*idx]));
                dirlist_add_dir(ls, type, argv[i]);
                *idx = i;
        }
@@ -360,7 +358,7 @@ static void construct_dirlist(struct wh_dirlist **ls,
 {
        size_t i;
 
-       DBG(STATIC, ul_debugobj(*ls, "construct %s dirlist from static array",
+       DBG_OBJ(STATIC, *ls, ul_debug("construct %s dirlist from static array",
                                whereis_type_to_name(type)));
 
        for (i = 0; paths[i]; i++) {
@@ -377,12 +375,12 @@ static void free_dirlist(struct wh_dirlist **ls0, int type)
 
        *ls0 = NULL;
 
-       DBG(LIST, ul_debugobj(*ls0, "free dirlist"));
+       DBG_OBJ(LIST, *ls0, ul_debug("free dirlist"));
 
        while (ls) {
                if (ls->type & type) {
                        next = ls->next;
-                       DBG(LIST, ul_debugobj(*ls0, " free: %s", ls->path));
+                       DBG_OBJ(LIST, *ls0, ul_debug(" free: %s", ls->path));
                        free(ls->path);
                        free(ls);
                        ls = next;
index 0619e7d349cd065b83e3ce62e4c7250f6110f074..caf2596229ebbf47b0c78ca3a632f9195d22b3ca 100644 (file)
@@ -24,7 +24,7 @@ struct lscpu_cpu *lscpu_new_cpu(int id)
        cpu->address = -1;
        cpu->configured = -1;
 
-       DBG(CPU, ul_debugobj(cpu, "alloc"));
+       DBG_OBJ(CPU, cpu, ul_debug("alloc"));
        return cpu;
 }
 
@@ -40,7 +40,7 @@ void lscpu_unref_cpu(struct lscpu_cpu *cpu)
                return;
 
        if (--cpu->refcount <= 0) {
-               DBG(CPU, ul_debugobj(cpu, "  freeing #%d", cpu->logical_id));
+               DBG_OBJ(CPU, cpu, ul_debug("  freeing #%d", cpu->logical_id));
                lscpu_unref_cputype(cpu->type);
                cpu->type = NULL;
                free(cpu->dynamic_mhz);
@@ -76,7 +76,7 @@ int lscpu_cpu_set_type(struct lscpu_cpu *cpu, struct lscpu_cputype *type)
        if (cpu->type == type)
                return 0;
 
-       DBG(CPU, ul_debugobj(cpu, " type %p -> %p", cpu->type, type));
+       DBG_OBJ(CPU, cpu, ul_debug(" type %p -> %p", cpu->type, type));
        lscpu_unref_cputype(cpu->type);
        cpu->type = type;
        lscpu_ref_cputype(type);
index 958cbe7b67c0833be4803ad070ce4d7a09e0453f..6440215bb12e8456e0f0396d9130df53ced2ee96 100644 (file)
@@ -65,7 +65,7 @@ struct lscpu_cputype *lscpu_new_cputype(void)
        ct->dispatching = -1;
        ct->freqboost = -1;
 
-       DBG(TYPE, ul_debugobj(ct, "alloc"));
+       DBG_OBJ(TYPE, ct, ul_debug("alloc"));
        return ct;
 }
 
@@ -73,7 +73,7 @@ void lscpu_ref_cputype(struct lscpu_cputype *ct)
 {
        if (ct) {
                ct->refcount++;
-               /*DBG(TYPE, ul_debugobj(ct, ">>> ref %d", ct->refcount));*/
+               /*DBG_OBJ(TYPE, ct, ul_debug(">>> ref %d", ct->refcount));*/
        }
 }
 
@@ -82,10 +82,10 @@ void lscpu_unref_cputype(struct lscpu_cputype *ct)
        if (!ct)
                return;
 
-       /*DBG(TYPE, ul_debugobj(ct, ">>> unref %d", ct->refcount - 1));*/
+       /*DBG_OBJ(TYPE, ct, ul_debug(">>> unref %d", ct->refcount - 1));*/
 
        if (--ct->refcount <= 0) {
-               DBG(TYPE, ul_debugobj(ct, "  freeing %s/%s", ct->vendor, ct->model));
+               DBG_OBJ(TYPE, ct, ul_debug("  freeing %s/%s", ct->vendor, ct->model));
                lscpu_cputype_free_topology(ct);
                free(ct->vendor);
                free(ct->bios_vendor);
@@ -118,7 +118,7 @@ struct lscpu_cputype *lscpu_cputype_get_default(struct lscpu_cxt *cxt)
 
 struct lscpu_cputype *lscpu_add_cputype(struct lscpu_cxt *cxt, struct lscpu_cputype *ct)
 {
-       DBG(TYPE, ul_debugobj(ct, "add new"));
+       DBG_OBJ(TYPE, ct, ul_debug("add new"));
        cxt->cputypes = xreallocarray(cxt->cputypes, cxt->ncputypes + 1,
                                      sizeof(struct lscpu_cputype *));
        cxt->cputypes[cxt->ncputypes] = ct;
@@ -361,14 +361,14 @@ static void deduplicate_cputypes(struct lscpu_cxt *cxt)
        for (u = 0, i = 1; i < cxt->ncputypes; i++) {
                struct lscpu_cputype *ct = cxt->cputypes[i];
 
-               DBG(TYPE, ul_debugobj(ct, "compare with %p", cxt->cputypes[u]));
+               DBG_OBJ(TYPE, ct, ul_debug("compare with %p", cxt->cputypes[u]));
 
                if (cmp_cputype(&cxt->cputypes[u], &ct) == 0) {
-                       DBG(TYPE, ul_debugobj(ct, " duplicated"));
+                       DBG_OBJ(TYPE, ct, ul_debug(" duplicated"));
                        replace_cpu_type(cxt, ct, cxt->cputypes[u]);
                        lscpu_unref_cputype(ct);
                } else {
-                       DBG(TYPE, ul_debugobj(ct, " uniq"));
+                       DBG_OBJ(TYPE, ct, ul_debug(" uniq"));
                        u++;
                        if (u != i)
                                cxt->cputypes[u] = ct;
@@ -396,7 +396,7 @@ static void deduplicate_cputypes(struct lscpu_cxt *cxt)
                struct lscpu_cputype *ct = cxt->cputypes[0],    /* subset ? */
                                     *mt = cxt->cputypes[1];    /* master ? */
 
-               DBG(TYPE, ul_debugobj(ct, "checking items in %p", mt));
+               DBG_OBJ(TYPE, ct, ul_debug("checking items in %p", mt));
                for (i = 0; i < ARRAY_SIZE(items); i++) {
                        if (!is_nonnull_offset(ct, items[i]))
                                continue;
@@ -524,7 +524,7 @@ static int cpuinfo_parse_cache(struct lscpu_cxt *cxt, int keynum, char *data)
        int level;
        unsigned int line_size, associativity;
 
-       DBG(GATHER, ul_debugobj(cxt, " parse cpuinfo cache '%s'", data));
+       DBG_OBJ(GATHER, cxt, ul_debug(" parse cpuinfo cache '%s'", data));
 
        p = strstr(data, "scope=") + 6;
        /* Skip private caches, also present in sysfs */
@@ -594,7 +594,7 @@ int lscpu_read_cpuinfo(struct lscpu_cxt *cxt)
        assert(cxt->npossibles);        /* lscpu_create_cpus() required */
        assert(cxt->cpus);
 
-       DBG(GATHER, ul_debugobj(cxt, "reading cpuinfo"));
+       DBG_OBJ(GATHER, cxt, ul_debug("reading cpuinfo"));
 
        fp = ul_path_fopen(cxt->procfs, "r", "cpuinfo");
        if (!fp)
@@ -794,7 +794,7 @@ struct lscpu_arch *lscpu_read_architecture(struct lscpu_cxt *cxt)
                        ar->bit32 = 1;
        }
 
-       DBG(GATHER, ul_debugobj(ar, "arch: name=%s %s %s",
+       DBG_OBJ(GATHER, ar, ul_debug("arch: name=%s %s %s",
                                ar->name,
                                ar->bit64 ? "64-bit" : "",
                                ar->bit64 ? "32-bit" : ""));
@@ -814,7 +814,7 @@ int lscpu_read_cpulists(struct lscpu_cxt *cxt)
        cpu_set_t *cpuset = NULL;
 
        assert(cxt);
-       DBG(GATHER, ul_debugobj(cxt, "reading cpulists"));
+       DBG_OBJ(GATHER, cxt, ul_debug("reading cpulists"));
 
        if (ul_path_read_s32(cxt->syscpu, &cxt->maxcpus, "kernel_max") == 0)
                /* note that kernel_max is maximum index [NR_CPUS-1] */
@@ -867,7 +867,7 @@ int lscpu_read_archext(struct lscpu_cxt *cxt)
        char buf[BUFSIZ];
        struct lscpu_cputype *ct;
 
-       DBG(GATHER, ul_debugobj(cxt, "reading extra arch info"));
+       DBG_OBJ(GATHER, cxt, ul_debug("reading extra arch info"));
 
        assert(cxt);
        ct = lscpu_cputype_get_default(cxt);
@@ -934,7 +934,7 @@ int lscpu_read_vulnerabilities(struct lscpu_cxt *cxt)
 
        assert(cxt);
 
-       DBG(GATHER, ul_debugobj(cxt, "reading vulnerabilities"));
+       DBG_OBJ(GATHER, cxt, ul_debug("reading vulnerabilities"));
 
        dir = ul_path_opendir(cxt->syscpu, "vulnerabilities");
        if (!dir)
@@ -1050,7 +1050,7 @@ int lscpu_read_numas(struct lscpu_cxt *cxt)
                ul_path_readf_cpuset(sys, &cxt->nodemaps[i], cxt->maxcpus,
                                "node%d/cpumap", cxt->idx2nodenum[i]);
 done:
-       DBG(GATHER, ul_debugobj(cxt, "read %zu numas", cxt->nnodes));
+       DBG_OBJ(GATHER, cxt, ul_debug("read %zu numas", cxt->nnodes));
 
        ul_unref_path(sys);
        return 0;
index 460ba449b28e455b566f25f9be3ef508fcdaabf6..327b05cddd101731ecd444931d86842b102b53ab 100644 (file)
@@ -148,7 +148,7 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
        sys = cxt->syscpu;                              /* /sys/devices/system/cpu/ */
        npos = cxt->npossibles;                         /* possible CPUs */
 
-       DBG(TYPE, ul_debugobj(ct, "reading %s/%s/%s topology",
+       DBG_OBJ(TYPE, ct, ul_debug("reading %s/%s/%s topology",
                                ct->vendor ?: "", ct->model ?: "", ct->modelname ?:""));
 
        hp_online_state = get_online_state(sys);
@@ -239,7 +239,7 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
                int t0, t1;
                char buf[BUFSIZ];
 
-               DBG(TYPE, ul_debugobj(ct, " reading sysinfo"));
+               DBG_OBJ(TYPE, ct, ul_debug(" reading sysinfo"));
 
                while (fgets(buf, sizeof(buf), fd) != NULL) {
                        if (sscanf(buf, "CPU Topology SW: %d %d %zu %zu %zu %zu",
@@ -249,7 +249,7 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
                                        &ct->nsockets_per_book,
                                        &ct->ncores_per_socket) == 6) {
                                sw_topo = 1;
-                               DBG(TYPE, ul_debugobj(ct, " using SW topology"));
+                               DBG_OBJ(TYPE, ct, ul_debug(" using SW topology"));
                                break;
                        }
                }
@@ -271,11 +271,11 @@ static int cputype_read_topology(struct lscpu_cxt *cxt, struct lscpu_cputype *ct
                ct->ndrawers_per_system = ct->ndrawers;
        }
 
-       DBG(TYPE, ul_debugobj(ct, " nthreads: %zu (per core)", ct->nthreads_per_core));
-       DBG(TYPE, ul_debugobj(ct, "   ncores: %zu (%zu per socket)", ct->ncores, ct->ncores_per_socket));
-       DBG(TYPE, ul_debugobj(ct, " nsockets: %zu (%zu per books)", ct->nsockets, ct->nsockets_per_book));
-       DBG(TYPE, ul_debugobj(ct, "   nbooks: %zu (%zu per drawer)", ct->nbooks, ct->nbooks_per_drawer));
-       DBG(TYPE, ul_debugobj(ct, " ndrawers: %zu (%zu per system)", ct->ndrawers, ct->ndrawers_per_system));
+       DBG_OBJ(TYPE, ct, ul_debug(" nthreads: %zu (per core)", ct->nthreads_per_core));
+       DBG_OBJ(TYPE, ct, ul_debug("   ncores: %zu (%zu per socket)", ct->ncores, ct->ncores_per_socket));
+       DBG_OBJ(TYPE, ct, ul_debug(" nsockets: %zu (%zu per books)", ct->nsockets, ct->nsockets_per_book));
+       DBG_OBJ(TYPE, ct, ul_debug("   nbooks: %zu (%zu per drawer)", ct->nbooks, ct->nbooks_per_drawer));
+       DBG_OBJ(TYPE, ct, ul_debug(" ndrawers: %zu (%zu per system)", ct->ndrawers, ct->ndrawers_per_system));
 
        return 0;
 }
@@ -350,7 +350,7 @@ static struct lscpu_cache *add_cache(struct lscpu_cxt *cxt,
        ca->level = level;
        ca->type = xstrdup(type);
 
-       DBG(GATHER, ul_debugobj(cxt, "add cache %s%d::%d", type, level, id));
+       DBG_OBJ(GATHER, cxt, ul_debug("add cache %s%d::%d", type, level, id));
        return ca;
 }
 
@@ -394,7 +394,7 @@ static int read_sparc_onecache(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu,
        if (rc != 0)
                return rc;
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading sparc %s cache", num, buf));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading sparc %s cache", num, buf));
 
        id = mk_cache_id(cxt, cpu, typestr, level);
 
@@ -454,7 +454,7 @@ static int read_caches(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
                                "cpu%d/l1_icache_size", num) == 0)
                return read_sparc_caches(cxt, cpu);
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading %zd caches", num, ncaches));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading %zd caches", num, ncaches));
 
        for (i = 0; i < ncaches; i++) {
                struct lscpu_cache *ca;
@@ -531,7 +531,7 @@ static int read_ids(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
        if (ul_path_accessf(sys, F_OK, "cpu%d/topology", num) != 0)
                return 0;
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading IDs", num));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading IDs", num));
 
        if (ul_path_readf_s32(sys, &cpu->coreid, "cpu%d/topology/core_id", num) != 0)
                cpu->coreid = -1;
@@ -556,7 +556,7 @@ static int read_polarization(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
 
        ul_path_readf_buffer(sys, mode, sizeof(mode), "cpu%d/polarization", num);
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading polar=%s", num, mode));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading polar=%s", num, mode));
 
        if (strncmp(mode, "vertical:low", sizeof(mode)) == 0)
                cpu->polarization = POLAR_VLOW;
@@ -582,7 +582,7 @@ static int read_address(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
        if (ul_path_accessf(sys, F_OK, "cpu%d/address", num) != 0)
                return 0;
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading address", num));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading address", num));
 
        ul_path_readf_s32(sys, &cpu->address, "cpu%d/address", num);
        if (cpu->type)
@@ -598,7 +598,7 @@ static int read_configure(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
        if (ul_path_accessf(sys, F_OK, "cpu%d/configure", num) != 0)
                return 0;
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading configure", num));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading configure", num));
 
        ul_path_readf_s32(sys, &cpu->configured, "cpu%d/configure", num);
        if (cpu->type)
@@ -612,7 +612,7 @@ static int read_mhz(struct lscpu_cxt *cxt, struct lscpu_cpu *cpu)
        int num = cpu->logical_id;
        int mhz;
 
-       DBG(CPU, ul_debugobj(cpu, "#%d reading mhz", num));
+       DBG_OBJ(CPU, cpu, ul_debug("#%d reading mhz", num));
 
        if (ul_path_readf_s32(sys, &mhz, "cpu%d/cpufreq/cpuinfo_max_freq", num) == 0)
                cpu->mhz_max_freq = (float) mhz / 1000;
@@ -704,7 +704,7 @@ int lscpu_read_topology(struct lscpu_cxt *cxt)
                if (!cpu || !cpu->type)
                        continue;
 
-               DBG(CPU, ul_debugobj(cpu, "#%d reading topology", cpu->logical_id));
+               DBG_OBJ(CPU, cpu, ul_debug("#%d reading topology", cpu->logical_id));
 
                rc = read_ids(cxt, cpu);
                if (!rc)
@@ -720,10 +720,10 @@ int lscpu_read_topology(struct lscpu_cxt *cxt)
        }
 
        lscpu_sort_caches(cxt->caches, cxt->ncaches);
-       DBG(GATHER, ul_debugobj(cxt, " L1d: %zu", lscpu_get_cache_full_size(cxt, "L1d", NULL)));
-       DBG(GATHER, ul_debugobj(cxt, " L1i: %zu", lscpu_get_cache_full_size(cxt, "L1i", NULL)));
-       DBG(GATHER, ul_debugobj(cxt, " L2: %zu", lscpu_get_cache_full_size(cxt, "L2", NULL)));
-       DBG(GATHER, ul_debugobj(cxt, " L3: %zu", lscpu_get_cache_full_size(cxt, "L3", NULL)));
+       DBG_OBJ(GATHER, cxt, ul_debug(" L1d: %zu", lscpu_get_cache_full_size(cxt, "L1d", NULL)));
+       DBG_OBJ(GATHER, cxt, ul_debug(" L1i: %zu", lscpu_get_cache_full_size(cxt, "L1i", NULL)));
+       DBG_OBJ(GATHER, cxt, ul_debug(" L2: %zu", lscpu_get_cache_full_size(cxt, "L2", NULL)));
+       DBG_OBJ(GATHER, cxt, ul_debug(" L3: %zu", lscpu_get_cache_full_size(cxt, "L3", NULL)));
 
        return rc;
 }
index a4fc171b8d31d4a37af6e6c8d6b5def3b0a3af52..5cdb4834b15172389037a18b7f120b364c75a176 100644 (file)
@@ -676,7 +676,7 @@ struct lscpu_virt *lscpu_read_virtualization(struct lscpu_cxt *cxt)
                }
        }
 done:
-       DBG(VIRT, ul_debugobj(virt, "virt: cpu='%s' hypervisor='%s' vendor=%d type=%d",
+       DBG_OBJ(VIRT, virt, ul_debug("virt: cpu='%s' hypervisor='%s' vendor=%d type=%d",
                                virt->cpuflag,
                                virt->hypervisor,
                                virt->vendor,
index 4556aa6df4168b838ee08415fa894ba58a5e581b..8c35dfd1cd2df26fa67e475830e2f15aad1581ec 100644 (file)
@@ -214,7 +214,7 @@ cache_column_name_to_id(const char *name, size_t namesz)
 
 static void lscpu_context_init_paths(struct lscpu_cxt *cxt)
 {
-       DBG(MISC, ul_debugobj(cxt, "initialize paths"));
+       DBG_OBJ(MISC, cxt, ul_debug("initialize paths"));
        ul_path_init_debug();
 
        /* / */
@@ -253,19 +253,19 @@ static void lscpu_free_context(struct lscpu_cxt *cxt)
        if (!cxt)
                return;
 
-       DBG(MISC, ul_debugobj(cxt, "freeing context"));
+       DBG_OBJ(MISC, cxt, ul_debug("freeing context"));
 
-       DBG(MISC, ul_debugobj(cxt, " de-initialize paths"));
+       DBG_OBJ(MISC, cxt, ul_debug(" de-initialize paths"));
        ul_unref_path(cxt->syscpu);
        ul_unref_path(cxt->procfs);
        ul_unref_path(cxt->rootfs);
 
-       DBG(MISC, ul_debugobj(cxt, " freeing cpus"));
+       DBG_OBJ(MISC, cxt, ul_debug(" freeing cpus"));
        for (i = 0; i < cxt->npossibles; i++) {
                lscpu_unref_cpu(cxt->cpus[i]);
                cxt->cpus[i] = NULL;
        }
-       DBG(MISC, ul_debugobj(cxt, " freeing types"));
+       DBG_OBJ(MISC, cxt, ul_debug(" freeing types"));
        for (i = 0; i < cxt->ncputypes; i++) {
                lscpu_unref_cputype(cxt->cputypes[i]);
                cxt->cputypes[i] = NULL;
index 0fae5d29ec6b2f1036ded7424ae6de509320457b..c7ff037899eee9e7dc8cbf9d913fd12c17b64c18 100644 (file)
 #define LSBLK_DEBUG_ALL                0xFFFF
 
 UL_DEBUG_DECLARE_MASK(lscpu);
-#define DBG(m, x)       __UL_DBG(lscpu, LSCPU_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(lscpu, LSCPU_DEBUG_, m, x)
-
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(lscpu)
-#include "debugobj.h"
+#define DBG(m, x)              __UL_DBG(lscpu, LSCPU_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(lscpu, LSCPU_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(lscpu, LSCPU_DEBUG_, m, x)
 
 #define _PATH_SYS_SYSTEM       "/sys/devices/system"
 #define _PATH_SYS_HYP_FEATURES "/sys/hypervisor/properties/features"
index 5e3b8c73bbce7c056aef951c3475a9ada82d2d4c..c8ee3ceacaf47dad4591ebf52e47111b040ac2e2 100644 (file)
@@ -68,8 +68,9 @@ UL_DEBUG_DEFINE_MASKNAMES(lsns) = UL_DEBUG_EMPTY_MASKNAMES;
 
 #define LSNS_NETNS_UNUSABLE -2
 
-#define DBG(m, x)       __UL_DBG(lsns, LSNS_DEBUG_, m, x)
-#define ON_DBG(m, x)    __UL_DBG_CALL(lsns, LSNS_DEBUG_, m, x)
+#define DBG(m, x)              __UL_DBG(lsns, LSNS_DEBUG_, m, x)
+#define DBG_OBJ(m, h, x)       __UL_DBG_OBJ(lsns, LSNS_DEBUG_, m, h, x)
+#define ON_DBG(m, x)           __UL_DBG_CALL(lsns, LSNS_DEBUG_, m, x)
 
 #define lsns_ioctl(fildes, request, ...) __extension__ ({ \
        int ret = ioctl(fildes, request, ##__VA_ARGS__); \
@@ -77,9 +78,6 @@ UL_DEBUG_DEFINE_MASKNAMES(lsns) = UL_DEBUG_EMPTY_MASKNAMES;
                warnx("Unsupported ioctl %s", #request); \
        ret; })
 
-#define UL_DEBUG_CURRENT_MASK  UL_DEBUG_MASK(lsns)
-#include "debugobj.h"
-
 #define EXIT_UNSUPPORTED_IOCTL 2
 
 static struct idcache *uid_cache = NULL;
@@ -705,7 +703,7 @@ static int read_process(struct lsns *ls, struct path_cxt *pc)
 
        INIT_LIST_HEAD(&p->processes);
 
-       DBG(PROC, ul_debugobj(p, "new pid=%d", p->pid));
+       DBG_OBJ(PROC, p, ul_debug("new pid=%d", p->pid));
        list_add_tail(&p->processes, &ls->processes);
 
        read_opened_namespaces(ls, pc, p->pid);
@@ -791,7 +789,7 @@ static struct lsns_namespace *add_namespace(struct lsns *ls, enum lsns_type type
        if (!ns)
                return NULL;
 
-       DBG(NS, ul_debugobj(ns, "new %s[%ju]", ns_names[type], (uintmax_t)ino));
+       DBG_OBJ(NS, ns, ul_debug("new %s[%ju]", ns_names[type], (uintmax_t)ino));
 
        INIT_LIST_HEAD(&ns->processes);
        INIT_LIST_HEAD(&ns->namespaces);
@@ -810,7 +808,7 @@ static int add_process_to_namespace(struct lsns *ls, struct lsns_namespace *ns,
 {
        struct list_head *p;
 
-       DBG(NS, ul_debugobj(ns, "add process [%p] pid=%d to %s[%ju]",
+       DBG_OBJ(NS, ns, ul_debug("add process [%p] pid=%d to %s[%ju]",
                proc, proc->pid, ns_names[ns->type], (uintmax_t)ns->id));
 
        list_for_each(p, &ls->processes) {