#define _cleanup_kmod_module_dependency_symbols_free_list_ _cleanup_(kmod_module_dependency_symbols_free_listp)
-static inline void fts_closep(FTS ** p)
+static inline void fts_closep(FTS **p)
{
if (*p)
fts_close(*p);
goto normal_copy;
dest_desc =
- open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
- (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
+ open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
+ (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
if (dest_desc < 0) {
goto normal_copy;
use_clone = false;
}
- normal_copy:
+normal_copy:
pid = fork();
if (pid == 0) {
if (geteuid() == 0 && no_xattr == false)
ret = -1;
if (geteuid() == 0 && no_xattr == false)
log_error
- ("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s",
- src, dst);
+ ("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s",
+ src, dst);
else
log_error
- ("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s",
- src, dst);
+ ("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s",
+ src, dst);
break;
}
}
log_error("Could not append '%s' to logfile '%s': %m", path, logfile);
}
-static bool check_hashmap(Hashmap * hm, const char *item)
+static bool check_hashmap(Hashmap *hm, const char *item)
{
char *existing;
existing = hashmap_get(hm, item);
_cleanup_free_ char *absdestpath = NULL;
ret =
- asprintf(&absdestpath, "%s/%s", destrootdir,
- (abspath[0] == '/' ? (abspath + 1) : abspath) + sysrootdirlen);
+ asprintf(&absdestpath, "%s/%s", destrootdir,
+ (abspath[0] == '/' ? (abspath + 1) : abspath) + sysrootdirlen);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
for (j = 0; j < globbuf.gl_pathc; j++) {
char *dest = strdup(globbuf.gl_pathv[j] + sysrootdirlen);
ret |=
- dracut_install(globbuf.gl_pathv[j] + sysrootdirlen, dest,
- arg_createdir, arg_resolvedeps, true);
+ dracut_install(globbuf.gl_pathv[j] + sysrootdirlen, dest,
+ arg_createdir, arg_resolvedeps, true);
free(dest);
}
}
char *paths[] = { "/sys/devices", NULL };
fts = fts_open(paths, FTS_NOCHDIR | FTS_NOSTAT, NULL);
}
- for (FTSENT * ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
+ for (FTSENT *ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_kmod_module_unref_list_ struct kmod_list *list = NULL;
struct kmod_list *l;
fts = fts_open(paths, FTS_COMFOLLOW | FTS_NOCHDIR | FTS_NOSTAT | FTS_LOGICAL, NULL);
}
- for (FTSENT * ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
+ for (FTSENT *ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) {
_cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL;
_cleanup_free_ const char *modname = NULL;
if (arg_optional)
r = EXIT_SUCCESS;
- finish:
+finish:
if (logfile_f)
fclose(logfile_f);
return h;
}
-int hashmap_ensure_allocated(Hashmap ** h, hash_func_t hash_func, compare_func_t compare_func)
+int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func)
{
assert(h);
return 0;
}
-static void link_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash)
+static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
{
assert(h);
assert(e);
assert(h->n_entries >= 1);
}
-static void unlink_entry(Hashmap * h, struct hashmap_entry *e, unsigned hash)
+static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
{
assert(h);
assert(e);
h->n_entries--;
}
-static void remove_entry(Hashmap * h, struct hashmap_entry **ep)
+static void remove_entry(Hashmap *h, struct hashmap_entry **ep)
{
struct hashmap_entry *e = *ep;
unsigned hash;
*ep = NULL;
}
-void hashmap_free(Hashmap * h)
+void hashmap_free(Hashmap *h)
{
if (!h)
free(h);
}
-void hashmap_free_free(Hashmap * h)
+void hashmap_free_free(Hashmap *h)
{
void *p;
hashmap_free(h);
}
-void hashmap_clear(Hashmap * h)
+void hashmap_clear(Hashmap *h)
{
if (!h)
return;
}
}
-static struct hashmap_entry *hash_scan(Hashmap * h, unsigned hash, const void *key)
+static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key)
{
struct hashmap_entry *e;
assert(h);
return NULL;
}
-int hashmap_put(Hashmap * h, const void *key, void *value)
+int hashmap_put(Hashmap *h, const void *key, void *value)
{
struct hashmap_entry *e;
unsigned hash;
return 1;
}
-int hashmap_replace(Hashmap * h, const void *key, void *value)
+int hashmap_replace(Hashmap *h, const void *key, void *value)
{
struct hashmap_entry *e;
unsigned hash;
return hashmap_put(h, key, value);
}
-void *hashmap_get(Hashmap * h, const void *key)
+void *hashmap_get(Hashmap *h, const void *key)
{
unsigned hash;
struct hashmap_entry *e;
return e->value;
}
-void *hashmap_remove(Hashmap * h, const void *key)
+void *hashmap_remove(Hashmap *h, const void *key)
{
struct hashmap_entry *e;
unsigned hash;
return data;
}
-int hashmap_remove_and_put(Hashmap * h, const void *old_key, const void *new_key, void *value)
+int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value)
{
struct hashmap_entry *e;
unsigned old_hash, new_hash;
return 0;
}
-int hashmap_remove_and_replace(Hashmap * h, const void *old_key, const void *new_key, void *value)
+int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value)
{
struct hashmap_entry *e, *k;
unsigned old_hash, new_hash;
return 0;
}
-void *hashmap_remove_value(Hashmap * h, const void *key, void *value)
+void *hashmap_remove_value(Hashmap *h, const void *key, void *value)
{
struct hashmap_entry *e;
unsigned hash;
return value;
}
-void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key)
+void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key)
{
struct hashmap_entry *e;
return e->value;
- at_end:
+at_end:
*i = ITERATOR_LAST;
if (key)
return NULL;
}
-void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key)
+void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key)
{
struct hashmap_entry *e;
return e->value;
- at_beginning:
+at_beginning:
*i = ITERATOR_FIRST;
if (key)
return NULL;
}
-void *hashmap_iterate_skip(Hashmap * h, const void *key, Iterator * i)
+void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i)
{
unsigned hash;
struct hashmap_entry *e;
return e->value;
}
-void *hashmap_first(Hashmap * h)
+void *hashmap_first(Hashmap *h)
{
if (!h)
return h->iterate_list_head->value;
}
-void *hashmap_first_key(Hashmap * h)
+void *hashmap_first_key(Hashmap *h)
{
if (!h)
return (void *)h->iterate_list_head->key;
}
-void *hashmap_last(Hashmap * h)
+void *hashmap_last(Hashmap *h)
{
if (!h)
return h->iterate_list_tail->value;
}
-void *hashmap_steal_first(Hashmap * h)
+void *hashmap_steal_first(Hashmap *h)
{
struct hashmap_entry *e;
void *data;
return data;
}
-void *hashmap_steal_first_key(Hashmap * h)
+void *hashmap_steal_first_key(Hashmap *h)
{
struct hashmap_entry *e;
void *key;
return key;
}
-unsigned hashmap_size(Hashmap * h)
+unsigned hashmap_size(Hashmap *h)
{
if (!h)
return h->n_entries;
}
-bool hashmap_isempty(Hashmap * h)
+bool hashmap_isempty(Hashmap *h)
{
if (!h)
return h->n_entries == 0;
}
-int hashmap_merge(Hashmap * h, Hashmap * other)
+int hashmap_merge(Hashmap *h, Hashmap *other)
{
struct hashmap_entry *e;
return 0;
}
-void hashmap_move(Hashmap * h, Hashmap * other)
+void hashmap_move(Hashmap *h, Hashmap *other)
{
struct hashmap_entry *e, *n;
}
}
-int hashmap_move_one(Hashmap * h, Hashmap * other, const void *key)
+int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key)
{
unsigned h_hash, other_hash;
struct hashmap_entry *e;
return 0;
}
-char **hashmap_get_strv(Hashmap * h)
+char **hashmap_get_strv(Hashmap *h)
{
char **sv;
Iterator it;
int trivial_compare_func(const void *a, const void *b);
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
-void hashmap_free(Hashmap * h);
-void hashmap_free_free(Hashmap * h);
-int hashmap_ensure_allocated(Hashmap ** h, hash_func_t hash_func, compare_func_t compare_func);
-
-int hashmap_put(Hashmap * h, const void *key, void *value);
-int hashmap_replace(Hashmap * h, const void *key, void *value);
-void *hashmap_get(Hashmap * h, const void *key);
-void *hashmap_remove(Hashmap * h, const void *key);
-void *hashmap_remove_value(Hashmap * h, const void *key, void *value);
-int hashmap_remove_and_put(Hashmap * h, const void *old_key, const void *new_key, void *value);
-int hashmap_remove_and_replace(Hashmap * h, const void *old_key, const void *new_key, void *value);
-
-int hashmap_merge(Hashmap * h, Hashmap * other);
-void hashmap_move(Hashmap * h, Hashmap * other);
-int hashmap_move_one(Hashmap * h, Hashmap * other, const void *key);
-
-unsigned hashmap_size(Hashmap * h);
-bool hashmap_isempty(Hashmap * h);
-
-void *hashmap_iterate(Hashmap * h, Iterator * i, const void **key);
-void *hashmap_iterate_backwards(Hashmap * h, Iterator * i, const void **key);
-void *hashmap_iterate_skip(Hashmap * h, const void *key, Iterator * i);
-
-void hashmap_clear(Hashmap * h);
-void *hashmap_steal_first(Hashmap * h);
-void *hashmap_steal_first_key(Hashmap * h);
-void *hashmap_first(Hashmap * h);
-void *hashmap_first_key(Hashmap * h);
-void *hashmap_last(Hashmap * h);
-
-char **hashmap_get_strv(Hashmap * h);
+void hashmap_free(Hashmap *h);
+void hashmap_free_free(Hashmap *h);
+int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func);
+
+int hashmap_put(Hashmap *h, const void *key, void *value);
+int hashmap_replace(Hashmap *h, const void *key, void *value);
+void *hashmap_get(Hashmap *h, const void *key);
+void *hashmap_remove(Hashmap *h, const void *key);
+void *hashmap_remove_value(Hashmap *h, const void *key, void *value);
+int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value);
+int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value);
+
+int hashmap_merge(Hashmap *h, Hashmap *other);
+void hashmap_move(Hashmap *h, Hashmap *other);
+int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);
+
+unsigned hashmap_size(Hashmap *h);
+bool hashmap_isempty(Hashmap *h);
+
+void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key);
+void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key);
+void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i);
+
+void hashmap_clear(Hashmap *h);
+void *hashmap_steal_first(Hashmap *h);
+void *hashmap_steal_first_key(Hashmap *h);
+void *hashmap_first(Hashmap *h);
+void *hashmap_first_key(Hashmap *h);
+void *hashmap_last(Hashmap *h);
+
+char **hashmap_get_strv(Hashmap *h);
#define HASHMAP_FOREACH(e, h, i) \
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), NULL); (e); (e) = hashmap_iterate((h), &(i), NULL))
} \
} while(false)
- /* Because statfs.t_type can be int on some architecures, we have to cast
- * the const magic to the type, otherwise the compiler warns about
- * signed/unsigned comparison, because the magic can be 32 bit unsigned.
- */
+/* Because statfs.t_type can be int on some architecures, we have to cast
+ * the const magic to the type, otherwise the compiler warns about
+ * signed/unsigned comparison, because the magic can be 32 bit unsigned.
+ */
#define F_TYPE_CMP(a, b) (a == (typeof(a)) b)
/* Returns the number of chars needed to format variables of the
return a;
- fail:
+fail:
strv_free(a);
return NULL;
}
*k = NULL;
return r;
- fail:
+fail:
strv_free(r);
return NULL;
}
*k = NULL;
return r;
- fail:
+fail:
strv_free(r);
return NULL;
k[1] = NULL;
return r;
- fail:
+fail:
strv_free(r);
return NULL;
}
*(t++) = ' ';
break;
- case 'x':{
- /* hexadecimal encoding */
- int a, b;
-
- a = unhexchar(f[1]);
- b = unhexchar(f[2]);
-
- if (a < 0 || b < 0) {
- /* Invalid escape code, let's take it literal then */
- *(t++) = '\\';
- *(t++) = 'x';
- } else {
- *(t++) = (char)((a << 4) | b);
- f += 2;
- }
-
- break;
+ case 'x': {
+ /* hexadecimal encoding */
+ int a, b;
+
+ a = unhexchar(f[1]);
+ b = unhexchar(f[2]);
+
+ if (a < 0 || b < 0) {
+ /* Invalid escape code, let's take it literal then */
+ *(t++) = '\\';
+ *(t++) = 'x';
+ } else {
+ *(t++) = (char)((a << 4) | b);
+ f += 2;
}
+ break;
+ }
+
case '0':
case '1':
case '2':
case '4':
case '5':
case '6':
- case '7':{
- /* octal encoding */
- int a, b, c;
-
- a = unoctchar(f[0]);
- b = unoctchar(f[1]);
- c = unoctchar(f[2]);
-
- if (a < 0 || b < 0 || c < 0) {
- /* Invalid escape code, let's take it literal then */
- *(t++) = '\\';
- *(t++) = f[0];
- } else {
- *(t++) = (char)((a << 6) | (b << 3) | c);
- f += 2;
- }
-
- break;
+ case '7': {
+ /* octal encoding */
+ int a, b, c;
+
+ a = unoctchar(f[0]);
+ b = unoctchar(f[1]);
+ c = unoctchar(f[2]);
+
+ if (a < 0 || b < 0 || c < 0) {
+ /* Invalid escape code, let's take it literal then */
+ *(t++) = '\\';
+ *(t++) = f[0];
+ } else {
+ *(t++) = (char)((a << 6) | (b << 3) | c);
+ f += 2;
}
+ break;
+ }
+
case 0:
/* premature end of string. */
*(t++) = '\\';
}
}
- finish:
+finish:
*t = 0;
return r;
}
usec_t now(clockid_t clock);
-dual_timestamp *dual_timestamp_get(dual_timestamp * ts);
-dual_timestamp *dual_timestamp_from_realtime(dual_timestamp * ts, usec_t u);
+dual_timestamp *dual_timestamp_get(dual_timestamp *ts);
+dual_timestamp *dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
#define dual_timestamp_is_set(ts) ((ts)->realtime > 0)
void close_many(const int fds[], unsigned n_fd);
int parse_boolean(const char *v);
-int parse_usec(const char *t, usec_t * usec);
-int parse_nsec(const char *t, nsec_t * nsec);
-int parse_bytes(const char *t, off_t * bytes);
-int parse_pid(const char *s, pid_t * ret_pid);
-int parse_uid(const char *s, uid_t * ret_uid);
+int parse_usec(const char *t, usec_t *usec);
+int parse_nsec(const char *t, nsec_t *nsec);
+int parse_bytes(const char *t, off_t *bytes);
+int parse_pid(const char *s, pid_t *ret_pid);
+int parse_uid(const char *s, uid_t *ret_uid);
#define parse_gid(s, ret_uid) parse_uid(s, ret_uid)
int safe_atou(const char *s, unsigned *ret_u);
}
#endif
-static inline int safe_atou32(const char *s, uint32_t * ret_u)
+static inline int safe_atou32(const char *s, uint32_t *ret_u)
{
assert_cc(sizeof(uint32_t) == sizeof(unsigned));
return safe_atou(s, (unsigned *)ret_u);
}
-static inline int safe_atoi32(const char *s, int32_t * ret_i)
+static inline int safe_atoi32(const char *s, int32_t *ret_i)
{
assert_cc(sizeof(int32_t) == sizeof(int));
return safe_atoi(s, (int *)ret_i);
}
-static inline int safe_atou64(const char *s, uint64_t * ret_u)
+static inline int safe_atou64(const char *s, uint64_t *ret_u)
{
assert_cc(sizeof(uint64_t) == sizeof(unsigned long long));
return safe_atollu(s, (unsigned long long *)ret_u);
}
-static inline int safe_atoi64(const char *s, int64_t * ret_i)
+static inline int safe_atoi64(const char *s, int64_t *ret_i)
{
assert_cc(sizeof(int64_t) == sizeof(long long int));
return safe_atolli(s, (long long int *)ret_i);
#define FOREACH_WORD_QUOTED(word, length, s, state) \
for ((state) = NULL, (word) = split_quoted((s), &(length), &(state)); (word); (word) = split_quoted((s), &(length), &(state)))
-pid_t get_parent_of_pid(pid_t pid, pid_t * ppid);
+pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
int get_starttime_of_pid(pid_t pid, unsigned long long *st);
int write_one_line_file(const char *fn, const char *line);
int get_process_comm(pid_t pid, char **name);
int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
int get_process_exe(pid_t pid, char **name);
-int get_process_uid(pid_t pid, uid_t * uid);
+int get_process_uid(pid_t pid, uid_t *uid);
char hexchar(int x);
int unhexchar(char c);
int chvt(int vt);
-int read_one_char(FILE * f, char *ret, usec_t timeout, bool *need_nl);
+int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
int ask(char *ret, const char *replies, const char *text, ...);
int reset_terminal_fd(int fd, bool switch_to_text);
int sigaction_many(const struct sigaction *sa, ...);
int close_pipe(int p[]);
-int fopen_temporary(const char *path, FILE ** _f, char **_temp_path);
+int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
void rename_process(const char name[8]);
-void sigset_add_many(sigset_t * ss, ...);
+void sigset_add_many(sigset_t *ss, ...);
char *gethostname_malloc(void);
bool hostname_is_set(void);
int getttyname_malloc(int fd, char **r);
int getttyname_harder(int fd, char **r);
-int get_ctty_devnr(pid_t pid, dev_t * d);
-int get_ctty(pid_t, dev_t * _devnr, char **r);
+int get_ctty_devnr(pid_t pid, dev_t *d);
+int get_ctty(pid_t, dev_t *_devnr, char **r);
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid);
char *unquote(const char *s, const char *quotes);
char *normalize_env_assignment(const char *s);
-int wait_for_terminate(pid_t pid, siginfo_t * status);
+int wait_for_terminate(pid_t pid, siginfo_t *status);
int wait_for_terminate_and_warn(const char *name, pid_t pid);
_noreturn_ void freeze(void);
DIR *xopendirat(int dirfd, const char *name, int flags);
-void dual_timestamp_serialize(FILE * f, const char *name, dual_timestamp * t);
-void dual_timestamp_deserialize(const char *value, dual_timestamp * t);
+void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
+void dual_timestamp_deserialize(const char *value, dual_timestamp *t);
char *fstab_node_to_udev_node(const char *p);
int vtnr_from_tty(const char *tty);
const char *default_term_for_tty(const char *tty);
-void execute_directory(const char *directory, DIR * _d, char *argv[]);
+void execute_directory(const char *directory, DIR *_d, char *argv[]);
int kill_and_sigcont(pid_t pid, int sig);
bool display_is_local(const char *display);
int socket_from_display(const char *display, char **path);
-int get_user_creds(const char **username, uid_t * uid, gid_t * gid, const char **home);
-int get_group_creds(const char **groupname, gid_t * gid);
+int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home);
+int get_group_creds(const char **groupname, gid_t *gid);
int in_group(const char *name);
int glob_exists(const char *path);
-int dirent_ensure_type(DIR * d, struct dirent *de);
+int dirent_ensure_type(DIR *d, struct dirent *de);
int in_search_path(const char *path, char **search);
int get_files_in_directory(const char *path, char ***list);
bool in_charset(const char *s, const char *charset);
-int block_get_whole_disk(dev_t d, dev_t * ret);
+int block_get_whole_disk(dev_t d, dev_t *ret);
int file_is_priv_sticky(const char *p);
free(*(void **)p);
}
-static inline void fclosep(FILE ** f)
+static inline void fclosep(FILE **f)
{
if (*f)
fclose(*f);
}
-static inline void pclosep(FILE ** f)
+static inline void pclosep(FILE **f)
{
if (*f)
pclose(*f);
close_nointr_nofail(*fd);
}
-static inline void closedirp(DIR ** d)
+static inline void closedirp(DIR **d)
{
if (*d)
closedir(*d);
}
-static inline void umaskp(mode_t * u)
+static inline void umaskp(mode_t *u)
{
umask(*u);
}
int fd_inc_sndbuf(int fd, size_t n);
int fd_inc_rcvbuf(int fd, size_t n);
-int fork_agent(pid_t * pid, const int except[], unsigned n_except, const char *path, ...);
+int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...);
int setrlimit_closest(int resource, const struct rlimit *rlim);
int timeout;
char *timeout_env;
struct pollfd fds[] = { {
- .fd = STDIN_FILENO,
- .events = POLLIN | POLLERR,
- }
+ .fd = STDIN_FILENO,
+ .events = POLLIN | POLLERR,
+ }
};
timeout_env = getenv("LOGTEE_TIMEOUT_MS");