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 | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 46 | --- a/src/basic/cgroup-util.c |
| 47 | +++ b/src/basic/cgroup-util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 48 | @@ -399,7 +399,7 @@ int cg_kill_kernel_sigkill(const char *c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 49 | if (r < 0) |
| 50 | return r; |
| 51 | |
| 52 | - r = write_string_file(killfile, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 53 | + r = write_string_file(killfile, "1", 0); |
| 54 | if (r < 0) |
| 55 | return r; |
| 56 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 57 | @@ -805,7 +805,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | |
| 59 | sc = strstrip(contents); |
| 60 | if (isempty(sc)) { |
| 61 | - r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 62 | + r = write_string_file(fs, agent, 0); |
| 63 | if (r < 0) |
| 64 | return r; |
| 65 | } else if (!path_equal(sc, agent)) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 66 | @@ -823,7 +823,7 @@ int cg_install_release_agent(const char |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 67 | |
| 68 | sc = strstrip(contents); |
| 69 | if (streq(sc, "0")) { |
| 70 | - r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 71 | + r = write_string_file(fs, "1", 0); |
| 72 | if (r < 0) |
| 73 | return r; |
| 74 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 75 | @@ -850,7 +850,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 76 | if (r < 0) |
| 77 | return r; |
| 78 | |
| 79 | - r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 80 | + r = write_string_file(fs, "0", 0); |
| 81 | if (r < 0) |
| 82 | return r; |
| 83 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 84 | @@ -860,7 +860,7 @@ int cg_uninstall_release_agent(const cha |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 85 | if (r < 0) |
| 86 | return r; |
| 87 | |
| 88 | - r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 89 | + r = write_string_file(fs, "", 0); |
| 90 | if (r < 0) |
| 91 | return r; |
| 92 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 93 | @@ -1730,7 +1730,7 @@ int cg_set_attribute(const char *control |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 94 | if (r < 0) |
| 95 | return r; |
| 96 | |
| 97 | - return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 98 | + return write_string_file(p, value, 0); |
| 99 | } |
| 100 | |
| 101 | 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] | 102 | --- a/src/basic/namespace-util.c |
| 103 | +++ b/src/basic/namespace-util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 104 | @@ -220,12 +220,12 @@ int userns_acquire(const char *uid_map, |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 105 | freeze(); |
| 106 | |
| 107 | xsprintf(path, "/proc/" PID_FMT "/uid_map", pid); |
| 108 | - r = write_string_file(path, uid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 109 | + r = write_string_file(path, uid_map, 0); |
| 110 | if (r < 0) |
| 111 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 112 | |
| 113 | xsprintf(path, "/proc/" PID_FMT "/gid_map", pid); |
| 114 | - r = write_string_file(path, gid_map, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 115 | + r = write_string_file(path, gid_map, 0); |
| 116 | if (r < 0) |
| 117 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 118 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 119 | --- a/src/basic/procfs-util.c |
| 120 | +++ b/src/basic/procfs-util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 121 | @@ -64,13 +64,13 @@ int procfs_tasks_set_limit(uint64_t limi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 122 | * decrease it, as threads-max is the much more relevant sysctl. */ |
| 123 | if (limit > pid_max-1) { |
| 124 | sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ |
| 125 | - r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 126 | + r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); |
| 127 | if (r < 0) |
| 128 | return r; |
| 129 | } |
| 130 | |
| 131 | sprintf(buffer, "%" PRIu64, limit); |
| 132 | - r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 133 | + r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); |
| 134 | if (r < 0) { |
| 135 | uint64_t threads_max; |
| 136 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 137 | --- a/src/basic/sysctl-util.c |
| 138 | +++ b/src/basic/sysctl-util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 139 | @@ -58,7 +58,7 @@ int sysctl_write(const char *property, c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 140 | |
| 141 | log_debug("Setting '%s' to '%s'", p, value); |
| 142 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 143 | - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); |
| 144 | + 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] | 145 | } |
| 146 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 147 | int sysctl_writef(const char *property, const char *format, ...) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 148 | --- a/src/basic/util.c |
| 149 | +++ b/src/basic/util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 150 | @@ -134,7 +134,7 @@ void disable_coredumps(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 151 | if (detect_container() > 0) |
| 152 | return; |
| 153 | |
| 154 | - r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 155 | + r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); |
| 156 | if (r < 0) |
| 157 | log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); |
| 158 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 159 | --- a/src/binfmt/binfmt.c |
| 160 | +++ b/src/binfmt/binfmt.c |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 161 | @@ -29,7 +29,7 @@ static bool arg_unregister = false; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 162 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 163 | static int delete_rule(const char *rulename) { |
| 164 | const char *fn = strjoina("/proc/sys/fs/binfmt_misc/", rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 165 | - return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 166 | + return write_string_file(fn, "-1", 0); |
| 167 | } |
| 168 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 169 | static int apply_rule(const char *filename, unsigned line, const char *rule) { |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 170 | @@ -59,7 +59,7 @@ static int apply_rule(const char *filena |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 171 | if (r >= 0) |
| 172 | log_debug("%s:%u: Rule '%s' deleted.", filename, line, rulename); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 173 | |
| 174 | - r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 175 | + r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); |
| 176 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 177 | return log_error_errno(r, "%s:%u: Failed to add binary format '%s': %m", |
| 178 | filename, line, rulename); |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 179 | @@ -225,7 +225,7 @@ static int run(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /* Flush out all rules */ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 183 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 184 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 185 | if (r < 0) |
| 186 | log_warning_errno(r, "Failed to flush binfmt_misc rules, ignoring: %m"); |
| 187 | else |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 188 | --- a/src/core/cgroup.c |
| 189 | +++ b/src/core/cgroup.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 190 | @@ -4210,7 +4210,7 @@ int unit_cgroup_freezer_action(Unit *u, |
| 191 | u->freezer_state = FREEZER_THAWING; |
| 192 | } |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 193 | |
| 194 | - r = write_string_file(path, one_zero(action == FREEZER_FREEZE), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 195 | + r = write_string_file(path, one_zero(action == FREEZER_FREEZE), 0); |
| 196 | if (r < 0) |
| 197 | return r; |
| 198 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 199 | --- a/src/core/main.c |
| 200 | +++ b/src/core/main.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 201 | @@ -1404,7 +1404,7 @@ static int bump_unix_max_dgram_qlen(void |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 202 | if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN) |
| 203 | return 0; |
| 204 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 205 | - r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, |
| 206 | + r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, |
| 207 | "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 208 | if (r < 0) |
| 209 | return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 210 | @@ -1676,7 +1676,7 @@ static void initialize_core_pattern(bool |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 211 | if (getpid_cached() != 1) |
| 212 | return; |
| 213 | |
| 214 | - r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 215 | + r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); |
| 216 | if (r < 0) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 217 | log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", |
| 218 | arg_early_core_pattern); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 219 | --- a/src/core/smack-setup.c |
| 220 | +++ b/src/core/smack-setup.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 221 | @@ -320,17 +320,17 @@ int mac_smack_setup(bool *loaded_policy) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 222 | } |
| 223 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 224 | #if HAVE_SMACK_RUN_LABEL |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 225 | - r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 226 | + r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); |
| 227 | if (r < 0) |
| 228 | log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); |
| 229 | - r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 230 | + r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); |
| 231 | if (r < 0) |
| 232 | log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); |
| 233 | r = write_string_file("/sys/fs/smackfs/netlabel", |
| 234 | - "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 235 | + "0.0.0.0/0 " SMACK_RUN_LABEL, 0); |
| 236 | if (r < 0) |
| 237 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); |
| 238 | - r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 239 | + r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); |
| 240 | if (r < 0) |
| 241 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); |
| 242 | #endif |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 243 | --- a/src/hibernate-resume/hibernate-resume.c |
| 244 | +++ b/src/hibernate-resume/hibernate-resume.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 245 | @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 246 | return EXIT_FAILURE; |
| 247 | } |
| 248 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 249 | - r = write_string_file("/sys/power/resume", FORMAT_DEVNUM(st.st_rdev), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 250 | + 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] | 251 | if (r < 0) { |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 252 | 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] | 253 | return EXIT_FAILURE; |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 254 | --- a/src/home/homework.c |
| 255 | +++ b/src/home/homework.c |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 256 | @@ -278,7 +278,7 @@ static void drop_caches_now(void) { |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 257 | * for details. We write "2" into /proc/sys/vm/drop_caches to ensure dentries/inodes are flushed, but |
| 258 | * not more. */ |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 259 | |
| 260 | - r = write_string_file("/proc/sys/vm/drop_caches", "2\n", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 261 | + r = write_string_file("/proc/sys/vm/drop_caches", "2\n", 0); |
| 262 | if (r < 0) |
| 263 | log_warning_errno(r, "Failed to drop caches, ignoring: %m"); |
| 264 | else |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 265 | --- a/src/libsystemd/sd-device/sd-device.c |
| 266 | +++ b/src/libsystemd/sd-device/sd-device.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 267 | @@ -2444,7 +2444,7 @@ _public_ int sd_device_set_sysattr_value |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 268 | if (!value) |
| 269 | return -ENOMEM; |
| 270 | |
| 271 | - r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); |
| 272 | + r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); |
| 273 | if (r < 0) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 274 | /* On failure, clear cache entry, as we do not know how it fails. */ |
| 275 | device_remove_cached_sysattr_value(device, sysattr); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 276 | --- a/src/nspawn/nspawn-cgroup.c |
| 277 | +++ b/src/nspawn/nspawn-cgroup.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 278 | @@ -123,7 +123,7 @@ int sync_cgroup(pid_t pid, CGroupUnified |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 279 | fn = strjoina(tree, cgroup, "/cgroup.procs"); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 280 | |
| 281 | sprintf(pid_string, PID_FMT, pid); |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 282 | - r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); |
| 283 | + r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 284 | if (r < 0) { |
| 285 | log_error_errno(r, "Failed to move process: %m"); |
| 286 | goto finish; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 287 | --- a/src/nspawn/nspawn.c |
| 288 | +++ b/src/nspawn/nspawn.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 289 | @@ -2762,7 +2762,7 @@ static int reset_audit_loginuid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 290 | if (streq(p, "4294967295")) |
| 291 | return 0; |
| 292 | |
| 293 | - r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 294 | + r = write_string_file("/proc/self/loginuid", "4294967295", 0); |
| 295 | if (r < 0) { |
| 296 | log_error_errno(r, |
| 297 | "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] | 298 | @@ -4187,7 +4187,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 299 | return log_oom(); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 300 | |
| 301 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 302 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 303 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 304 | if (r < 0) |
| 305 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 306 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 307 | @@ -4197,7 +4197,7 @@ static int setup_uid_map( |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 308 | return log_oom(); |
| 309 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 310 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 311 | - r = write_string_file(uid_map, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 312 | + r = write_string_file(uid_map, s, 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 313 | if (r < 0) |
| 314 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 315 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 316 | --- a/src/shared/binfmt-util.c |
| 317 | +++ b/src/shared/binfmt-util.c |
| 318 | @@ -26,7 +26,7 @@ int disable_binfmt(void) { |
| 319 | if (r < 0) |
| 320 | return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m"); |
| 321 | |
| 322 | - r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 323 | + r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
| 324 | if (r < 0) |
| 325 | return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m"); |
| 326 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 327 | --- a/src/shared/cgroup-setup.c |
| 328 | +++ b/src/shared/cgroup-setup.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 329 | @@ -350,7 +350,7 @@ int cg_attach(const char *controller, co |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 330 | |
| 331 | xsprintf(c, PID_FMT "\n", pid); |
| 332 | |
| 333 | - r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 334 | + r = write_string_file(fs, c, 0); |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 335 | if (r == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0) |
| 336 | /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */ |
| 337 | return -EUCLEAN; |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 338 | @@ -887,7 +887,7 @@ int cg_enable_everywhere( |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 339 | return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); |
| 340 | } |
| 341 | |
| 342 | - r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 343 | + r = write_string_stream(f, s, 0); |
| 344 | if (r < 0) { |
| 345 | log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", |
| 346 | FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 347 | --- a/src/shared/coredump-util.c |
| 348 | +++ b/src/shared/coredump-util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 349 | @@ -70,5 +70,5 @@ int set_coredump_filter(uint64_t value) |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 350 | sprintf(t, "0x%"PRIx64, value); |
| 351 | |
| 352 | return write_string_file("/proc/self/coredump_filter", t, |
| 353 | - WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); |
| 354 | + WRITE_STRING_FILE_VERIFY_ON_FAILURE); |
| 355 | } |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 356 | --- a/src/shared/smack-util.c |
| 357 | +++ b/src/shared/smack-util.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 358 | @@ -115,7 +115,7 @@ int mac_smack_apply_pid(pid_t pid, const |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 359 | return 0; |
| 360 | |
| 361 | p = procfs_file_alloca(pid, "attr/current"); |
| 362 | - r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 363 | + r = write_string_file(p, label, 0); |
| 364 | if (r < 0) |
| 365 | return r; |
| 366 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 367 | --- a/src/sleep/sleep.c |
| 368 | +++ b/src/sleep/sleep.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 369 | @@ -50,7 +50,7 @@ static int write_hibernate_location_info |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 370 | assert(hibernate_location->swap); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 371 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 372 | xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); |
| 373 | - r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 374 | + r = write_string_file("/sys/power/resume", resume_str, 0); |
| 375 | if (r < 0) |
| 376 | return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", |
| 377 | hibernate_location->swap->device, resume_str); |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 378 | @@ -77,7 +77,7 @@ static int write_hibernate_location_info |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 379 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 380 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 381 | xsprintf(offset_str, "%" PRIu64, hibernate_location->offset); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 382 | - r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 383 | + r = write_string_file("/sys/power/resume_offset", offset_str, 0); |
| 384 | if (r < 0) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 385 | return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m", |
| 386 | hibernate_location->swap->device, offset_str); |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 387 | @@ -93,7 +93,7 @@ static int write_mode(char **modes) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 388 | STRV_FOREACH(mode, modes) { |
| 389 | int k; |
| 390 | |
| 391 | - k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 392 | + k = write_string_file("/sys/power/disk", *mode, 0); |
| 393 | if (k >= 0) |
| 394 | return 0; |
| 395 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 396 | @@ -114,7 +114,7 @@ static int write_state(FILE **f, char ** |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 397 | STRV_FOREACH(state, states) { |
| 398 | int k; |
| 399 | |
| 400 | - k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 401 | + k = write_string_stream(*f, *state, 0); |
| 402 | if (k >= 0) |
| 403 | return 0; |
| 404 | 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] | 405 | --- a/src/udev/udev-rules.c |
| 406 | +++ b/src/udev/udev-rules.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 407 | @@ -2354,7 +2354,6 @@ static int udev_rule_apply_token_to_even |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 408 | log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value); |
| 409 | r = write_string_file(buf, value, |
| 410 | WRITE_STRING_FILE_VERIFY_ON_FAILURE | |
| 411 | - WRITE_STRING_FILE_DISABLE_BUFFER | |
| 412 | WRITE_STRING_FILE_AVOID_NEWLINE | |
| 413 | WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE); |
| 414 | if (r < 0) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 415 | --- a/src/vconsole/vconsole-setup.c |
| 416 | +++ b/src/vconsole/vconsole-setup.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 417 | @@ -108,7 +108,7 @@ static int toggle_utf8_vc(const char *na |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 418 | static int toggle_utf8_sysfs(bool utf8) { |
| 419 | int r; |
| 420 | |
| 421 | - r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 422 | + r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); |
| 423 | if (r < 0) |
| 424 | return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); |
| 425 | |