diff options
author | Karel Zak | 2018-06-21 13:49:03 +0200 |
---|---|---|
committer | Karel Zak | 2018-06-21 13:49:03 +0200 |
commit | 83bbeb77c1e64b02ad5f36bde47d22be69d08a0f (patch) | |
tree | ec74dbfc41ac3ea0fd8d27d4f0f2c0932ddbd7ed /lib | |
parent | tests: add simple LVM lsblk dump (diff) | |
download | kernel-qcow2-util-linux-83bbeb77c1e64b02ad5f36bde47d22be69d08a0f.tar.gz kernel-qcow2-util-linux-83bbeb77c1e64b02ad5f36bde47d22be69d08a0f.tar.xz kernel-qcow2-util-linux-83bbeb77c1e64b02ad5f36bde47d22be69d08a0f.zip |
lib/path: allow dir-path formatting
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/path.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/path.c b/lib/path.c index 602674956..34abb144a 100644 --- a/lib/path.c +++ b/lib/path.c @@ -48,7 +48,7 @@ void ul_path_init_debug(void) __UL_INIT_DEBUG_FROM_ENV(ulpath, ULPATH_DEBUG_, 0, ULPATH_DEBUG); } -struct path_cxt *ul_new_path(const char *dir) +struct path_cxt *ul_new_path(const char *dir, ...) { struct path_cxt *pc = calloc(1, sizeof(*pc)); @@ -61,8 +61,14 @@ struct path_cxt *ul_new_path(const char *dir) pc->dir_fd = -1; if (dir) { - pc->dir_path = strdup(dir); - if (!pc->dir_path) + int rc; + va_list ap; + + va_start(ap, dir); + rc = vasprintf(&pc->dir_path, dir, ap); + va_end(ap); + + if (rc < 0 || !pc->dir_path) goto fail; } return pc; |