Subject: Re: Fwd: Some non-standard O_* flags are missing

From: Maxime Devos <[email-masked]>
Date: Tue, 09 Mar 2021 20:03:27 +0100

I forgot to include O_PATH, which (in combination with O_NOFOLLOW)
is required for opening a symbolic link.  See revised patch in attachment.
From d769a75962c64804f354a0133494491626b8b2dc Mon Sep 17 00:00:00 2001
From: Maxime Devos <[email-masked]>
Date: Tue, 2 Mar 2021 18:03:22 +0100
Subject: [PATCH] Define `O_NOFOLLOW' and various other flags when supported.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* libguile/filesys.c (scm_init_filesys): Define ‘O_IGNORE_CTTY’,
  ‘O_NOLINK’, ‘O_NOFOLLOW’, ‘O_PATH’, ‘O_TMPFILE’, ‘O_SHLOCK’,
  ‘O_EXLOCK’, ‘O_ASYNC’, ‘O_NOATIME’, ‘O_DIRECTORY’, ‘O_CLOEXEC’
  and ‘O_DIRECT’ when available.
---
 libguile/filesys.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 1b0af6e14..fce6eec2b 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1958,9 +1958,45 @@ scm_init_filesys ()
 #ifdef O_LARGEFILE  
   scm_c_define ("O_LARGEFILE", scm_from_int (O_LARGEFILE));
 #endif
+#ifdef O_IGNORE_CTTY
+  scm_c_define ("O_IGNORE_CTTY", scm_from_int (O_IGNORE_CTTY));
+#endif
+#ifdef O_NOLINK
+  scm_c_define ("O_NOLINK", scm_from_int (O_NOLINK));
+#endif
 #ifdef O_NOTRANS
   scm_c_define ("O_NOTRANS", scm_from_int (O_NOTRANS));
 #endif
+#ifdef O_NOFOLLOW
+  scm_c_define ("O_NOFOLLOW", scm_from_int (O_NOFOLLOW));
+#endif
+#ifdef O_PATH
+  scm_c_define ("O_PATH", scm_from_int (O_PATH));
+#endif
+#ifdef O_TMPFILE
+  scm_c_define ("O_TMPFILE", scm_from_int (O_TMPFILE));
+#endif
+#ifdef O_SHLOCK
+  scm_c_define ("O_SHLOCK", scm_from_int (O_SHLOCK));
+#endif
+#ifdef O_EXLOCK
+  scm_c_define ("O_EXLOCK", scm_from_int (O_EXLOCK));
+#endif
+#ifdef O_ASYNC
+  scm_c_define ("O_ASYNC", scm_from_int (O_ASYNC));
+#endif
+#ifdef O_NOATIME
+  scm_c_define ("O_NOATIME", scm_from_int (O_NOATIME));
+#endif
+#ifdef O_DIRECTORY
+  scm_c_define ("O_DIRECTORY", scm_from_int (O_DIRECTORY));
+#endif
+#ifdef O_CLOEXEC
+  scm_c_define ("O_CLOEXEC", scm_from_int (O_CLOEXEC));
+#endif
+#ifdef O_DIRECT
+  scm_c_define ("O_DIRECT", scm_from_int (O_DIRECT));
+#endif
 
 #ifdef F_DUPFD  
   scm_c_define ("F_DUPFD", scm_from_int (F_DUPFD));
-- 
2.30.1