From 79cdaaa0cf72fec7a43f1747a0c0ee3e6db8bc00 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 27 Nov 2017 16:06:39 +0100 Subject: [PATCH] fileio: document why fileio-label.c and fileio.c are two different modules --- src/basic/fileio-label.h | 4 ++++ src/basic/fileio.h | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/basic/fileio-label.h b/src/basic/fileio-label.h index d811ca9b8..42676a352 100644 --- a/src/basic/fileio-label.h +++ b/src/basic/fileio-label.h @@ -24,6 +24,10 @@ #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); diff --git a/src/basic/fileio.h b/src/basic/fileio.h index 5b3d045e0..d90fa4836 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -29,11 +29,16 @@ #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); -- 2.30.2