]>
git.ipfire.org Git - thirdparty/kmod.git/blob - libkmod/libkmod-util.h
12 char *getline_wrapped(FILE *fp
, unsigned int *linenum
) __attribute__((nonnull(1)));
13 #define streq(a, b) (strcmp((a), (b)) == 0)
14 #define strstartswith(a, b) (strncmp(a, b, strlen(b)) == 0)
15 void *memdup(const void *p
, size_t n
) __attribute__((nonnull(1)));
17 ssize_t
read_str_safe(int fd
, char *buf
, size_t buflen
) _must_check_
__attribute__((nonnull(2)));
18 ssize_t
write_str_safe(int fd
, const char *buf
, size_t buflen
) __attribute__((nonnull(2)));
19 int read_str_long(int fd
, long *value
, int base
) _must_check_
__attribute__((nonnull(2)));
20 int read_str_ulong(int fd
, unsigned long *value
, int base
) _must_check_
__attribute__((nonnull(2)));
21 char *strchr_replace(char *s
, int c
, char r
);
22 bool path_is_absolute(const char *p
) _must_check_
__attribute__((nonnull(1)));
23 char *path_make_absolute_cwd(const char *p
) _must_check_
__attribute__((nonnull(1)));
24 int mkdir_p(const char *path
, int len
, mode_t mode
);
25 int mkdir_parents(const char *path
, mode_t mode
);
26 int alias_normalize(const char *alias
, char buf
[PATH_MAX
], size_t *len
) _must_check_
__attribute__((nonnull(1,2)));
27 char *modname_normalize(const char *modname
, char buf
[PATH_MAX
], size_t *len
) __attribute__((nonnull(1, 2)));
28 char *path_to_modname(const char *path
, char buf
[PATH_MAX
], size_t *len
) __attribute__((nonnull(2)));
30 extern const struct kmod_ext
{
34 #define KMOD_EXT_UNC 0
35 bool path_ends_with_kmod_ext(const char *path
, size_t len
) __attribute__((nonnull(1)));
37 unsigned long long stat_mstamp(const struct stat
*st
);
38 unsigned long long ts_usec(const struct timespec
*ts
);
40 #define get_unaligned(ptr) \
42 struct __attribute__((packed)) { \
44 } *__p = (typeof(__p)) (ptr); \
48 #define put_unaligned(val, ptr) \
50 struct __attribute__((packed)) { \
52 } *__p = (typeof(__p)) (ptr); \
56 static _always_inline_
unsigned int ALIGN_POWER2(unsigned int u
)
58 return 1 << ((sizeof(u
) * 8) - __builtin_clz(u
- 1));
61 static inline void freep(void *p
) {
65 #define _cleanup_free_ _cleanup_(freep)