]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - include/path.h
blkdev.h: avoid some unused argument warnings
[thirdparty/util-linux.git] / include / path.h
index ebdb58d05ddf2d6c7905bd9109a86ab96de0e27f..e523f178120b0f2725e8aa8427a71fd18ca4e3f0 100644 (file)
@@ -1,12 +1,18 @@
+/*
+ * No copyright is claimed.  This code is in the public domain; do with
+ * it what you wish.
+ */
 #ifndef UTIL_LINUX_PATH_H
 #define UTIL_LINUX_PATH_H
 
 #include <stdio.h>
 #include <stdint.h>
-#include <stdint.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 #include <dirent.h>
 
+#include "c.h"
+
 struct path_cxt {
        int     dir_fd;
        char    *dir_path;
@@ -21,7 +27,8 @@ struct path_cxt {
        int     (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
 };
 
-struct path_cxt *ul_new_path(const char *dir);
+struct path_cxt *ul_new_path(const char *dir, ...)
+                       __attribute__ ((__format__ (__printf__, 1, 2)));
 void ul_unref_path(struct path_cxt *pc);
 void ul_ref_path(struct path_cxt *pc);
 
@@ -38,10 +45,14 @@ void *ul_path_get_dialect(struct path_cxt *pc);
 
 int ul_path_set_enoent_redirect(struct path_cxt *pc, int (*func)(struct path_cxt *, const char *, int *));
 int ul_path_get_dirfd(struct path_cxt *pc);
+void ul_path_close_dirfd(struct path_cxt *pc);
+int ul_path_isopen_dirfd(struct path_cxt *pc);
+int ul_path_is_accessible(struct path_cxt *pc);
 
 char *ul_path_get_abspath(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 4, 5)));
 
+int ul_path_stat(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)));
@@ -49,15 +60,18 @@ int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
 int ul_path_open(struct path_cxt *pc, int flags, const char *path);
 int ul_path_openf(struct path_cxt *pc, int flags, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
-int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap);
+int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap)
+                               __attribute__ ((__format__ (__printf__, 3, 0)));
 
 FILE *ul_path_fopen(struct path_cxt *pc, const char *mode, const char *path);
 FILE *ul_path_fopenf(struct path_cxt *pc, const char *mode, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
-FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap);
+FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap)
+                               __attribute__ ((__format__ (__printf__, 3, 0)));
 
 DIR *ul_path_opendir(struct path_cxt *pc, const char *path);
-DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap);
+DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap)
+                               __attribute__ ((__format__ (__printf__, 2, 0)));
 DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 2, 3)));
 
@@ -66,7 +80,8 @@ ssize_t ul_path_readlinkf(struct path_cxt *pc, char *buf, size_t bufsiz, const c
                                __attribute__ ((__format__ (__printf__, 4, 5)));
 
 int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path);
-int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap);
+int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap)
+                               __attribute__ ((__format__ (__printf__, 4, 0)));
 int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 4, 5)));
 
@@ -74,8 +89,14 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path);
 int ul_path_readf_string(struct path_cxt *pc, char **str, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
 
-int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...);
+int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path);
+int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
+                               __attribute__ ((__format__ (__printf__, 4, 5)));
+
+int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...)
+                               __attribute__ ((__format__ (__scanf__, 3, 4)));
 int ul_path_scanff(struct path_cxt *pc, const char *path, va_list ap, const char *fmt, ...)
+                               __attribute__ ((__format__ (__printf__, 2, 0)))
                                __attribute__ ((__format__ (__scanf__, 4, 5)));
 
 int ul_path_read_majmin(struct path_cxt *pc, dev_t *res, const char *path);
@@ -102,6 +123,7 @@ int ul_path_write_string(struct path_cxt *pc, const char *str, const char *path)
 int ul_path_writef_string(struct path_cxt *pc, const char *str, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
 
+int ul_path_write_s64(struct path_cxt *pc, int64_t num, const char *path);
 int ul_path_write_u64(struct path_cxt *pc, uint64_t num, const char *path);
 int ul_path_writef_u64(struct path_cxt *pc, uint64_t num, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
@@ -110,6 +132,7 @@ int ul_path_count_dirents(struct path_cxt *pc, const char *path);
 int ul_path_countf_dirents(struct path_cxt *pc, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 2, 3)));
 
+int ul_path_next_dirent(struct path_cxt *pc, DIR **sub, const char *dirname, struct dirent **d);
 
 
 #ifdef HAVE_CPU_SET_T