include/crc64.h \
include/c_strtod.h \
include/debug.h \
- include/debugobj.h \
include/encode.h \
include/env.h \
include/exec_shell.h \
#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) { \
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,
+++ /dev/null
-/*
- * 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 */
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)
{
#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)
{
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);
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);
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;
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
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;
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;
}
{
assert(data);
- DBG(DATA, ul_debugobj(data, "deinit"));
+ DBG_OBJ(DATA, data, ul_debug("deinit"));
free(data->blocks);
data->blocks = NULL;
data->nblocks = 0;
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;
}
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);
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;
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);
}
}
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)
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;
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;
}
/* 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;
}
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;
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
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);
}
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);
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)
}
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);
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;
}
#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)
{
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;
} 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);
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;
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) &&
* 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;
if (!lc)
return;
- DBG(CXT, ul_debugobj(lc, "de-initialize"));
+ DBG_OBJ(CXT, lc, ul_debug("de-initialize"));
free(lc->filename);
lc->filename = NULL;
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;
* (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;
}
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" : "??"));
iter = &lc->iter;
- DBG(ITER, ul_debugobj(iter, "initialize"));
+ DBG_OBJ(ITER, iter, ul_debug("initialize"));
/* always zeroize
*/
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)
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;
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);
&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;
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);
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;
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)
*/
* 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];
/* 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);
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;
}
}
}
- DBG(CXT, ul_debugobj(lc, "get_backing_file [%s]", res));
+ DBG_OBJ(CXT, lc, ul_debug("get_backing_file [%s]", res));
return res;
}
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;
}
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;
}
*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;
}
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;
}
} 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;
}
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;
}
} 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;
}
} 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;
}
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));
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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 */
}
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));
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;
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
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 */
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
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"));
}
/*
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) {
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)
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
{
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)
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;
}
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);
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;
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;
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;
}
{ 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)
{
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 */
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;
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;
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;
}
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"));
}
}
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 {
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);
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);
}
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;
}
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;
}
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;
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;
{ 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)
{
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;
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. */
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);
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);
}
/* 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)
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;
}
};
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
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;
}
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"));
}
}
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;
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);
}
#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)
{
if (!pc)
return NULL;
- DBG(CXT, ul_debugobj(pc, "alloc"));
+ DBG_OBJ(CXT, pc, ul_debug("alloc"));
pc->refcount = 1;
pc->dir_fd = -1;
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);
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;
}
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;
}
{
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;
}
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);
}
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;
}
&& 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;
}
&& 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;
}
&& 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;
}
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);
#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)
{
return NULL;
}
- DBG(CXT, ul_debugobj(pc, "alloc"));
+ DBG_OBJ(CXT, pc, ul_debug("alloc"));
return pc;
}
/* 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;
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;
if (!pc)
return;
- DBG(CXT, ul_debugobj(pc, "deinit"));
+ DBG_OBJ(CXT, pc, ul_debug("deinit"));
prc = ul_path_get_dialect(pc);
if (!prc)
#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)
{
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;
{
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));
}
}
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) {
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)
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;
}
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;
}
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);
}
/* 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();
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)
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)
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;
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;
}
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);
/* 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);
}
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)) {
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
}
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);
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)
&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;
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);
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) {
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 */
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" : "???",
* 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);
#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)
{
return NULL;
}
- DBG(CXT, ul_debugobj(pc, "alloc"));
+ DBG_OBJ(CXT, pc, ul_debug("alloc"));
return pc;
}
/* 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;
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);
if (!pc)
return;
- DBG(CXT, ul_debugobj(pc, "deinit"));
+ DBG_OBJ(CXT, pc, ul_debug("deinit"));
blk = ul_path_get_dialect(pc);
if (!blk)
} else
blk->parent = NULL;
- DBG(CXT, ul_debugobj(pc, "new parent"));
+ DBG_OBJ(CXT, pc, ul_debug("new parent"));
return 0;
}
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;
}
}
}
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;
}
#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);
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);
(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)); */
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,
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);
}
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;
} 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
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);
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)) {
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);
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 */
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 {
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) {
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;
}
/*
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;
}
{
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);
}
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;
}
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,
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,
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));
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;
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;
}
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;
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));
}
}
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));
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);
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;
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));
/* 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));
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) {
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;
}
}
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;
}
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;
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);
/* 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));
if (!ask)
return NULL;
- DBG(ASK, ul_debugobj(ask, "alloc"));
+ DBG_OBJ(ASK, ask, ul_debug("alloc"));
ask->refcount = 1;
return 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))
if (ask->refcount <= 0) {
fdisk_reset_ask(ask);
- DBG(ASK, ul_debugobj(ask, "free"));
+ DBG_OBJ(ASK, ask, ul_debug("free"));
free(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" :
!(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;
}
}
}
- 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) {
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
if (!cxt)
return NULL;
- DBG(CXT, ul_debugobj(cxt, "alloc"));
+ DBG_OBJ(CXT, cxt, ul_debug("alloc"));
cxt->dev_fd = -1;
cxt->refcount = 1;
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);
}
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;
&& 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;
}
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);
}
{
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++)
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);
}
/* 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" : "",
{
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;
}
}
{
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)
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;
}
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);
}
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);
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)
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."));
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);
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++;
}
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);
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
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;
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! */
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;
}
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;
#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
return NULL;
li->refcount = 1;
- DBG(ITEM, ul_debugobj(li, "alloc"));
+ DBG_OBJ(ITEM, li, ul_debug("alloc"));
return 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);
}
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);
return 0;
}
- DBG(CXT, ul_debugobj(cxt, "no label found"));
+ DBG_OBJ(CXT, cxt, ul_debug("no label found"));
return 1; /* not found */
}
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);
}
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);
}
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) {
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;
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);
}
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);
}
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;
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;
}
pa->refcount = 1;
init_partition(pa);
- DBG(PART, ul_debugobj(pa, "alloc"));
+ DBG_OBJ(PART, pa, ul_debug("alloc"));
return 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);
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);
}
}
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)) {
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))
{
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);
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,
#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;
}
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) {
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),
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;
}
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),
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;
}
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);
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);
} 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 */
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));
}
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;
/* 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);
}
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;
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;
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),
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;
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;
}
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);
}
t->refcount = 1;
t->flags = FDISK_PARTTYPE_ALLOCATED;
- DBG(PARTTYPE, ul_debugobj(t, "alloc"));
+ DBG_OBJ(PARTTYPE, t, ul_debug("alloc"));
return 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);
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);
}
if (ret)
- DBG(PARTTYPE, ul_debugobj(ret, " result '%s'", ret->name));
+ DBG_OBJ(PARTTYPE, ret, ul_debug(" result '%s'", ret->name));
return ret;
}
{
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];
{
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];
{
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;
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))
}
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;
}
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);
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);
{
assert(dp);
- DBG(SCRIPT, ul_debugobj(dp, "reset"));
+ DBG_OBJ(SCRIPT, dp, ul_debug("reset"));
if (dp->table)
fdisk_reset_table(dp->table);
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);
}
}
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);
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));
/* 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;
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;
}
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;
}
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);
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;
}
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);
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");
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);
}
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;
}
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) {
}
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);
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
fputc('\n', f);
}
- DBG(SCRIPT, ul_debugobj(dp, "write script done"));
+ DBG_OBJ(SCRIPT, dp, ul_debug("write script done"));
return 0;
}
"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;
}
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,
}
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,
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)
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)) {
}
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;
}
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;
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) {
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;
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)
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;
}
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 {
/* 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;
}
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));
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;
}
/* 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);
}
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) {
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);
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;
}
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;
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,
if (tb->refcount <= 0) {
fdisk_reset_table(tb);
- DBG(TAB, ul_debugobj(tb, "free"));
+ DBG_OBJ(TAB, tb, ul_debug("free"));
free(tb);
}
}
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,
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),
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);
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;
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),
fdisk_partition_is_nested(pa) ? " nested" : "",
fdisk_partition_is_freespace(pa) ? " freespace" : "",
fdisk_partition_is_container(pa) ? " container" : "");
+ }
}
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));
*/
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)) {
}
}
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);
}
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;
}
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)));
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;
}
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;
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)));
/* 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);
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;
}
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) {
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) {
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)
}
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);
}
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;
}
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;
}
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;
}
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;
}
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)
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) {
* 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;
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);
/* 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);
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);
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);
}
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)
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;
}
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];
{
if (cache) {
cache->refcount++;
- /*DBG(CACHE, ul_debugobj(cache, "ref=%d", cache->refcount));*/
+ /*DBG_OBJ(CACHE, cache, ul_debug("ref=%d", cache->refcount));*/
}
}
{
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);
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));
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)
}
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);
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;
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);
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;
*/
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);
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) {
{
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;
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);
{
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)
cxt->noautofs = 0;
- DBG(CXT, ul_debugobj(cxt, "----> allocate %s",
+ DBG_OBJ(CXT, cxt, ul_debug("----> allocate %s",
cxt->restricted ? "[RESTRICTED]" : ""));
return cxt;
free(cxt->children);
- DBG(CXT, ul_debugobj(cxt, "free"));
+ DBG_OBJ(CXT, cxt, ul_debug("free"));
free(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;
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);
}
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);
}
if (!n)
return NULL;
- DBG(CXT, ul_debugobj(n, "<---- clone ---->"));
+ DBG_OBJ(CXT, n, ul_debug("<---- clone ---->"));
n->flags = o->flags;
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)
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)
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;
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;
}
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) {
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:
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;
}
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);
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);
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)
}
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;
}
|| 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;
}
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:
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)
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;
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)
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:
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);
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;
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;
}
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;
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;
}
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;
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;
}
&& 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;
}
&& !(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;
}
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;
}
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,
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;
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;
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;
}
/* 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);
/* 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
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
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;
}
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;
}
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;
}
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;
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;
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:
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;
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) {
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;
}
}
/* 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;
}
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)
#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)
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)
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;
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;
*/
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;
}
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);
srcpath = xsrc;
}
if (!srcpath) {
- DBG(CXT, ul_debugobj(cxt, "perms: src undefined"));
+ DBG_OBJ(CXT, cxt, ul_debug("perms: src undefined"));
return -EPERM;
}
}
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;
}
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",
}
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);
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));
}
case -1:
cxt->helper_exec_status = rc = -errno;
- DBG(CXT, ul_debugobj(cxt, "fork() failed"));
+ DBG_OBJ(CXT, cxt, ul_debug("fork() failed"));
break;
}
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;
}
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)
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)
* 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
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;
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)
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;
}
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)
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;
}
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)
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;
}
&& !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);
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);
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;
}
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) ||
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,
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;
}
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);
}
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,
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,
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
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;
}
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)));
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));
}
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:
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 */
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
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);
}
}
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;
}
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);
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;
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;
}
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:
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;
}
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);
}
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;
* 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)
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));
}
fs = NULL;
}
if (!fs) {
- DBG(CXT, ul_debugobj(cxt,
+ DBG_OBJ(CXT, cxt, ul_debug(
"umount %s: mountinfo disagrees with fstab",
tgt));
goto eperm;
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;
}
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);
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;
}
}
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;
}
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;
}
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);
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));
}
case -1:
cxt->helper_exec_status = rc = -errno;
- DBG(CXT, ul_debugobj(cxt, "fork() failed"));
+ DBG_OBJ(CXT, cxt, ul_debug("fork() failed"));
break;
}
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)) {
/*
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)" : ""));
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));
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;
}
}
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;
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)
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 */
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;
}
fs->refcount = 1;
INIT_LIST_HEAD(&fs->ents);
- DBG(FS, ul_debugobj(fs, "alloc"));
+ DBG_OBJ(FS, fs, ul_debug("alloc"));
return 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);
{
if (fs) {
fs->refcount++;
- /*DBG(FS, ul_debugobj(fs, "ref=%d", fs->refcount));*/
+ /*DBG_OBJ(FS, fs, ul_debug("ref=%d", fs->refcount));*/
}
}
{
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);
}
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;
return NULL;
sm->refcount = 1;
- DBG(STATMNT, ul_debugobj(sm, "alloc"));
+ DBG_OBJ(STATMNT, sm, ul_debug("alloc"));
return sm;
#else
errno = ENOSYS;
{
if (sm) {
sm->refcount++;
- /*DBG(STATMNT, ul_debugobj(sm, "ref=%d", sm->refcount));*/
+ /*DBG_OBJ(STATMNT, sm, ul_debug("ref=%d", sm->refcount));*/
}
}
{
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);
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;
}
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;
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
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 */
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)
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 " : "",
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
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
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;
}
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,
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;
{
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) {
{
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) {
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);
}
}
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;
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;
}
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;
}
}
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;
}
}
* 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;
}
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;
{
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;
}
* 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;
* 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;
/* 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;
}
}
- 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. */
* 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;
}
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)));
}
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;
}
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:
* 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;
}
*/
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;
}
}
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;
}
/* 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;
}
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) {
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;
}
/*
* 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;
}
{
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) {
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;
/* 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);
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);
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)
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;
}
{
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;
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;
}
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);
/*
* 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 |
#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;
}
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;
}
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;
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)
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)
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));
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);
}
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;
/* 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;
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;
}
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)
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;
{
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) {
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)" : ""));
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;
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,
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);
}
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)" : ""));
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);
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)
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" :
{
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) {
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;
}
}
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,
{
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) {
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)
/* 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) {
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);
}
/* 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);
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;
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;
}
}
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,
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 */
/* 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);
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;
}
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) {
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)))
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;
}
}
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;
}
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;
}
&& 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)
#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);
}
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;
}
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;
}
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,
* 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) );
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"));
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) {
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));
}
}
/* 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);
}
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);
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);
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)
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);
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;
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++) {
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)
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;
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;
}
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);
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);
{
if (ml) {
ml->refcount++;
- /*DBG(FS, ul_debugobj(fs, "ref=%d", ml->refcount));*/
+ /*DBG_OBJ(FS, fs, ul_debug("ref=%d", ml->refcount));*/
}
}
{
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);
}
{
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;
}
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);
}
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;
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);
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);
}
}
mn->fd = -1;
INIT_LIST_HEAD(&mn->ents);
- DBG(MONITOR, ul_debugobj(mn, "alloc"));
+ DBG_OBJ(MONITOR, mn, ul_debug("alloc"));
return 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;
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;
}
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;
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;
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;
}
*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;
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;
}
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;
}
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);
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;
}
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 {
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;
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)
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" :
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);
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;
}
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)
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;
}
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;
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);
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;
}
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)
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;
}
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 {
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;
}
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;
}
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;
}
#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
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;
}
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;
}
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)
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 */
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:
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) {
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);
}
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);
}
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);
}
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) {
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);
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);
*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;
}
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 ||
* 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;
}
}
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]" :
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)));
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;
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,
{
if (tb) {
tb->refcount++;
- /*DBG(FS, ul_debugobj(tb, "ref=%d", tb->refcount));*/
+ /*DBG_OBJ(FS, tb, ul_debug("ref=%d", tb->refcount));*/
}
}
{
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);
}
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);
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;
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);
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)));
}
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);
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;
}
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);
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;
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) {
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))
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);
}
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;
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);
/* 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)) {
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);
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);
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)
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);
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);
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);
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);
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) {
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);
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) {
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) {
*/
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) {
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;
}
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) {
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
}
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;
}
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);
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,
{
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
*/
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)) {
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));
}
}
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;
}
/* 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;
}
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;
}
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;
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;
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,
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 */
}
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;
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,
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;
}
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)
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 */
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"));
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) {
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"));
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();
/* 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;
}
} 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;
}
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);
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;
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);
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;
}
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));
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;
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 */
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;
return NULL;
upd->act_fd = -1;
- DBG(UPDATE, ul_debugobj(upd, "allocate"));
+ DBG_OBJ(UPDATE, upd, ul_debug("allocate"));
return 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);
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));
}
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) {
}
}
- DBG(UPDATE, ul_debugobj(upd, "ready"));
+ DBG_OBJ(UPDATE, upd, ul_debug("ready"));
upd->ready = 1;
return 0;
}
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)
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;
}
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;
}
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;
}
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;
}
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)
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;
}
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)
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)
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)
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;
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;
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)
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));
}
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;
}
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)
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;
}
} 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;
}
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;
}
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);
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);
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)
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);
/* 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);
}
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]",
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));
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));
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)) :
}
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
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 */
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);
/* 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) {
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;
}
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 */
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++;
}
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 */
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++;
} 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;
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;
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);
if (!rc)
dest->userdata = src->userdata;
- DBG(CELL, ul_debugobj(src, "copy"));
+ DBG_OBJ(CELL, src, ul_debug("copy"));
return rc;
}
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;
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);
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;
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;
}
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)) {
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;
}
{
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:
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)
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);
}
}
}
- 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;
}
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;
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);
}
{
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) {
}
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;
}
}
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;
}
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:
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;
}
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;
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;
}
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);
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);
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);
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);
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;
}
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);
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;
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);
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);
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)));
}
&& 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);
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));
}
{
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
*/
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) {
}
}
- 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 *));
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 *)),
done:
/*
- DBG(TAB, ul_debugobj(tb, "new grpset:"));
+ DBG_OBJ(TAB, tb, ul_debug("new grpset:"));
grpset_debug(tb, NULL);
*/
return first;
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 &&
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();
}
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;
}
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];
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;
}
{
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;
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;
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++;
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;
}
}
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);
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);
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);
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);
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]);
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)
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));
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;
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);
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]))
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)
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);
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);
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) {
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);
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 */
{
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);
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++;
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);
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)
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;
}
assert(ln);
- DBG(LINE, ul_debugobj(ln, " printing line"));
+ DBG_OBJ(LINE, ln, ul_debug(" printing line"));
fputs_color_line_open(tb, ln);
/* 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);
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) {
} 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);
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;
}
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);
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;
}
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) {
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);
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);
}
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);
#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
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;
}
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();
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);
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;
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;
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);
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 */
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)
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;
}
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;
}
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);
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);
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);
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);
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)
/* 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);
}
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;
}
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;
}
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)
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)
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)
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;
}
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;
}
{
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;
}
{
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;
}
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;
}
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;
}
{
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;
}
{
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;
}
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))
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);
*/
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;
}
*/
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;
}
{
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))
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,
}
}
-/* 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;
}
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;
}
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;
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;
}
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;
}
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;
}
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);
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);
}
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);
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);
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);
}
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;
}
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;
}
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,
/* 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;
}
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;
{
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;
}
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;
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;
}
}
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
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 */
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 */
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);
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 */
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);
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;
}
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)
!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;
}
{
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;
{
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);
}
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;
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;
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);
}
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 */
{
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;
}
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;
}
/* 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;
}
}
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;
}
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;
}
}
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;
}
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;
}
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)
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)
* 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;
}
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;
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;
}
}
/* 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);
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,
#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 {
#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;
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;
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 */
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) {
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,
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;
{
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;
}
{
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++) {
*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;
cpu->address = -1;
cpu->configured = -1;
- DBG(CPU, ul_debugobj(cpu, "alloc"));
+ DBG_OBJ(CPU, cpu, ul_debug("alloc"));
return 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);
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);
ct->dispatching = -1;
ct->freqboost = -1;
- DBG(TYPE, ul_debugobj(ct, "alloc"));
+ DBG_OBJ(TYPE, ct, ul_debug("alloc"));
return ct;
}
{
if (ct) {
ct->refcount++;
- /*DBG(TYPE, ul_debugobj(ct, ">>> ref %d", ct->refcount));*/
+ /*DBG_OBJ(TYPE, ct, ul_debug(">>> ref %d", ct->refcount));*/
}
}
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);
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;
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;
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;
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 */
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)
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" : ""));
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] */
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);
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)
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;
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);
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",
&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;
}
}
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;
}
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;
}
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);
"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;
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;
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;
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)
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)
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;
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)
}
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;
}
}
}
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,
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();
/* / */
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;
#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"
#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__); \
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;
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);
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);
{
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) {