bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable


From: Jim Meyering
Subject: Re: [PATCH] fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable
Date: Wed, 01 Sep 2010 22:59:05 +0200

Paul Eggert wrote:
> POSIX 2008 specifies a new 'open' flag O_SEARCH, which can be used
> when one needs search access to a directory but not read access.
> On systems where it is available, it works in some cases where
> O_RDONLY does not, namely on directories that are searchable but
> not readable, and which need only to be searchable.  If O_SEARCH
> is not available, fall back to the traditional method of using
> O_RDONLY.
>
> * lib/fcntl.in.h (O_SEARCH): #define to O_RDONLY if not defined.
> * lib/chdir-long.c (cdb_advance_fd): Use O_SEARCH, not O_RDONLY,
> when opening a directory that needs only to be searchable.
> * lib/chdir-safer.c (chdir_no_follow): Likewise.
> * lib/fts.c (diropen, fts_open, fd_ring_check): Likewise.
> * lib/openat-proc.c (openat_proc_name): Likewise.
> * lib/openat.c (openat_needs_fchdir): Likewise.
> * lib/save-cwd.c (save_cwd): Likewise.
> * lib/savewd.c (savewd_save, savewd_chdir): Likewise.

By the way, thanks for doing all of this (haven't looked in detail yet).
Once O_SEARCH hits systems we care about, these uses will plug what
should be the final hole in some directory-traversal code.
I.e., once this functionality is ubiquitous enough (and native *at
syscalls), there is no longer an argument to use chdir in a module like fts.



reply via email to

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