chiark / gitweb /
fileio: document why fileio-label.c and fileio.c are two different modules
authorLennart Poettering <lennart@poettering.net>
Mon, 27 Nov 2017 15:06:39 +0000 (16:06 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 27 Nov 2017 15:06:39 +0000 (16:06 +0100)
src/basic/fileio-label.h
src/basic/fileio.h

index d811ca9b89bfdcaf596d713c686eb6a5af7f116e..42676a3525bba09d7aa37e7769e78ebddb9f9fc0 100644 (file)
 
 #include "fileio.h"
 
+/* These functions are split out of fileio.h (and not for examplement just as flags to the functions they wrap) in
+ * order to optimize linking: This way, -lselinux is needed only for the callers of these functions that need selinux,
+ * but not for all */
+
 int write_string_file_atomic_label_ts(const char *fn, const char *line, struct timespec *ts);
 static inline int write_string_file_atomic_label(const char *fn, const char *line) {
         return write_string_file_atomic_label_ts(fn, line, NULL);
index 5b3d045e05424b5920c1006c531389815bc77480..d90fa4836dca02d7b981c6ab176c70f04824e7e0 100644 (file)
 #include "time-util.h"
 
 typedef enum {
-        WRITE_STRING_FILE_CREATE = 1<<0,
-        WRITE_STRING_FILE_ATOMIC = 1<<1,
-        WRITE_STRING_FILE_AVOID_NEWLINE = 1<<2,
+        WRITE_STRING_FILE_CREATE            = 1<<0,
+        WRITE_STRING_FILE_ATOMIC            = 1<<1,
+        WRITE_STRING_FILE_AVOID_NEWLINE     = 1<<2,
         WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1<<3,
-        WRITE_STRING_FILE_SYNC = 1<<4,
+        WRITE_STRING_FILE_SYNC              = 1<<4,
+
+        /* 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()
+           and friends. */
+
 } WriteStringFileFlags;
 
 int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts);