]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fd-util: Move O_ACCMODE_STRICT to fd-util.h 38051/head
authorDaanDeMeyer <daan.j.demeyer@gmail.com>
Thu, 3 Jul 2025 12:23:16 +0000 (14:23 +0200)
committerDaanDeMeyer <daan.j.demeyer@gmail.com>
Thu, 3 Jul 2025 12:28:14 +0000 (14:28 +0200)
We're still discussing whether we want to remove this or not, but
regardless of whether we end up removing it or not, it's something
we add ourselves and as such should not live in our headers that
override glibc headers, so let's move it to fd-util.h.

src/basic/fd-util.h
src/basic/include/fcntl.h
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-file.h
src/shared/journal-file-util.c

index 75cc5310c7a25f48e3af8943a17877d2b099f1dd..25ad3e9361e34660b3da02b31e04ecb7272ba43d 100644 (file)
 #  endif
 #endif
 
+/* On musl, O_ACCMODE is defined as (03|O_SEARCH), unlike glibc which defines it as
+ * (O_RDONLY|O_WRONLY|O_RDWR). Additionally, O_SEARCH is simply defined as O_PATH. This changes the behaviour
+ * of O_ACCMODE in certain situations, which we don't want. This definition is copied from glibc and works
+ * around the problems with musl's definition. */
+#define O_ACCMODE_STRICT (O_RDONLY|O_WRONLY|O_RDWR)
+
 int close_nointr(int fd);
 int safe_close(int fd);
 void safe_close_pair(int p[static 2]);
index 344287f7680f9d526bb093e996f14b3dd745861c..5f1d90ad795aa24e8392caa94cf47f949cc5f6a7 100644 (file)
@@ -17,9 +17,3 @@
 #ifndef AT_HANDLE_FID
 #define AT_HANDLE_FID AT_REMOVEDIR
 #endif
-
-/* On musl, O_ACCMODE is defined as (03|O_SEARCH), unlike glibc which defines it as
- * (O_RDONLY|O_WRONLY|O_RDWR). Additionally, O_SEARCH is simply defined as O_PATH. This changes the behaviour
- * of O_ACCMODE in certain situations, which we don't want. This definition is copied from glibc and works
- * around the problems with musl's definition. */
-#define O_ACCMODE_STRICT (O_RDONLY|O_WRONLY|O_RDWR)
index 224c3e23c7a09247f9405955142dd7d795e3fe72..baabb92fd70af8c8788248bb00e699ffa2d151f8 100644 (file)
@@ -4694,6 +4694,11 @@ bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec, int log
         return false;
 }
 
+bool journal_file_writable(JournalFile *f) {
+        assert(f);
+        return (f->open_flags & O_ACCMODE_STRICT) != O_RDONLY;
+}
+
 static const char * const journal_object_type_table[] = {
         [OBJECT_UNUSED]           = "unused",
         [OBJECT_DATA]             = "data",
index 9598879066a2d462b9f37373efc61b38ebd280e8..4a5e0d81e2fbcd5941cde2b2b04ec60895e7a47b 100644 (file)
@@ -378,7 +378,4 @@ static inline uint32_t COMPRESSION_TO_HEADER_INCOMPATIBLE_FLAG(Compression c) {
         }
 }
 
-static inline bool journal_file_writable(JournalFile *f) {
-        assert(f);
-        return (f->open_flags & O_ACCMODE_STRICT) != O_RDONLY;
-}
+bool journal_file_writable(JournalFile *f);
index ce799e9256e1a0825f938db399e5ce0b75181130..990146b62465e4e342500d2fae08bb09d7d1109d 100644 (file)
@@ -9,6 +9,7 @@
 #include "chattr-util.h"
 #include "copy.h"
 #include "errno-util.h"
+#include "fd-util.h"
 #include "journal-authenticate.h"
 #include "journal-file-util.h"
 #include "log.h"