]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/path.h
include/path: make sure PATH_MAX is defined
[thirdparty/util-linux.git] / include / path.h
CommitLineData
e21e6d26
KZ
1#ifndef UTIL_LINUX_PATH_H
2#define UTIL_LINUX_PATH_H
3
8148217b 4#include <stdio.h>
37a5c7ee 5#include <stdint.h>
1ed21c80
KZ
6#include <stdint.h>
7#include <sys/types.h>
8#include <dirent.h>
9
2cb147e0
KZ
10#include "c.h"
11
1ed21c80
KZ
12struct path_cxt {
13 int dir_fd;
14 char *dir_path;
15
16 int refcount;
17
18 char *prefix;
19 char path_buffer[PATH_MAX];
20
21 void *dialect;
22 void (*free_dialect)(struct path_cxt *);
23 int (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
24};
25
83bbeb77 26struct path_cxt *ul_new_path(const char *dir, ...);
1ed21c80
KZ
27void ul_unref_path(struct path_cxt *pc);
28void ul_ref_path(struct path_cxt *pc);
29
bcf445fd
KZ
30void ul_path_init_debug(void);
31
1ed21c80
KZ
32int ul_path_set_prefix(struct path_cxt *pc, const char *prefix);
33const char *ul_path_get_prefix(struct path_cxt *pc);
34
35int ul_path_set_dir(struct path_cxt *pc, const char *dir);
36const char *ul_path_get_dir(struct path_cxt *pc);
37
38int ul_path_set_dialect(struct path_cxt *pc, void *data, void free_data(struct path_cxt *));
39void *ul_path_get_dialect(struct path_cxt *pc);
40
41int ul_path_set_enoent_redirect(struct path_cxt *pc, int (*func)(struct path_cxt *, const char *, int *));
42int ul_path_get_dirfd(struct path_cxt *pc);
43
e74e5401
KZ
44char *ul_path_get_abspath(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
45 __attribute__ ((__format__ (__printf__, 4, 5)));
46
1ed21c80
KZ
47int ul_path_access(struct path_cxt *pc, int mode, const char *path);
48int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
49 __attribute__ ((__format__ (__printf__, 3, 4)));
50
51int ul_path_open(struct path_cxt *pc, int flags, const char *path);
52int ul_path_openf(struct path_cxt *pc, int flags, const char *path, ...)
53 __attribute__ ((__format__ (__printf__, 3, 4)));
54int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap);
55
56FILE *ul_path_fopen(struct path_cxt *pc, const char *mode, const char *path);
57FILE *ul_path_fopenf(struct path_cxt *pc, const char *mode, const char *path, ...)
58 __attribute__ ((__format__ (__printf__, 3, 4)));
59FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap);
60
61DIR *ul_path_opendir(struct path_cxt *pc, const char *path);
62DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap);
63DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
64 __attribute__ ((__format__ (__printf__, 2, 3)));
65
66ssize_t ul_path_readlink(struct path_cxt *pc, char *buf, size_t bufsiz, const char *path);
67ssize_t ul_path_readlinkf(struct path_cxt *pc, char *buf, size_t bufsiz, const char *path, ...)
68 __attribute__ ((__format__ (__printf__, 4, 5)));
69
70int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path);
71int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap);
72int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path, ...)
73 __attribute__ ((__format__ (__printf__, 4, 5)));
74
75int ul_path_read_string(struct path_cxt *pc, char **str, const char *path);
76int ul_path_readf_string(struct path_cxt *pc, char **str, const char *path, ...)
77 __attribute__ ((__format__ (__printf__, 3, 4)));
78
7eb8e47b
KZ
79int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path);
80int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
81 __attribute__ ((__format__ (__printf__, 4, 5)));
82
1ed21c80
KZ
83int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...);
84int ul_path_scanff(struct path_cxt *pc, const char *path, va_list ap, const char *fmt, ...)
85 __attribute__ ((__format__ (__scanf__, 4, 5)));
86
87int ul_path_read_majmin(struct path_cxt *pc, dev_t *res, const char *path);
88int ul_path_readf_majmin(struct path_cxt *pc, dev_t *res, const char *path, ...)
89 __attribute__ ((__format__ (__printf__, 3, 4)));
90
91int ul_path_read_u32(struct path_cxt *pc, uint32_t *res, const char *path);
92int ul_path_readf_u32(struct path_cxt *pc, uint32_t *res, const char *path, ...)
93 __attribute__ ((__format__ (__printf__, 3, 4)));
94
95int ul_path_read_s32(struct path_cxt *pc, int32_t *res, const char *path);
96int ul_path_readf_s32(struct path_cxt *pc, int32_t *res, const char *path, ...)
97 __attribute__ ((__format__ (__printf__, 3, 4)));
98
99int ul_path_read_u64(struct path_cxt *pc, uint64_t *res, const char *path);
100int ul_path_readf_u64(struct path_cxt *pc, uint64_t *res, const char *path, ...)
101 __attribute__ ((__format__ (__printf__, 3, 4)));
102
103int ul_path_read_s64(struct path_cxt *pc, int64_t *res, const char *path);
104int ul_path_readf_s64(struct path_cxt *pc, int64_t *res, const char *path, ...)
105 __attribute__ ((__format__ (__printf__, 3, 4)));
106
107int ul_path_write_string(struct path_cxt *pc, const char *str, const char *path);
108int ul_path_writef_string(struct path_cxt *pc, const char *str, const char *path, ...)
109 __attribute__ ((__format__ (__printf__, 3, 4)));
110
111int ul_path_write_u64(struct path_cxt *pc, uint64_t num, const char *path);
112int ul_path_writef_u64(struct path_cxt *pc, uint64_t num, const char *path, ...)
113 __attribute__ ((__format__ (__printf__, 3, 4)));
114
115int ul_path_count_dirents(struct path_cxt *pc, const char *path);
116int ul_path_countf_dirents(struct path_cxt *pc, const char *path, ...)
117 __attribute__ ((__format__ (__printf__, 2, 3)));
118
9023b201 119FILE *ul_prefix_fopen(const char *prefix, const char *path, const char *mode);
8148217b 120
e21e6d26
KZ
121
122#ifdef HAVE_CPU_SET_T
123# include "cpuset.h"
1ed21c80
KZ
124int ul_path_readf_cpuset(struct path_cxt *pc, cpu_set_t **set, int maxcpus, const char *path, ...)
125 __attribute__ ((__format__ (__printf__, 4, 5)));
e21e6d26 126
1ed21c80
KZ
127int ul_path_readf_cpulist(struct path_cxt *pc, cpu_set_t **set, int maxcpus, const char *path, ...)
128 __attribute__ ((__format__ (__printf__, 4, 5)));
e21e6d26 129#endif /* HAVE_CPU_SET_T */
e21e6d26 130#endif /* UTIL_LINUX_PATH_H */