From 2705eaf36d46539397571886ba6ccd0045ef3e9b Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Tue, 11 Apr 2017 17:05:07 +0200 Subject: [PATCH] Prep v228: Substitute declaration masks (1/4) Although it looks very ugly, substitute all declaration masks of the form: // UNNEEDED type foo(...); with: /// UNNEEDED by elogind #if 0 type foo(...); #endif // 0 to make future merging of upstream pathes easier, as the relevant lines themselves are not changed any more. --- src/basic/capability-util.h | 14 +++--- src/basic/cgroup-util.h | 93 +++++++++++++++++++++---------------- src/basic/copy.c | 4 +- src/basic/copy.h | 22 +++++---- src/basic/errno-list.h | 5 +- src/basic/extract-word.h | 7 ++- src/basic/fd-util.h | 14 ++++-- src/basic/fileio-label.h | 10 ++-- src/basic/fileio.h | 27 +++++++---- src/basic/fs-util.h | 40 +++++++++------- src/basic/hashmap.h | 7 +-- src/basic/hostname-util.h | 22 ++++++--- src/basic/label.h | 33 +++++++++++++ src/basic/log.h | 18 +++++-- 14 files changed, 208 insertions(+), 108 deletions(-) create mode 100644 src/basic/label.h diff --git a/src/basic/capability-util.h b/src/basic/capability-util.h index 3f6c988f6..d835e3f20 100644 --- a/src/basic/capability-util.h +++ b/src/basic/capability-util.h @@ -27,16 +27,16 @@ #include "util.h" unsigned long cap_last_cap(void); -// UNNEEDED int have_effective_cap(int value); -// UNNEEDED int capability_bounding_set_drop(uint64_t drop, bool right_now); -// UNNEEDED int capability_bounding_set_drop_usermode(uint64_t drop); +/// UNNEEDED by elogind +#if 0 +int have_effective_cap(int value); +int capability_bounding_set_drop(uint64_t drop, bool right_now); +int capability_bounding_set_drop_usermode(uint64_t drop); -// UNNEEDED int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities); +int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities); -// UNNEEDED int drop_capability(cap_value_t cv); +int drop_capability(cap_value_t cv); -/// UNNEEDED by elogind -#if 0 DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free); #define _cleanup_cap_free_ _cleanup_(cap_freep) diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index b82f2a896..6fd772748 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -125,11 +125,13 @@ int cg_attach_fallback(const char *controller, const char *path, pid_t pid); int cg_create_and_attach(const char *controller, const char *path, pid_t pid); int cg_set_attribute(const char *controller, const char *path, const char *attribute, const char *value); -// UNNEEDED int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret); - -// UNNEEDED int cg_set_group_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid); -// UNNEEDED int cg_set_task_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid); +/// UNNEEDED by elogind +#if 0 +int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret); +int cg_set_group_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid); +int cg_set_task_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid); +#endif // 0 int cg_install_release_agent(const char *controller, const char *agent); int cg_uninstall_release_agent(const char *controller); @@ -139,54 +141,65 @@ int cg_is_empty_recursive(const char *controller, const char *path); int cg_get_root_path(char **path); int cg_path_get_session(const char *path, char **session); -// UNNEEDED int cg_path_get_owner_uid(const char *path, uid_t *uid); -// UNNEEDED int cg_path_get_unit(const char *path, char **unit); -// UNNEEDED int cg_path_get_user_unit(const char *path, char **unit); -// UNNEEDED int cg_path_get_machine_name(const char *path, char **machine); -// UNNEEDED int cg_path_get_slice(const char *path, char **slice); -// UNNEEDED int cg_path_get_user_slice(const char *path, char **slice); - +/// UNNEEDED by elogind +#if 0 +int cg_path_get_owner_uid(const char *path, uid_t *uid); +int cg_path_get_unit(const char *path, char **unit); +int cg_path_get_user_unit(const char *path, char **unit); +int cg_path_get_machine_name(const char *path, char **machine); +int cg_path_get_slice(const char *path, char **slice); +int cg_path_get_user_slice(const char *path, char **slice); +#endif // 0 int cg_shift_path(const char *cgroup, const char *cached_root, const char **shifted); int cg_pid_get_path_shifted(pid_t pid, const char *cached_root, char **cgroup); int cg_pid_get_session(pid_t pid, char **session); -// UNNEEDED int cg_pid_get_owner_uid(pid_t pid, uid_t *uid); -// UNNEEDED int cg_pid_get_unit(pid_t pid, char **unit); -// UNNEEDED int cg_pid_get_user_unit(pid_t pid, char **unit); -// UNNEEDED int cg_pid_get_machine_name(pid_t pid, char **machine); -// UNNEEDED int cg_pid_get_slice(pid_t pid, char **slice); -// UNNEEDED int cg_pid_get_user_slice(pid_t pid, char **slice); - -// UNNEEDED int cg_path_decode_unit(const char *cgroup, char **unit); - +/// UNNEEDED by elogind +#if 0 +int cg_pid_get_owner_uid(pid_t pid, uid_t *uid); +int cg_pid_get_unit(pid_t pid, char **unit); +int cg_pid_get_user_unit(pid_t pid, char **unit); +int cg_pid_get_machine_name(pid_t pid, char **machine); +int cg_pid_get_slice(pid_t pid, char **slice); +int cg_pid_get_user_slice(pid_t pid, char **slice); + +int cg_path_decode_unit(const char *cgroup, char **unit); +#endif // 0 char *cg_escape(const char *p); char *cg_unescape(const char *p) _pure_; bool cg_controller_is_valid(const char *p); - -// UNNEEDED int cg_slice_to_path(const char *unit, char **ret); - -// UNNEEDED typedef const char* (*cg_migrate_callback_t)(CGroupMask mask, void *userdata); - -// UNNEEDED int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path); -// UNNEEDED int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_migrate_callback_t callback, void *userdata); -// UNNEEDED int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, cg_migrate_callback_t callback, void *userdata); -// UNNEEDED int cg_migrate_everywhere(CGroupMask supported, const char *from, const char *to, cg_migrate_callback_t callback, void *userdata); -// UNNEEDED int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root); -// UNNEEDED int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p); - +/// UNNEEDED by elogind +#if 0 +int cg_slice_to_path(const char *unit, char **ret); + +typedef const char* (*cg_migrate_callback_t)(CGroupMask mask, void *userdata); + +int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path); +int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_migrate_callback_t callback, void *userdata); +int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, cg_migrate_callback_t callback, void *userdata); +int cg_migrate_everywhere(CGroupMask supported, const char *from, const char *to, cg_migrate_callback_t callback, void *userdata); +int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root); +int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p); +#endif // 0 int cg_mask_supported(CGroupMask *ret); - -// UNNEEDED int cg_kernel_controllers(Set *controllers); - +/// UNNEEDED by elogind +#if 0 +int cg_kernel_controllers(Set *controllers); +#endif // 0 int cg_unified(void); -// UNNEEDED void cg_unified_flush(void); +/// UNNEEDED by elogind +#if 0 +void cg_unified_flush(void); -// UNNEEDED bool cg_is_unified_wanted(void); +bool cg_is_unified_wanted(void); +#endif // 0 bool cg_is_legacy_wanted(void); const char* cgroup_controller_to_string(CGroupController c) _const_; CGroupController cgroup_controller_from_string(const char *s) _pure_; - -// UNNEEDED int cg_cpu_shares_parse(const char *s, uint64_t *ret); -// UNNEEDED int cg_blkio_weight_parse(const char *s, uint64_t *ret); +/// UNNEEDED by elogind +#if 0 +int cg_cpu_shares_parse(const char *s, uint64_t *ret); +int cg_blkio_weight_parse(const char *s, uint64_t *ret); +#endif // 0 diff --git a/src/basic/copy.c b/src/basic/copy.c index c5cbbb79f..cff446d9f 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -45,7 +45,7 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) { assert(fdf >= 0); assert(fdt >= 0); -// UNNEEDED by elogind +/// UNNEEDED by elogind #if 0 /* Try btrfs reflinks first. */ if (try_reflink && @@ -129,7 +129,7 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) { return 0; /* return 0 if we hit EOF earlier than the size limit */ } -// UNNEEDED by elogind +/// UNNEEDED by elogind #if 0 static int fd_copy_symlink(int df, const char *from, const struct stat *st, int dt, const char *to) { _cleanup_free_ char *target = NULL; diff --git a/src/basic/copy.h b/src/basic/copy.h index f5d8a1dd8..2cc7ad146 100644 --- a/src/basic/copy.h +++ b/src/basic/copy.h @@ -25,12 +25,18 @@ #include #include -// UNNEEDED int copy_file_fd(const char *from, int to, bool try_reflink); -// UNNEEDED int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags); -// UNNEEDED int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags); -// UNNEEDED int copy_tree(const char *from, const char *to, bool merge); -// UNNEEDED int copy_tree_at(int fdf, const char *from, int fdt, const char *to, bool merge); -// UNNEEDED int copy_directory_fd(int dirfd, const char *to, bool merge); +/// UNNEEDED by elogind +#if 0 +int copy_file_fd(const char *from, int to, bool try_reflink); +int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags); +int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags); +int copy_tree(const char *from, const char *to, bool merge); +int copy_tree_at(int fdf, const char *from, int fdt, const char *to, bool merge); +int copy_directory_fd(int dirfd, const char *to, bool merge); +#endif // 0 int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink); -// UNNEEDED int copy_times(int fdf, int fdt); -// UNNEEDED int copy_xattr(int fdf, int fdt); +/// UNNEEDED by elogind +#if 0 +int copy_times(int fdf, int fdt); +int copy_xattr(int fdf, int fdt); +#endif // 0 diff --git a/src/basic/errno-list.h b/src/basic/errno-list.h index 0b819fc5f..752e139fa 100644 --- a/src/basic/errno-list.h +++ b/src/basic/errno-list.h @@ -24,4 +24,7 @@ const char *errno_to_name(int id); int errno_from_name(const char *name); -// UNNEEDED int errno_max(void); +/// UNNEEDED by elogind +#if 0 +int errno_max(void); +#endif // 0 diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h index eb33224d9..994482582 100644 --- a/src/basic/extract-word.h +++ b/src/basic/extract-word.h @@ -33,5 +33,8 @@ typedef enum ExtractFlags { } ExtractFlags; int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags); -// UNNEEDED int extract_first_word_and_warn(const char **p, char **ret, const char *separators, ExtractFlags flags, const char *unit, const char *filename, unsigned line, const char *rvalue); -// UNNEEDED int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) _sentinel_; +/// UNNEEDED by elogind +#if 0 +int extract_first_word_and_warn(const char **p, char **ret, const char *separators, ExtractFlags flags, const char *unit, const char *filename, unsigned line, const char *rvalue); +int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) _sentinel_; +#endif // 0 diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 0d742b50b..0e03e26b0 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -40,7 +40,10 @@ void close_many(const int fds[], unsigned n_fd); int fclose_nointr(FILE *f); FILE* safe_fclose(FILE *f); -// UNNEEDED DIR* safe_closedir(DIR *f); +/// UNNEEDED by elogind +#if 0 +DIR* safe_closedir(DIR *f); +#endif // 0 static inline void closep(int *fd) { safe_close(*fd); @@ -68,8 +71,11 @@ int fd_cloexec(int fd, bool cloexec); int close_all_fds(const int except[], unsigned n_except); -// UNNEEDED int same_fd(int a, int b); +/// UNNEEDED by elogind +#if 0 +int same_fd(int a, int b); -// UNNEEDED void cmsg_close_all(struct msghdr *mh); +void cmsg_close_all(struct msghdr *mh); -// UNNEEDED bool fdname_is_valid(const char *s); +bool fdname_is_valid(const char *s); +#endif // 0 diff --git a/src/basic/fileio-label.h b/src/basic/fileio-label.h index 81f62050b..9fef650ee 100644 --- a/src/basic/fileio-label.h +++ b/src/basic/fileio-label.h @@ -26,6 +26,10 @@ #include "fileio.h" int write_string_file_atomic_label(const char *fn, const char *line); -// UNNEEDED int write_env_file_label(const char *fname, char **l); -// UNNEEDED int fopen_temporary_label(const char *target, -// UNNEEDED const char *path, FILE **f, char **temp_path); + +/// UNNEEDED by elogind +#if 0 +int write_env_file_label(const char *fname, char **l); +int fopen_temporary_label(const char *target, + const char *path, FILE **f, char **temp_path); +#endif // 0 diff --git a/src/basic/fileio.h b/src/basic/fileio.h index 23b76cdac..f45b0d54a 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -51,16 +51,19 @@ int load_env_file(FILE *f, const char *fname, const char *separator, char ***l); int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l); int write_env_file(const char *fname, char **l); - -// UNNEEDED int executable_is_script(const char *path, char **interpreter); - +/// UNNEEDED by elogind +#if 0 +int executable_is_script(const char *path, char **interpreter); +#endif // 0 int get_proc_field(const char *filename, const char *pattern, const char *terminator, char **field); DIR *xopendirat(int dirfd, const char *name, int flags); int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f); -// UNNEEDED int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f); - +/// UNNEEDED by elogind +#if 0 +int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f); +#endif // 0 #define FOREACH_LINE(line, f, on_error) \ for (;;) \ if (!fgets(line, sizeof(line), f)) { \ @@ -74,11 +77,17 @@ int fflush_and_check(FILE *f); int fopen_temporary(const char *path, FILE **_f, char **_temp_path); int mkostemp_safe(char *pattern, int flags); -// UNNEEDED int open_tmpfile(const char *path, int flags); +/// UNNEEDED by elogind +#if 0 +int open_tmpfile(const char *path, int flags); +#endif // 0 int tempfn_xxxxxx(const char *p, const char *extra, char **ret); int tempfn_random(const char *p, const char *extra, char **ret); -// UNNEEDED int tempfn_random_child(const char *p, const char *extra, char **ret); +/// UNNEEDED by elogind +#if 0 +int tempfn_random_child(const char *p, const char *extra, char **ret); -// UNNEEDED int write_timestamp_file_atomic(const char *fn, usec_t n); -// UNNEEDED int read_timestamp_file(const char *fn, usec_t *ret); +int write_timestamp_file_atomic(const char *fn, usec_t n); +int read_timestamp_file(const char *fn, usec_t *ret); +#endif // 0 diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index d36d2d6aa..55ee990f7 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -30,21 +30,26 @@ #include "time-util.h" int unlink_noerrno(const char *path); +/// UNNEEDED by elogind +#if 0 +int rmdir_parents(const char *path, const char *stop); -// UNNEEDED int rmdir_parents(const char *path, const char *stop); - -// UNNEEDED int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); - +int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); +#endif // 0 int readlinkat_malloc(int fd, const char *p, char **ret); int readlink_malloc(const char *p, char **r); -// UNNEEDED int readlink_value(const char *p, char **ret); -// UNNEEDED int readlink_and_make_absolute(const char *p, char **r); -// UNNEEDED int readlink_and_canonicalize(const char *p, char **r); -// UNNEEDED int readlink_and_make_absolute_root(const char *root, const char *path, char **ret); - +/// UNNEEDED by elogind +#if 0 +int readlink_value(const char *p, char **ret); +int readlink_and_make_absolute(const char *p, char **r); +int readlink_and_canonicalize(const char *p, char **r); +int readlink_and_make_absolute_root(const char *root, const char *path, char **ret); +#endif // 0 int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); -// UNNEEDED int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid); - +/// UNNEEDED by elogind +#if 0 +int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid); +#endif // 0 int fchmod_umask(int fd, mode_t mode); int fd_warn_permissions(const char *path, int fd); @@ -53,13 +58,14 @@ int fd_warn_permissions(const char *path, int fd); int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode); int touch(const char *path); +/// UNNEEDED by elogind +#if 0 +int symlink_idempotent(const char *from, const char *to); -// UNNEEDED int symlink_idempotent(const char *from, const char *to); - -// UNNEEDED int symlink_atomic(const char *from, const char *to); -// UNNEEDED int mknod_atomic(const char *path, mode_t mode, dev_t dev); -// UNNEEDED int mkfifo_atomic(const char *path, mode_t mode); - +int symlink_atomic(const char *from, const char *to); +int mknod_atomic(const char *path, mode_t mode, dev_t dev); +int mkfifo_atomic(const char *path, mode_t mode); +#endif // 0 int get_files_in_directory(const char *path, char ***list); /// UNNEEDED by elogind diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h index 54f60258d..c194575f7 100644 --- a/src/basic/hashmap.h +++ b/src/basic/hashmap.h @@ -368,10 +368,11 @@ static inline void *hashmap_first(Hashmap *h) { static inline void *ordered_hashmap_first(OrderedHashmap *h) { return internal_hashmap_first(HASHMAP_BASE(h)); } - +/// UNNEEDED by elogind +#if 0 /* no hashmap_next */ -// UNNEEDED void *ordered_hashmap_next(OrderedHashmap *h, const void *key); - +void *ordered_hashmap_next(OrderedHashmap *h, const void *key); +#endif // 0 char **internal_hashmap_get_strv(HashmapBase *h); static inline char **hashmap_get_strv(Hashmap *h) { return internal_hashmap_get_strv(HASHMAP_BASE(h)); diff --git a/src/basic/hostname-util.h b/src/basic/hostname-util.h index dd0960e37..6eba0a075 100644 --- a/src/basic/hostname-util.h +++ b/src/basic/hostname-util.h @@ -25,18 +25,26 @@ #include "macro.h" -// UNNEEDED bool hostname_is_set(void); - -// UNNEEDED char* gethostname_malloc(void); +/// UNNEEDED by elogind +#if 0 +bool hostname_is_set(void); +char* gethostname_malloc(void); +#endif // 0 bool hostname_is_valid(const char *s, bool allow_trailing_dot) _pure_; -// UNNEEDED char* hostname_cleanup(char *s); +/// UNNEEDED by elogind +#if 0 +char* hostname_cleanup(char *s); +#endif // 0 #define machine_name_is_valid(s) hostname_is_valid(s, false) bool is_localhost(const char *hostname); -// UNNEEDED bool is_gateway_hostname(const char *hostname); +/// UNNEEDED by elogind +#if 0 +bool is_gateway_hostname(const char *hostname); -// UNNEEDED int sethostname_idempotent(const char *s); +int sethostname_idempotent(const char *s); -// UNNEEDED int read_hostname_config(const char *path, char **hostname); +int read_hostname_config(const char *path, char **hostname); +#endif // 0 diff --git a/src/basic/label.h b/src/basic/label.h new file mode 100644 index 000000000..35feb7c8d --- /dev/null +++ b/src/basic/label.h @@ -0,0 +1,33 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + +#include +#include + +int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs); + +int mkdir_label(const char *path, mode_t mode); +/// UNNEEDED by elogind +#if 0 +int symlink_label(const char *old_path, const char *new_path); +#endif // 0 diff --git a/src/basic/log.h b/src/basic/log.h index e6314e820..4325215b9 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -70,10 +70,15 @@ int log_get_max_level(void) _pure_; int log_open(void); void log_close(void); -// UNNEEDED void log_forget_fds(void); - +/// UNNEEDED by elogind +#if 0 +void log_forget_fds(void); +#endif // 0 void log_close_syslog(void); -// UNNEEDED void log_close_journal(void); +/// UNNEEDED by elogind +#if 0 +void log_close_journal(void); +#endif // 0 void log_close_kmsg(void); void log_close_console(void); @@ -215,9 +220,12 @@ LogTarget log_target_from_string(const char *s) _pure_; #define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__ #define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x) -// UNNEEDED void log_received_signal(int level, const struct signalfd_siginfo *si); +/// UNNEEDED by elogind +#if 0 +void log_received_signal(int level, const struct signalfd_siginfo *si); -// UNNEEDED void log_set_upgrade_syslog_to_journal(bool b); +void log_set_upgrade_syslog_to_journal(bool b); +#endif // 0 int log_syntax_internal( const char *unit, -- 2.30.2