Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 1 | From 414e2f97008a1f3c26a260a6dc4d51a8c1fa6900 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 2 | From: Chen Qi <Qi.Chen@windriver.com> |
| 3 | Date: Fri, 1 Mar 2019 15:22:15 +0800 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 4 | Subject: [PATCH] do not disable buffer in writing files |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 | |
| 6 | Do not disable buffer in writing files, otherwise we get |
| 7 | failure at boot for musl like below. |
| 8 | |
| 9 | [!!!!!!] Failed to allocate manager object. |
| 10 | |
| 11 | And there will be other failures, critical or not critical. |
| 12 | This is specific to musl. |
| 13 | |
| 14 | Upstream-Status: Inappropriate [musl] |
| 15 | |
| 16 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 17 | [Rebased for v242] |
| 18 | Signed-off-by: Andrej Valek <andrej.valek@siemens.com> |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 19 | [rebased for systemd 243] |
| 20 | Signed-off-by: Scott Murray <scott.murray@konsulko.com> |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 21 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | --- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 23 | src/basic/cgroup-util.c | 12 ++++++------ |
| 24 | src/basic/namespace-util.c | 4 ++-- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 25 | src/basic/procfs-util.c | 4 ++-- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 26 | src/basic/sysctl-util.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 27 | src/basic/util.c | 2 +- |
| 28 | src/binfmt/binfmt.c | 6 +++--- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 29 | src/core/cgroup.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 30 | src/core/main.c | 4 ++-- |
| 31 | src/core/smack-setup.c | 8 ++++---- |
| 32 | src/hibernate-resume/hibernate-resume.c | 2 +- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 33 | src/home/homework.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 34 | src/libsystemd/sd-device/sd-device.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | src/nspawn/nspawn-cgroup.c | 2 +- |
| 36 | src/nspawn/nspawn.c | 6 +++--- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 37 | src/shared/binfmt-util.c | 2 +- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 38 | src/shared/cgroup-setup.c | 4 ++-- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 39 | src/shared/coredump-util.c | 2 +- |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 40 | src/shared/smack-util.c | 2 +- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 41 | src/sleep/sleep.c | 8 ++++---- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 42 | src/udev/udev-rules.c | 1 - |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 43 | src/vconsole/vconsole-setup.c | 2 +- |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 44 | 21 files changed, 39 insertions(+), 40 deletions(-) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 45 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 46 | diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 47 | index f4615ffce1..07cb8ed669 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 48 | --- a/src/basic/cgroup-util.c |
| 49 | +++ b/src/basic/cgroup-util.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 50 | @@ -399,7 +399,7 @@ int cg_kill_kernel_sigkill(const char *controller, const char *path) { |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 51 | if (r < 0) |
| 52 | return r; |
| 53 | |
| 54 | - r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 55 | + r = write_string_file(killfile, "1", 0); |
| 56 | if (r < 0) |
| 57 | return r; |
| 58 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 59 | @@ -805,7 +805,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 60 | |
| 61 | sc = strstrip(contents); |
| 62 | if (isempty(sc)) { |
| 63 | - r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 64 | + r = write_string_file(fs, agent, 0); |
| 65 | if (r < 0) |
| 66 | return r; |
| 67 | } else if (!path_equal(sc, agent)) |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 68 | @@ -823,7 +823,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 69 | |
| 70 | sc = strstrip(contents); |
| 71 | if (streq(sc, "0")) { |
| 72 | - r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 73 | + r = write_string_file(fs, "1", 0); |
| 74 | if (r < 0) |
| 75 | return r; |
| 76 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 77 | @@ -850,7 +850,7 @@ int cg_uninstall_release_agent(const char *controller) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 78 | if (r < 0) |
| 79 | return r; |
| 80 | |
| 81 | - r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 82 | + r = write_string_file(fs, "0", 0); |
| 83 | if (r < 0) |
| 84 | return r; |
| 85 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 86 | @@ -860,7 +860,7 @@ int cg_uninstall_release_agent(const char *controller) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 87 | if (r < 0) |
| 88 | return r; |
| 89 | |
| 90 | - r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 91 | + r = write_string_file(fs, "", 0); |
| 92 | if (r < 0) |
| 93 | return r; |
| 94 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 95 | @@ -1730,7 +1730,7 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 96 | if (r < 0) |
| 97 | return r; |
| 98 | |
| 99 | - return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 100 | + return write_string_file(p, value, 0); |
| 101 | } |
| 102 | |
| 103 | int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) { |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 104 | diff --git a/src/basic/namespace-util.c b/src/basic/namespace-util.c |
| 105 | index b9120a5ed0..78e460b75f 100644 |
| 106 | --- a/src/basic/namespace-util.c |
| 107 | +++ b/src/basic/namespace-util.c |
| 108 | @@ -202,12 +202,12 @@ int userns_acquire(const char *uid_map, const char *gid_map) { |
| 109 | freeze(); |
| 110 | |
| 111 | xsprintf(path, "/proc/" PID_FMT "/uid_map", pid); |
| 112 | - r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 113 | + r = write_string_file(path, uid_map, 0); |
| 114 | if (r < 0) |
| 115 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 116 | |
| 117 | xsprintf(path, "/proc/" PID_FMT "/gid_map", pid); |
| 118 | - r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 119 | + r = write_string_file(path, gid_map, 0); |
| 120 | if (r < 0) |
| 121 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 122 | |
| 123 | diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c |
| 124 | index e485a0196b..8bff210356 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 125 | --- a/src/basic/procfs-util.c |
| 126 | +++ b/src/basic/procfs-util.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 127 | @@ -64,13 +64,13 @@ int procfs_tasks_set_limit(uint64_t limit) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 128 | * decrease it, as threads-max is the much more relevant sysctl. */ |
| 129 | if (limit > pid_max-1) { |
| 130 | sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ |
| 131 | - r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 132 | + r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); |
| 133 | if (r < 0) |
| 134 | return r; |
| 135 | } |
| 136 | |
| 137 | sprintf(buffer, "%" PRIu64, limit); |
| 138 | - r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 139 | + r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); |
| 140 | if (r < 0) { |
| 141 | uint64_t threads_max; |
| 142 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 143 | diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c |
| 144 | index b66a6622ae..8d1c93008a 100644 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 145 | --- a/src/basic/sysctl-util.c |
| 146 | +++ b/src/basic/sysctl-util.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 147 | @@ -58,7 +58,7 @@ int sysctl_write(const char *property, const char *value) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 148 | |
| 149 | log_debug("Setting '%s' to '%s'", p, value); |
| 150 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 151 | - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); |
| 152 | + return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 155 | int sysctl_writef(const char *property, const char *format, ...) { |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 156 | diff --git a/src/basic/util.c b/src/basic/util.c |
| 157 | index d7ef382737..31c35118d1 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 158 | --- a/src/basic/util.c |
| 159 | +++ b/src/basic/util.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 160 | @@ -168,7 +168,7 @@ void disable_coredumps(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 161 | if (detect_container() > 0) |
| 162 | return; |
| 163 | |
| 164 | - r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 165 | + r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); |
| 166 | if (r < 0) |
| 167 | log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); |
| 168 | } |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 169 | diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c |
| 170 | index 18231c2618..6c598d55c8 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 171 | --- a/src/binfmt/binfmt.c |
| 172 | +++ b/src/binfmt/binfmt.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 173 | @@ -29,7 +29,7 @@ static bool arg_unregister = false; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 174 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 175 | static int delete_rule(const char *rulename) { |
| 176 | const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 177 | - return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 178 | + return write_string_file(fn, "-1", 0); |
| 179 | } |
| 180 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 181 | static int apply_rule(const char *filename, unsigned line, const char *rule) { |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 182 | @@ -59,7 +59,7 @@ static int apply_rule(const char *filename, unsigned line, const char *rule) { |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 183 | if (r >= 0) |
| 184 | log_debug("%s:%u: Rule '%s' deleted.", filename, line, rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 185 | |
| 186 | - r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 187 | + r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); |
| 188 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 189 | return log_error_errno(r, "%s:%u: Failed to add binary format '%s': %m", |
| 190 | filename, line, rulename); |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 191 | @@ -225,7 +225,7 @@ static int run(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | /* Flush out all rules */ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 195 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 196 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 197 | if (r < 0) |
| 198 | log_warning_errno(r, "Failed to flush binfmt_misc rules, ignoring: %m"); |
| 199 | else |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 200 | diff --git a/src/core/cgroup.c b/src/core/cgroup.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 201 | index 9282b1ff20..7781e0f8eb 100644 |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 202 | --- a/src/core/cgroup.c |
| 203 | +++ b/src/core/cgroup.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 204 | @@ -4182,7 +4182,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) { |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 205 | else |
| 206 | u->freezer_state = FREEZER_THAWING; |
| 207 | |
| 208 | - r = write_string_file(path, one_zero(action == FREEZER_FREEZE), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 209 | + r = write_string_file(path, one_zero(action == FREEZER_FREEZE), 0); |
| 210 | if (r < 0) |
| 211 | return r; |
| 212 | |
| 213 | diff --git a/src/core/main.c b/src/core/main.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 214 | index 409b84a006..b1631e57ce 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 215 | --- a/src/core/main.c |
| 216 | +++ b/src/core/main.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 217 | @@ -1374,7 +1374,7 @@ static int bump_unix_max_dgram_qlen(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 218 | if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN) |
| 219 | return 0; |
| 220 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 221 | - r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, |
| 222 | + r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, |
| 223 | "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 224 | if (r < 0) |
| 225 | return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 226 | @@ -1646,7 +1646,7 @@ static void initialize_core_pattern(bool skip_setup) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 227 | if (getpid_cached() != 1) |
| 228 | return; |
| 229 | |
| 230 | - r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 231 | + r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); |
| 232 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 233 | log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", |
| 234 | arg_early_core_pattern); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 235 | diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c |
| 236 | index f88cb80834..68055fb64a 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 237 | --- a/src/core/smack-setup.c |
| 238 | +++ b/src/core/smack-setup.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 239 | @@ -320,17 +320,17 @@ int mac_smack_setup(bool *loaded_policy) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 240 | } |
| 241 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 242 | #if HAVE_SMACK_RUN_LABEL |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 243 | - r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 244 | + r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); |
| 245 | if (r < 0) |
| 246 | log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); |
| 247 | - r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 248 | + r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); |
| 249 | if (r < 0) |
| 250 | log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); |
| 251 | r = write_string_file("/sys/fs/smackfs/netlabel", |
| 252 | - "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 253 | + "0.0.0.0/0 " SMACK_RUN_LABEL, 0); |
| 254 | if (r < 0) |
| 255 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); |
| 256 | - r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 257 | + r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); |
| 258 | if (r < 0) |
| 259 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); |
| 260 | #endif |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 261 | diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 262 | index 1c7d9179d8..3ae78ee580 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 263 | --- a/src/hibernate-resume/hibernate-resume.c |
| 264 | +++ b/src/hibernate-resume/hibernate-resume.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 265 | @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 266 | return EXIT_FAILURE; |
| 267 | } |
| 268 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 269 | - r = write_string_file("/sys/power/resume", FORMAT_DEVNUM(st.st_rdev), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 270 | + r = write_string_file("/sys/power/resume", FORMAT_DEVNUM(st.st_rdev), 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 271 | if (r < 0) { |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 272 | log_error_errno(r, "Failed to write '" DEVNUM_FORMAT_STR "' to /sys/power/resume: %m", DEVNUM_FORMAT_VAL(st.st_rdev)); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 273 | return EXIT_FAILURE; |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 274 | diff --git a/src/home/homework.c b/src/home/homework.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 275 | index 0014a7f598..ec3e9caa1c 100644 |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 276 | --- a/src/home/homework.c |
| 277 | +++ b/src/home/homework.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 278 | @@ -278,7 +278,7 @@ static void drop_caches_now(void) { |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 279 | * details. We write "2" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but not |
| 280 | * more. */ |
| 281 | |
| 282 | - r = write_string_file("/proc/sys/vm/drop_caches", "2\n", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 283 | + r = write_string_file("/proc/sys/vm/drop_caches", "2\n", 0); |
| 284 | if (r < 0) |
| 285 | log_warning_errno(r, "Failed to drop caches, ignoring: %m"); |
| 286 | else |
| 287 | diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 288 | index aaf951ced8..45a9d70f0d 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 289 | --- a/src/libsystemd/sd-device/sd-device.c |
| 290 | +++ b/src/libsystemd/sd-device/sd-device.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 291 | @@ -2215,7 +2215,7 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 292 | if (!value) |
| 293 | return -ENOMEM; |
| 294 | |
| 295 | - r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); |
| 296 | + r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); |
| 297 | if (r < 0) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 298 | /* On failure, clear cache entry, as we do not know how it fails. */ |
| 299 | device_remove_cached_sysattr_value(device, sysattr); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 300 | diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 301 | index 9e6379ae7b..546a03a7f5 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 302 | --- a/src/nspawn/nspawn-cgroup.c |
| 303 | +++ b/src/nspawn/nspawn-cgroup.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 304 | @@ -123,7 +123,7 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) { |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 305 | fn = strjoina(tree, cgroup, "/cgroup.procs"); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 306 | |
| 307 | sprintf(pid_string, PID_FMT, pid); |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 308 | - r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); |
| 309 | + r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 310 | if (r < 0) { |
| 311 | log_error_errno(r, "Failed to move process: %m"); |
| 312 | goto finish; |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 313 | diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 314 | index c5fd978395..fefe8a21e5 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 315 | --- a/src/nspawn/nspawn.c |
| 316 | +++ b/src/nspawn/nspawn.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 317 | @@ -2759,7 +2759,7 @@ static int reset_audit_loginuid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 318 | if (streq(p, "4294967295")) |
| 319 | return 0; |
| 320 | |
| 321 | - r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 322 | + r = write_string_file("/proc/self/loginuid", "4294967295", 0); |
| 323 | if (r < 0) { |
| 324 | log_error_errno(r, |
| 325 | "Failed to reset audit login UID. This probably means that your kernel is too\n" |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 326 | @@ -4187,7 +4187,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 327 | return log_oom(); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 328 | |
| 329 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 330 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 331 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 332 | if (r < 0) |
| 333 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 334 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 335 | @@ -4197,7 +4197,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 336 | return log_oom(); |
| 337 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 338 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 339 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 340 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 341 | if (r < 0) |
| 342 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 343 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 344 | diff --git a/src/shared/binfmt-util.c b/src/shared/binfmt-util.c |
| 345 | index 724d7f27d9..dd725cff92 100644 |
| 346 | --- a/src/shared/binfmt-util.c |
| 347 | +++ b/src/shared/binfmt-util.c |
| 348 | @@ -26,7 +26,7 @@ int disable_binfmt(void) { |
| 349 | if (r < 0) |
| 350 | return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m"); |
| 351 | |
| 352 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 353 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 354 | if (r < 0) |
| 355 | return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m"); |
| 356 | |
| 357 | diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 358 | index a1fabc73c1..c5c8fc417e 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 359 | --- a/src/shared/cgroup-setup.c |
| 360 | +++ b/src/shared/cgroup-setup.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 361 | @@ -344,7 +344,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 362 | |
| 363 | xsprintf(c, PID_FMT "\n", pid); |
| 364 | |
| 365 | - r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 366 | + r = write_string_file(fs, c, 0); |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 367 | if (r == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0) |
| 368 | /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */ |
| 369 | return -EUCLEAN; |
| 370 | @@ -879,7 +879,7 @@ int cg_enable_everywhere( |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 371 | return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); |
| 372 | } |
| 373 | |
| 374 | - r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 375 | + r = write_string_stream(f, s, 0); |
| 376 | if (r < 0) { |
| 377 | log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", |
| 378 | FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 379 | diff --git a/src/shared/coredump-util.c b/src/shared/coredump-util.c |
| 380 | index a0b648bf79..13f921390d 100644 |
| 381 | --- a/src/shared/coredump-util.c |
| 382 | +++ b/src/shared/coredump-util.c |
| 383 | @@ -70,5 +70,5 @@ int set_coredump_filter(uint64_t value) { |
| 384 | sprintf(t, "0x%"PRIx64, value); |
| 385 | |
| 386 | return write_string_file("/proc/self/coredump_filter", t, |
| 387 | - WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); |
| 388 | + WRITE_STRING_FILE_VERIFY_ON_FAILURE); |
| 389 | } |
| 390 | diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c |
| 391 | index 0df1778cb2..3b9a0c934e 100644 |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 392 | --- a/src/shared/smack-util.c |
| 393 | +++ b/src/shared/smack-util.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 394 | @@ -114,7 +114,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) { |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 395 | return 0; |
| 396 | |
| 397 | p = procfs_file_alloca(pid, "attr/current"); |
| 398 | - r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 399 | + r = write_string_file(p, label, 0); |
| 400 | if (r < 0) |
| 401 | return r; |
| 402 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 403 | diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c |
| 404 | index 7064f3a905..8f2a7d9da2 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 405 | --- a/src/sleep/sleep.c |
| 406 | +++ b/src/sleep/sleep.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 407 | @@ -46,7 +46,7 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 408 | assert(hibernate_location->swap); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 409 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 410 | xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); |
| 411 | - r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 412 | + r = write_string_file("/sys/power/resume", resume_str, 0); |
| 413 | if (r < 0) |
| 414 | return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", |
| 415 | hibernate_location->swap->device, resume_str); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 416 | @@ -73,7 +73,7 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 417 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 418 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 419 | xsprintf(offset_str, "%" PRIu64, hibernate_location->offset); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 420 | - r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 421 | + r = write_string_file("/sys/power/resume_offset", offset_str, 0); |
| 422 | if (r < 0) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 423 | return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m", |
| 424 | hibernate_location->swap->device, offset_str); |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 425 | @@ -89,7 +89,7 @@ static int write_mode(char **modes) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 426 | STRV_FOREACH(mode, modes) { |
| 427 | int k; |
| 428 | |
| 429 | - k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 430 | + k = write_string_file("/sys/power/disk", *mode, 0); |
| 431 | if (k >= 0) |
| 432 | return 0; |
| 433 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 434 | @@ -110,7 +110,7 @@ static int write_state(FILE **f, char **states) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 435 | STRV_FOREACH(state, states) { |
| 436 | int k; |
| 437 | |
| 438 | - k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 439 | + k = write_string_stream(*f, *state, 0); |
| 440 | if (k >= 0) |
| 441 | return 0; |
| 442 | log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", *state); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 443 | diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 444 | index cd858c9cca..0feb9669a0 100644 |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 445 | --- a/src/udev/udev-rules.c |
| 446 | +++ b/src/udev/udev-rules.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 447 | @@ -2335,7 +2335,6 @@ static int udev_rule_apply_token_to_event( |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 448 | log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value); |
| 449 | r = write_string_file(buf, value, |
| 450 | WRITE_STRING_FILE_VERIFY_ON_FAILURE | |
| 451 | - WRITE_STRING_FILE_DISABLE_BUFFER | |
| 452 | WRITE_STRING_FILE_AVOID_NEWLINE | |
| 453 | WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); |
| 454 | if (r < 0) |
| 455 | diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c |
| 456 | index 50930d4af3..5efd5d3728 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 457 | --- a/src/vconsole/vconsole-setup.c |
| 458 | +++ b/src/vconsole/vconsole-setup.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 459 | @@ -108,7 +108,7 @@ static int toggle_utf8_vc(const char *name, int fd, bool utf8) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 460 | static int toggle_utf8_sysfs(bool utf8) { |
| 461 | int r; |
| 462 | |
| 463 | - r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 464 | + r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); |
| 465 | if (r < 0) |
| 466 | return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); |
| 467 | |