]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: add ul_path_statf() and ul_path_vstatf()
authorKarel Zak <kzak@redhat.com>
Thu, 2 May 2024 13:56:29 +0000 (15:56 +0200)
committerMasatake YAMATO <yamato@redhat.com>
Thu, 2 May 2024 21:56:02 +0000 (06:56 +0900)
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 9b47899495e229ace482afca9e14b9b95ef6fde9)

include/path.h
lib/path.c

index e523f178120b0f2725e8aa8427a71fd18ca4e3f0..4c84dd31f691bbe00924a3c7946158709798f60a 100644 (file)
@@ -53,6 +53,9 @@ char *ul_path_get_abspath(struct path_cxt *pc, char *buf, size_t bufsz, const ch
                                __attribute__ ((__format__ (__printf__, 4, 5)));
 
 int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *path);
+int ul_path_vstatf(struct path_cxt *pc, struct stat *sb, int flags, const char *path, va_list ap);
+int ul_path_statf(struct path_cxt *pc, struct stat *sb, int flags, const char *path, ...);
+
 int ul_path_access(struct path_cxt *pc, int mode, const char *path);
 int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
index 202f19ac4fc0d5a4e3d986100ec08db510eeba62..fec20187faae670ef7b20f0d1644d3e05268d294 100644 (file)
@@ -370,6 +370,25 @@ int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *pa
        return rc;
 }
 
+int ul_path_vstatf(struct path_cxt *pc, struct stat *sb, int flags, const char *path, va_list ap)
+{
+       const char *p = ul_path_mkpath(pc, path, ap);
+
+       return !p ? -errno : ul_path_stat(pc, sb, flags, p);
+}
+
+int ul_path_statf(struct path_cxt *pc, struct stat *sb, int flags, const char *path, ...)
+{
+       va_list ap;
+       int rc;
+
+       va_start(ap, path);
+       rc = ul_path_vstatf(pc, sb, flags, path, ap);
+       va_end(ap);
+
+       return rc;
+}
+
 int ul_path_open(struct path_cxt *pc, int flags, const char *path)
 {
        int fd;