mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
manager: do not append '\n' when writing sysctl settings
When booting with debug logs, we print: Setting '/proc/sys/fs/file-max' to '9223372036854775807 ' Setting '/proc/sys/fs/nr_open' to '2147483640 ' Couldn't write fs.nr_open as 2147483640, halving it. Setting '/proc/sys/fs/nr_open' to '1073741816 ' Successfully bumped fs.nr_open to 1073741816 The strange formatting is because we explicitly appended a newline in those two places. It seems that the kernel doesn't care. In fact, we have a few dozen other writes to sysctl where we don't append a newline. So let's just drop those here too, to make the code a bit simpler and avoid strange output in the logs.
This commit is contained in:
parent
f6484e8503
commit
b47e0fac03
@ -1184,9 +1184,10 @@ static void bump_file_max_and_nr_open(void) {
|
||||
#if BUMP_PROC_SYS_FS_FILE_MAX
|
||||
/* The maximum the kernel allows for this since 5.2 is LONG_MAX, use that. (Previously things were
|
||||
* different, but the operation would fail silently.) */
|
||||
r = sysctl_writef("fs/file-max", "%li\n", LONG_MAX);
|
||||
r = sysctl_writef("fs/file-max", "%li", LONG_MAX);
|
||||
if (r < 0)
|
||||
log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, "Failed to bump fs.file-max, ignoring: %m");
|
||||
log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING,
|
||||
r, "Failed to bump fs.file-max, ignoring: %m");
|
||||
#endif
|
||||
|
||||
#if BUMP_PROC_SYS_FS_NR_OPEN
|
||||
@ -1218,7 +1219,7 @@ static void bump_file_max_and_nr_open(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
r = sysctl_writef("fs/nr_open", "%i\n", v);
|
||||
r = sysctl_writef("fs/nr_open", "%i", v);
|
||||
if (r == -EINVAL) {
|
||||
log_debug("Couldn't write fs.nr_open as %i, halving it.", v);
|
||||
v /= 2;
|
||||
|
Loading…
Reference in New Issue
Block a user