From: Tiago Salem Herrmann Date: Tue, 12 Dec 2017 15:52:45 +0000 (-0200) Subject: sysctl: disable buffer while writing to /proc X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=61837b944ab30193dbcb286b95470771efba82b2;p=elogind.git sysctl: disable buffer while writing to /proc fputs() writes only first 2048 bytes and fails to write to /proc when values are larger than that. This patch adds a new flag to WriteStringFileFlags that make it possible to disable the buffer under specific cases. --- diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 3c2f9742e..2f9d47019 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -166,6 +166,9 @@ int write_string_file_ts( } } + if (flags & WRITE_STRING_FILE_DISABLE_BUFFER) + setvbuf(f, NULL, _IONBF, 0); + r = write_string_stream_ts(f, line, flags, ts); if (r < 0) goto fail; diff --git a/src/basic/fileio.h b/src/basic/fileio.h index d90fa4836..08423c1c9 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -34,6 +34,7 @@ typedef enum { WRITE_STRING_FILE_AVOID_NEWLINE = 1<<2, WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1<<3, WRITE_STRING_FILE_SYNC = 1<<4, + WRITE_STRING_FILE_DISABLE_BUFFER = 1<<5, /* And before you wonder, why write_string_file_atomic_label_ts() is a separate function instead of just one more flag here: it's about linking: we don't want to pull -lselinux into all users of write_string_file()