William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1 | From 7cb6579572b50ef44bc0a321a4c73cce55b0c2f2 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 | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 23 | src/basic/cgroup-util.c | 10 +++++----- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | src/basic/procfs-util.c | 4 ++-- |
| 25 | src/basic/smack-util.c | 2 +- |
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 +++--- |
| 29 | src/core/main.c | 4 ++-- |
| 30 | src/core/smack-setup.c | 8 ++++---- |
| 31 | src/hibernate-resume/hibernate-resume.c | 2 +- |
| 32 | src/libsystemd/sd-device/sd-device.c | 2 +- |
| 33 | src/login/logind-dbus.c | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 34 | src/nspawn/nspawn-cgroup.c | 2 +- |
| 35 | src/nspawn/nspawn.c | 6 +++--- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 36 | src/shared/cgroup-setup.c | 4 ++-- |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 37 | src/sleep/sleep.c | 8 ++++---- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 38 | src/vconsole/vconsole-setup.c | 2 +- |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 39 | 16 files changed, 33 insertions(+), 33 deletions(-) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 40 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 41 | diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 42 | index 50c1ae1b2b..5b40e92163 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 43 | --- a/src/basic/cgroup-util.c |
| 44 | +++ b/src/basic/cgroup-util.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 45 | @@ -765,7 +765,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | |
| 47 | sc = strstrip(contents); |
| 48 | if (isempty(sc)) { |
| 49 | - r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 50 | + r = write_string_file(fs, agent, 0); |
| 51 | if (r < 0) |
| 52 | return r; |
| 53 | } else if (!path_equal(sc, agent)) |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 54 | @@ -783,7 +783,7 @@ int cg_install_release_agent(const char *controller, const char *agent) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 55 | |
| 56 | sc = strstrip(contents); |
| 57 | if (streq(sc, "0")) { |
| 58 | - r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 59 | + r = write_string_file(fs, "1", 0); |
| 60 | if (r < 0) |
| 61 | return r; |
| 62 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 63 | @@ -810,7 +810,7 @@ int cg_uninstall_release_agent(const char *controller) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 64 | if (r < 0) |
| 65 | return r; |
| 66 | |
| 67 | - r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 68 | + r = write_string_file(fs, "0", 0); |
| 69 | if (r < 0) |
| 70 | return r; |
| 71 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 72 | @@ -820,7 +820,7 @@ int cg_uninstall_release_agent(const char *controller) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 73 | if (r < 0) |
| 74 | return r; |
| 75 | |
| 76 | - r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 77 | + r = write_string_file(fs, "", 0); |
| 78 | if (r < 0) |
| 79 | return r; |
| 80 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 81 | @@ -1650,7 +1650,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] | 82 | if (r < 0) |
| 83 | return r; |
| 84 | |
| 85 | - return write_string_file(p, value, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 86 | + return write_string_file(p, value, 0); |
| 87 | } |
| 88 | |
| 89 | int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 90 | diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c |
| 91 | index 8f9eee8d36..480f8cc0b4 100644 |
| 92 | --- a/src/basic/procfs-util.c |
| 93 | +++ b/src/basic/procfs-util.c |
| 94 | @@ -86,13 +86,13 @@ int procfs_tasks_set_limit(uint64_t limit) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 95 | * decrease it, as threads-max is the much more relevant sysctl. */ |
| 96 | if (limit > pid_max-1) { |
| 97 | sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */ |
| 98 | - r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 99 | + r = write_string_file("/proc/sys/kernel/pid_max", buffer, 0); |
| 100 | if (r < 0) |
| 101 | return r; |
| 102 | } |
| 103 | |
| 104 | sprintf(buffer, "%" PRIu64, limit); |
| 105 | - r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 106 | + r = write_string_file("/proc/sys/kernel/threads-max", buffer, 0); |
| 107 | if (r < 0) { |
| 108 | uint64_t threads_max; |
| 109 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 110 | diff --git a/src/basic/smack-util.c b/src/basic/smack-util.c |
| 111 | index 3362ee3924..80c0f2a52e 100644 |
| 112 | --- a/src/basic/smack-util.c |
| 113 | +++ b/src/basic/smack-util.c |
| 114 | @@ -114,7 +114,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 115 | return 0; |
| 116 | |
| 117 | p = procfs_file_alloca(pid, "attr/current"); |
| 118 | - r = write_string_file(p, label, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 119 | + r = write_string_file(p, label, 0); |
| 120 | if (r < 0) |
| 121 | return r; |
| 122 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 123 | diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c |
| 124 | index c96b5cd77f..d2476d9665 100644 |
| 125 | --- a/src/basic/sysctl-util.c |
| 126 | +++ b/src/basic/sysctl-util.c |
| 127 | @@ -93,7 +93,7 @@ int sysctl_write_ip_property(int af, const char *ifname, const char *property, c |
| 128 | |
| 129 | log_debug("Setting '%s' to '%s'", p, value); |
| 130 | |
| 131 | - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER); |
| 132 | + return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | 0); |
| 133 | } |
| 134 | |
| 135 | int sysctl_read(const char *property, char **ret) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 136 | diff --git a/src/basic/util.c b/src/basic/util.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 137 | index 955b18bd2a..6d89c90176 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 138 | --- a/src/basic/util.c |
| 139 | +++ b/src/basic/util.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 140 | @@ -234,7 +234,7 @@ void disable_coredumps(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 141 | if (detect_container() > 0) |
| 142 | return; |
| 143 | |
| 144 | - r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 145 | + r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); |
| 146 | if (r < 0) |
| 147 | log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); |
| 148 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 149 | diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 150 | index f6b72e0bae..e9fd4d06be 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 151 | --- a/src/binfmt/binfmt.c |
| 152 | +++ b/src/binfmt/binfmt.c |
| 153 | @@ -48,7 +48,7 @@ static int delete_rule(const char *rule) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 154 | if (!fn) |
| 155 | return log_oom(); |
| 156 | |
| 157 | - return write_string_file(fn, "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 158 | + return write_string_file(fn, "-1", 0); |
| 159 | } |
| 160 | |
| 161 | static int apply_rule(const char *rule) { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 162 | @@ -56,7 +56,7 @@ static int apply_rule(const char *rule) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 163 | |
| 164 | (void) delete_rule(rule); |
| 165 | |
| 166 | - r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 167 | + r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0); |
| 168 | if (r < 0) |
| 169 | return log_error_errno(r, "Failed to add binary format: %m"); |
| 170 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 171 | @@ -222,7 +222,7 @@ static int run(int argc, char *argv[]) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* Flush out all rules */ |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 175 | - (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 176 | + (void) write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 177 | |
| 178 | STRV_FOREACH(f, files) { |
| 179 | k = apply_file(*f, true); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 180 | diff --git a/src/core/main.c b/src/core/main.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 181 | index 3ee8d0a869..ec36e3e80f 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 182 | --- a/src/core/main.c |
| 183 | +++ b/src/core/main.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 184 | @@ -1401,7 +1401,7 @@ static int bump_unix_max_dgram_qlen(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 185 | if (v >= DEFAULT_UNIX_MAX_DGRAM_QLEN) |
| 186 | return 0; |
| 187 | |
| 188 | - r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", WRITE_STRING_FILE_DISABLE_BUFFER, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
| 189 | + r = write_string_filef("/proc/sys/net/unix/max_dgram_qlen", 0, "%lu", DEFAULT_UNIX_MAX_DGRAM_QLEN); |
| 190 | if (r < 0) |
| 191 | return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, |
| 192 | "Failed to bump AF_UNIX datagram queue length, ignoring: %m"); |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 193 | @@ -1678,7 +1678,7 @@ static void initialize_core_pattern(bool skip_setup) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 194 | if (getpid_cached() != 1) |
| 195 | return; |
| 196 | |
| 197 | - r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 198 | + r = write_string_file("/proc/sys/kernel/core_pattern", arg_early_core_pattern, 0); |
| 199 | if (r < 0) |
| 200 | log_warning_errno(r, "Failed to write '%s' to /proc/sys/kernel/core_pattern, ignoring: %m", arg_early_core_pattern); |
| 201 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 202 | diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 203 | index 8cc1696a4f..ab7b4ba2c3 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 204 | --- a/src/core/smack-setup.c |
| 205 | +++ b/src/core/smack-setup.c |
| 206 | @@ -325,17 +325,17 @@ int mac_smack_setup(bool *loaded_policy) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | #ifdef SMACK_RUN_LABEL |
| 210 | - r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 211 | + r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0); |
| 212 | if (r < 0) |
| 213 | log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m"); |
| 214 | - r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 215 | + r = write_string_file("/sys/fs/smackfs/ambient", SMACK_RUN_LABEL, 0); |
| 216 | if (r < 0) |
| 217 | log_warning_errno(r, "Failed to set SMACK ambient label \"" SMACK_RUN_LABEL "\": %m"); |
| 218 | r = write_string_file("/sys/fs/smackfs/netlabel", |
| 219 | - "0.0.0.0/0 " SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 220 | + "0.0.0.0/0 " SMACK_RUN_LABEL, 0); |
| 221 | if (r < 0) |
| 222 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"0.0.0.0/0 " SMACK_RUN_LABEL "\": %m"); |
| 223 | - r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 224 | + r = write_string_file("/sys/fs/smackfs/netlabel", "127.0.0.1 -CIPSO", 0); |
| 225 | if (r < 0) |
| 226 | log_warning_errno(r, "Failed to set SMACK netlabel rule \"127.0.0.1 -CIPSO\": %m"); |
| 227 | #endif |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 228 | diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 229 | index 58e35e403e..1d0beb4008 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 230 | --- a/src/hibernate-resume/hibernate-resume.c |
| 231 | +++ b/src/hibernate-resume/hibernate-resume.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 232 | @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { |
| 233 | return EXIT_FAILURE; |
| 234 | } |
| 235 | |
| 236 | - r = write_string_file("/sys/power/resume", major_minor, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 237 | + r = write_string_file("/sys/power/resume", major_minor, 0); |
| 238 | if (r < 0) { |
| 239 | log_error_errno(r, "Failed to write '%s' to /sys/power/resume: %m", major_minor); |
| 240 | return EXIT_FAILURE; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 241 | diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 242 | index d82f01a164..b8fd63346c 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 243 | --- a/src/libsystemd/sd-device/sd-device.c |
| 244 | +++ b/src/libsystemd/sd-device/sd-device.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 245 | @@ -1987,7 +1987,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] | 246 | if (!value) |
| 247 | return -ENOMEM; |
| 248 | |
| 249 | - r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW); |
| 250 | + r = write_string_file(path, value, 0 | WRITE_STRING_FILE_NOFOLLOW); |
| 251 | if (r < 0) { |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 252 | /* On failure, clear cache entry, as we do not know how it fails. */ |
| 253 | device_remove_cached_sysattr_value(device, sysattr); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 254 | diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 255 | index 3bc424b83b..5f5eef0843 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 256 | --- a/src/login/logind-dbus.c |
| 257 | +++ b/src/login/logind-dbus.c |
| 258 | @@ -1330,7 +1330,7 @@ static int trigger_device(Manager *m, sd_device *d) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 259 | if (!t) |
| 260 | return -ENOMEM; |
| 261 | |
| 262 | - (void) write_string_file(t, "change", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 263 | + (void) write_string_file(t, "change", 0); |
| 264 | } |
| 265 | |
| 266 | return 0; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 267 | diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c |
| 268 | index cb01b25bc6..e92051268b 100644 |
| 269 | --- a/src/nspawn/nspawn-cgroup.c |
| 270 | +++ b/src/nspawn/nspawn-cgroup.c |
| 271 | @@ -124,7 +124,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] | 272 | fn = strjoina(tree, cgroup, "/cgroup.procs"); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 273 | |
| 274 | sprintf(pid_string, PID_FMT, pid); |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 275 | - r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755); |
| 276 | + r = write_string_file(fn, pid_string, WRITE_STRING_FILE_MKDIR_0755); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 277 | if (r < 0) { |
| 278 | log_error_errno(r, "Failed to move process: %m"); |
| 279 | goto finish; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 280 | diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 281 | index 0c41a48d4b..9c893b18e4 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 282 | --- a/src/nspawn/nspawn.c |
| 283 | +++ b/src/nspawn/nspawn.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 284 | @@ -2695,7 +2695,7 @@ static int reset_audit_loginuid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 285 | if (streq(p, "4294967295")) |
| 286 | return 0; |
| 287 | |
| 288 | - r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_DISABLE_BUFFER); |
| 289 | + r = write_string_file("/proc/self/loginuid", "4294967295", 0); |
| 290 | if (r < 0) { |
| 291 | log_error_errno(r, |
| 292 | "Failed to reset audit login UID. This probably means that your kernel is too\n" |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 293 | @@ -3948,13 +3948,13 @@ static int setup_uid_map(pid_t pid) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 294 | |
| 295 | xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid); |
| 296 | xsprintf(line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, arg_uid_shift, arg_uid_range); |
| 297 | - r = write_string_file(uid_map, line, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 298 | + r = write_string_file(uid_map, line, 0); |
| 299 | if (r < 0) |
| 300 | return log_error_errno(r, "Failed to write UID map: %m"); |
| 301 | |
| 302 | /* We always assign the same UID and GID ranges */ |
| 303 | xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid); |
| 304 | - r = write_string_file(uid_map, line, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 305 | + r = write_string_file(uid_map, line, 0); |
| 306 | if (r < 0) |
| 307 | return log_error_errno(r, "Failed to write GID map: %m"); |
| 308 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 309 | diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c |
| 310 | index f197f715c7..077f893177 100644 |
| 311 | --- a/src/shared/cgroup-setup.c |
| 312 | +++ b/src/shared/cgroup-setup.c |
| 313 | @@ -267,7 +267,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] | 314 | |
| 315 | xsprintf(c, PID_FMT "\n", pid); |
| 316 | |
| 317 | - r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 318 | + r = write_string_file(fs, c, 0); |
| 319 | if (r < 0) |
| 320 | return r; |
| 321 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 322 | @@ -799,7 +799,7 @@ int cg_enable_everywhere( |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 323 | return log_debug_errno(errno, "Failed to open cgroup.subtree_control file of %s: %m", p); |
| 324 | } |
| 325 | |
| 326 | - r = write_string_stream(f, s, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 327 | + r = write_string_stream(f, s, 0); |
| 328 | if (r < 0) { |
| 329 | log_debug_errno(r, "Failed to %s controller %s for %s (%s): %m", |
| 330 | FLAGS_SET(mask, bit) ? "enable" : "disable", n, p, fs); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 331 | diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 332 | index 262d4cea66..0523e8dc9b 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 333 | --- a/src/sleep/sleep.c |
| 334 | +++ b/src/sleep/sleep.c |
| 335 | @@ -48,7 +48,7 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 336 | assert(hibernate_location->swap); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 337 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 338 | xsprintf(resume_str, "%u:%u", major(hibernate_location->devno), minor(hibernate_location->devno)); |
| 339 | - r = write_string_file("/sys/power/resume", resume_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 340 | + r = write_string_file("/sys/power/resume", resume_str, 0); |
| 341 | if (r < 0) |
| 342 | return log_debug_errno(r, "Failed to write partition device to /sys/power/resume for '%s': '%s': %m", |
| 343 | hibernate_location->swap->device, resume_str); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 344 | @@ -75,7 +75,7 @@ static int write_hibernate_location_info(const HibernateLocation *hibernate_loca |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 345 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 346 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 347 | xsprintf(offset_str, "%" PRIu64, hibernate_location->offset); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 348 | - r = write_string_file("/sys/power/resume_offset", offset_str, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 349 | + r = write_string_file("/sys/power/resume_offset", offset_str, 0); |
| 350 | if (r < 0) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 351 | return log_debug_errno(r, "Failed to write swap file offset to /sys/power/resume_offset for '%s': '%s': %m", |
| 352 | hibernate_location->swap->device, offset_str); |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 353 | @@ -92,7 +92,7 @@ static int write_mode(char **modes) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 354 | STRV_FOREACH(mode, modes) { |
| 355 | int k; |
| 356 | |
| 357 | - k = write_string_file("/sys/power/disk", *mode, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 358 | + k = write_string_file("/sys/power/disk", *mode, 0); |
| 359 | if (k >= 0) |
| 360 | return 0; |
| 361 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 362 | @@ -114,7 +114,7 @@ static int write_state(FILE **f, char **states) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 363 | STRV_FOREACH(state, states) { |
| 364 | int k; |
| 365 | |
| 366 | - k = write_string_stream(*f, *state, WRITE_STRING_FILE_DISABLE_BUFFER); |
| 367 | + k = write_string_stream(*f, *state, 0); |
| 368 | if (k >= 0) |
| 369 | return 0; |
| 370 | log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m", *state); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 371 | diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 372 | index d1c3febdd5..1cc68694d1 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 373 | --- a/src/vconsole/vconsole-setup.c |
| 374 | +++ b/src/vconsole/vconsole-setup.c |
| 375 | @@ -116,7 +116,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] | 376 | static int toggle_utf8_sysfs(bool utf8) { |
| 377 | int r; |
| 378 | |
| 379 | - r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), WRITE_STRING_FILE_DISABLE_BUFFER); |
| 380 | + r = write_string_file("/sys/module/vt/parameters/default_utf8", one_zero(utf8), 0); |
| 381 | if (r < 0) |
| 382 | return log_warning_errno(r, "Failed to %s sysfs UTF-8 flag: %m", enable_disable(utf8)); |
| 383 | |