mirror of https://github.com/mkerrisk/man-pages
open.2: Enhance rationale discussion for openat() and friends
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
a3708b57a5
commit
54305f5b5f
15
man2/open.2
15
man2/open.2
|
@ -1314,11 +1314,24 @@ of the directory prefix given to
|
|||
.BR open ()
|
||||
could be changed in parallel with the call to
|
||||
.BR open ().
|
||||
Suppose, for example, that we wish to create the file
|
||||
.I path/to/xxx.dep
|
||||
if the file
|
||||
.I path/to/xxx
|
||||
exists.
|
||||
The problem is that between the existence check and the file creation step,
|
||||
.I path
|
||||
or
|
||||
.I to
|
||||
(which might be symbolic links)
|
||||
could be modified to point to a different location.
|
||||
Such races can be avoided by
|
||||
opening a file descriptor for the target directory,
|
||||
and then specifying that file descriptor as the
|
||||
.I dirfd
|
||||
argument of
|
||||
argument of (say)
|
||||
.BR fstatat (2)
|
||||
and
|
||||
.BR openat ().
|
||||
|
||||
Second,
|
||||
|
|
Loading…
Reference in New Issue