diff mbox series

[RFC,4/5] include/fcntl.h: Define O_IGNORE_CTTY

Message ID 20230417225857.2006561-5-bugaevc@gmail.com
State New
Headers show
Series O_IGNORE_CTTY everywhere | expand

Commit Message

Sergey Bugaev April 17, 2023, 10:58 p.m. UTC
This internal definition makes it possible to use O_IGNORE_CTTY in
the glibc codebase unconditionally, no matter whether the current port
provides it or not (i.e. both on Hurd and on Linux). Along with the
definition, this adds a small guide on when O_IGNORE_CTTY is to be used.

The following commit will actually make use of O_IGNORE_CTTY
throughout the glibc codebase.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 include/fcntl.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/include/fcntl.h b/include/fcntl.h
index be435047..3de40827 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -33,6 +33,22 @@  extern int __openat_2 (int __fd, const char *__path, int __oflag);
 extern int __openat64_2 (int __fd, const char *__path, int __oflag);
 
 
+/* Makes open () & friends slightly faster on the Hurd, but can only be used
+   (without altering user-visible behavior) when we're sure that the file
+   we're opening is not (at the moment) our controlling terminal.  Use this
+   when:
+   - opening well-known files internally (utmp, nss db);
+   - opening files with user-specified names that can not reasonably be ttys
+     (sem_open, shm_open);
+   - opening new (previously unused) ttys (openpty).
+   Don't use this when:
+   - doing a general-purpose open () with a user-controlled path that could
+     well be "/dev/tty" (fopen).  */
+#ifndef O_IGNORE_CTTY
+#  define O_IGNORE_CTTY	0
+#endif
+
+
 #if IS_IN (rtld)
 #  include <dl-fcntl.h>
 #endif