[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Sergey Bugaev
Subject: [RFC PATCH 4/5] include/fcntl.h: Define O_IGNORE_CTTY
Date: Tue, 18 Apr 2023 01:58:56 +0300

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 --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 
 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
 #if IS_IN (rtld)
 #  include <dl-fcntl.h>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]