]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/path.h
1 #ifndef UTIL_LINUX_PATH_H
2 #define UTIL_LINUX_PATH_H
17 char path_buffer
[PATH_MAX
];
20 void (*free_dialect
)(struct path_cxt
*);
21 int (*redirect_on_enoent
)(struct path_cxt
*, const char *, int *);
24 struct path_cxt
*ul_new_path(const char *dir
);
25 void ul_unref_path(struct path_cxt
*pc
);
26 void ul_ref_path(struct path_cxt
*pc
);
28 void ul_path_init_debug(void);
30 int ul_path_set_prefix(struct path_cxt
*pc
, const char *prefix
);
31 const char *ul_path_get_prefix(struct path_cxt
*pc
);
33 int ul_path_set_dir(struct path_cxt
*pc
, const char *dir
);
34 const char *ul_path_get_dir(struct path_cxt
*pc
);
36 int ul_path_set_dialect(struct path_cxt
*pc
, void *data
, void free_data(struct path_cxt
*));
37 void *ul_path_get_dialect(struct path_cxt
*pc
);
39 int ul_path_set_enoent_redirect(struct path_cxt
*pc
, int (*func
)(struct path_cxt
*, const char *, int *));
40 int ul_path_get_dirfd(struct path_cxt
*pc
);
42 char *ul_path_get_abspath(struct path_cxt
*pc
, char *buf
, size_t bufsz
, const char *path
, ...)
43 __attribute__ ((__format__ (__printf__
, 4, 5)));
45 int ul_path_access(struct path_cxt
*pc
, int mode
, const char *path
);
46 int ul_path_accessf(struct path_cxt
*pc
, int mode
, const char *path
, ...)
47 __attribute__ ((__format__ (__printf__
, 3, 4)));
49 int ul_path_open(struct path_cxt
*pc
, int flags
, const char *path
);
50 int ul_path_openf(struct path_cxt
*pc
, int flags
, const char *path
, ...)
51 __attribute__ ((__format__ (__printf__
, 3, 4)));
52 int ul_path_vopenf(struct path_cxt
*pc
, int flags
, const char *path
, va_list ap
);
54 FILE *ul_path_fopen(struct path_cxt
*pc
, const char *mode
, const char *path
);
55 FILE *ul_path_fopenf(struct path_cxt
*pc
, const char *mode
, const char *path
, ...)
56 __attribute__ ((__format__ (__printf__
, 3, 4)));
57 FILE *ul_path_vfopenf(struct path_cxt
*pc
, const char *mode
, const char *path
, va_list ap
);
59 DIR *ul_path_opendir(struct path_cxt
*pc
, const char *path
);
60 DIR *ul_path_vopendirf(struct path_cxt
*pc
, const char *path
, va_list ap
);
61 DIR *ul_path_opendirf(struct path_cxt
*pc
, const char *path
, ...)
62 __attribute__ ((__format__ (__printf__
, 2, 3)));
64 ssize_t
ul_path_readlink(struct path_cxt
*pc
, char *buf
, size_t bufsiz
, const char *path
);
65 ssize_t
ul_path_readlinkf(struct path_cxt
*pc
, char *buf
, size_t bufsiz
, const char *path
, ...)
66 __attribute__ ((__format__ (__printf__
, 4, 5)));
68 int ul_path_read(struct path_cxt
*pc
, char *buf
, size_t len
, const char *path
);
69 int ul_path_vreadf(struct path_cxt
*pc
, char *buf
, size_t len
, const char *path
, va_list ap
);
70 int ul_path_readf(struct path_cxt
*pc
, char *buf
, size_t len
, const char *path
, ...)
71 __attribute__ ((__format__ (__printf__
, 4, 5)));
73 int ul_path_read_string(struct path_cxt
*pc
, char **str
, const char *path
);
74 int ul_path_readf_string(struct path_cxt
*pc
, char **str
, const char *path
, ...)
75 __attribute__ ((__format__ (__printf__
, 3, 4)));
77 int ul_path_scanf(struct path_cxt
*pc
, const char *path
, const char *fmt
, ...);
78 int ul_path_scanff(struct path_cxt
*pc
, const char *path
, va_list ap
, const char *fmt
, ...)
79 __attribute__ ((__format__ (__scanf__
, 4, 5)));
81 int ul_path_read_majmin(struct path_cxt
*pc
, dev_t
*res
, const char *path
);
82 int ul_path_readf_majmin(struct path_cxt
*pc
, dev_t
*res
, const char *path
, ...)
83 __attribute__ ((__format__ (__printf__
, 3, 4)));
85 int ul_path_read_u32(struct path_cxt
*pc
, uint32_t *res
, const char *path
);
86 int ul_path_readf_u32(struct path_cxt
*pc
, uint32_t *res
, const char *path
, ...)
87 __attribute__ ((__format__ (__printf__
, 3, 4)));
89 int ul_path_read_s32(struct path_cxt
*pc
, int32_t *res
, const char *path
);
90 int ul_path_readf_s32(struct path_cxt
*pc
, int32_t *res
, const char *path
, ...)
91 __attribute__ ((__format__ (__printf__
, 3, 4)));
93 int ul_path_read_u64(struct path_cxt
*pc
, uint64_t *res
, const char *path
);
94 int ul_path_readf_u64(struct path_cxt
*pc
, uint64_t *res
, const char *path
, ...)
95 __attribute__ ((__format__ (__printf__
, 3, 4)));
97 int ul_path_read_s64(struct path_cxt
*pc
, int64_t *res
, const char *path
);
98 int ul_path_readf_s64(struct path_cxt
*pc
, int64_t *res
, const char *path
, ...)
99 __attribute__ ((__format__ (__printf__
, 3, 4)));
101 int ul_path_write_string(struct path_cxt
*pc
, const char *str
, const char *path
);
102 int ul_path_writef_string(struct path_cxt
*pc
, const char *str
, const char *path
, ...)
103 __attribute__ ((__format__ (__printf__
, 3, 4)));
105 int ul_path_write_u64(struct path_cxt
*pc
, uint64_t num
, const char *path
);
106 int ul_path_writef_u64(struct path_cxt
*pc
, uint64_t num
, const char *path
, ...)
107 __attribute__ ((__format__ (__printf__
, 3, 4)));
109 int ul_path_count_dirents(struct path_cxt
*pc
, const char *path
);
110 int ul_path_countf_dirents(struct path_cxt
*pc
, const char *path
, ...)
111 __attribute__ ((__format__ (__printf__
, 2, 3)));
115 #ifdef HAVE_CPU_SET_T
117 int ul_path_readf_cpuset(struct path_cxt
*pc
, cpu_set_t
**set
, int maxcpus
, const char *path
, ...)
118 __attribute__ ((__format__ (__printf__
, 4, 5)));
120 int ul_path_readf_cpulist(struct path_cxt
*pc
, cpu_set_t
**set
, int maxcpus
, const char *path
, ...)
121 __attribute__ ((__format__ (__printf__
, 4, 5)));
122 #endif /* HAVE_CPU_SET_T */
123 #endif /* UTIL_LINUX_PATH_H */