bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH v3 1/2] include/fcntl.h: Define O_IGNORE_CTTY


From: Adhemerval Zanella Netto
Subject: Re: [PATCH v3 1/2] include/fcntl.h: Define O_IGNORE_CTTY
Date: Mon, 5 Jun 2023 15:24:59 -0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.2


On 04/06/23 17:42, Sergey Bugaev via Libc-alpha wrote:
> 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 | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/include/fcntl.h b/include/fcntl.h
> index be435047..d788db2e 100644
> --- a/include/fcntl.h
> +++ b/include/fcntl.h
> @@ -33,6 +33,21 @@ 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 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
> +

I think it would be better to add a sysdeps/unix/sysv/linux/fcntl.h which
defines O_IGNORE_CTTY  unconditionally and include the default one (either
directly or though include_next.h).  We currently are trying to avoid the 
"#ifdef ...", so a code that does not define, where is should, would fail 
at compile time.

> +
>  #if IS_IN (rtld)
>  #  include <dl-fcntl.h>
>  #endif



reply via email to

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