xref: /freebsd/lib/libsys/open.2 (revision ae07a5805b1906f29e786f415d67bef334557bd3)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd May 17, 2025
29.Dt OPEN 2
30.Os
31.Sh NAME
32.Nm open , openat
33.Nd open or create a file for reading, writing or executing
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In fcntl.h
38.Ft int
39.Fn open "const char *path" "int flags" "..."
40.Ft int
41.Fn openat "int fd" "const char *path" "int flags" "..."
42.Sh DESCRIPTION
43The file name specified by
44.Fa path
45is opened
46for either execution or reading and/or writing as specified by the
47argument
48.Fa flags
49and the file descriptor returned to the calling process.
50The
51.Fa flags
52argument may indicate the file is to be
53created if it does not exist (by specifying the
54.Dv O_CREAT
55flag).
56In this case
57.Fn open
58and
59.Fn openat
60require an additional argument
61.Fa "mode_t mode" ,
62and the file is created with mode
63.Fa mode
64as described in
65.Xr chmod 2
66and modified by the process' umask value (see
67.Xr umask 2 ) .
68.Pp
69The
70.Fn openat
71function is equivalent to the
72.Fn open
73function except in the case where the
74.Fa path
75specifies a relative path.
76For
77.Fn openat
78and relative
79.Fa path ,
80the file to be opened is determined relative to the directory
81associated with the file descriptor
82.Fa fd
83instead of the current working directory.
84The
85.Fa flag
86parameter and the optional fourth parameter correspond exactly to
87the parameters of
88.Fn open .
89If
90.Fn openat
91is passed the special value
92.Dv AT_FDCWD
93in the
94.Fa fd
95parameter, the current working directory is used
96and the behavior is identical to a call to
97.Fn open .
98.Pp
99When
100.Fn openat
101is called with an absolute
102.Fa path ,
103it ignores the
104.Fa fd
105argument.
106.Pp
107In
108.Xr capsicum 4
109capability mode,
110.Fn open
111is not permitted.
112The
113.Fa path
114argument to
115.Fn openat
116must be strictly relative to a file descriptor
117.Fa fd ;
118that is,
119.Fa path
120must not be an absolute path and must not contain ".." components
121which cause the path resolution to escape the directory hierarchy
122starting at
123.Fa fd .
124Additionally, no symbolic link in
125.Fa path
126may target absolute path or contain escaping ".." components.
127.Fa fd
128must not be
129.Dv AT_FDCWD .
130.Pp
131If the
132.Dv vfs.lookup_cap_dotdot
133.Xr sysctl 3
134MIB is set to zero, ".." components in the paths,
135used in capability mode,
136are completely disabled.
137If the
138.Dv vfs.lookup_cap_dotdot_nonlocal
139MIB is set to zero, ".." is not allowed if found on non-local filesystem.
140.Pp
141The
142.Fa flags
143are formed by
144.Em or Ns 'ing
145the following values:
146.Pp
147.Bl -tag -width O_RESOLVE_BENEATH
148.It Dv O_RDONLY
149open for reading only
150.It Dv O_WRONLY
151open for writing only
152.It Dv O_RDWR
153open for reading and writing
154.It Dv O_EXEC
155open for execute only
156.It Dv O_SEARCH
157open for search only
158(an alias for
159.Dv O_EXEC
160typically used with
161.Dv O_DIRECTORY )
162.It Dv O_NONBLOCK
163do not block on open
164.It Dv O_APPEND
165set file pointer to the end of the file before each write
166.It Dv O_CREAT
167create file if it does not exist
168.It Dv O_TRUNC
169truncate size to 0
170.It Dv O_EXCL
171fail if
172.Dv O_CREAT
173is set and the file exists
174.It Dv O_SHLOCK
175atomically obtain a shared lock
176.It Dv O_EXLOCK
177atomically obtain an exclusive lock
178.It Dv O_DIRECT
179read and write directly from the backing store
180.It Dv O_FSYNC
181synchronous data and metadata writes
182.Pq historical synonym for Dv O_SYNC
183.It Dv O_SYNC
184synchronous data and metadata writes
185.It Dv O_DSYNC
186synchronous data writes
187.It Dv O_NOFOLLOW
188do not follow symlinks
189.It Dv O_NOCTTY
190ignored
191.It Dv O_TTY_INIT
192ignored
193.It Dv O_DIRECTORY
194error if file is not a directory
195.It Dv O_CLOEXEC
196automatically close file on
197.Xr execve 2
198.It Dv O_CLOFORK
199automatically close file on any child process created with
200.Fn fork 2
201.It Dv O_VERIFY
202verify the contents of the file with
203.Xr mac_veriexec 4
204.It Dv O_RESOLVE_BENEATH
205.Pq Xr openat 2 only
206path resolution must not cross the
207.Fa fd
208directory
209.It Dv O_PATH
210record only the target path in the opened descriptor
211.It Dv O_EMPTY_PATH
212.Pq Xr openat 2 only
213open file referenced by
214.Fa fd
215if path is empty
216.It Dv O_NAMEDATTR
217open a named attribute or named attribute directory
218.El
219.Pp
220Exactly one of the flags
221.Dv O_RDONLY ,
222.Dv O_WRONLY ,
223.Dv O_RDWR ,
224or
225.Dv O_EXEC
226must be provided.
227.Pp
228Opening a file with
229.Dv O_APPEND
230set causes each write on the resulting file descriptor
231to be appended to the end of the file.
232.Pp
233If
234.Dv O_TRUNC
235is specified and the
236file exists, the file is truncated to zero length.
237.Pp
238If
239.Dv O_CREAT
240is set, but file already exists,
241this flag has no effect except when
242.Dv O_EXCL
243is set too, in this case
244.Fn open
245fails with
246.Er EEXIST .
247This may be used to
248implement a simple exclusive access locking mechanism.
249In all other cases, the file is created
250and the access permission bits (see
251.Xr chmod 2)
252of the file mode
253are set to the value of the third argument taken as
254.Fa "mode_t mode"
255and passed through the
256.Xr umask 2 .
257This argument does not affect whether the file is opened
258for reading, writing, or for both.
259The open' request for a lock on the file, created with
260.Dv O_CREAT ,
261will never fail
262provided that the underlying file system supports locking;
263see also
264.Dv O_SHLOCK
265and
266.Dv O_EXLOCK
267below.
268.Pp
269If
270.Dv O_EXCL
271is set and the last component of the pathname is
272a symbolic link,
273.Fn open
274will fail even if the symbolic
275link points to a non-existent name.
276.Pp
277If
278.Dv O_NONBLOCK
279is specified and the
280.Fn open
281system call would
282block for some reason (for example, waiting for
283carrier on a dialup line),
284.Fn open
285returns immediately.
286The descriptor remains in non-blocking mode for subsequent operations.
287.Pp
288If
289.Dv O_SYNC
290is used in the mask, all writes will
291immediately and synchronously be written to disk.
292.Dv O_FSYNC
293is an historical synonym for
294.Dv O_SYNC .
295.Pp
296If
297.Dv O_DSYNC
298is used in the mask, all data and metadata required to read the data will be
299synchronously written to disk, but changes to metadata such as file access and
300modification timestamps may be written later.
301.Pp
302If
303.Dv O_NOFOLLOW
304is used in the mask and the target file passed to
305.Fn open
306is a symbolic link then the
307.Fn open
308will fail.
309.Pp
310When opening a file, a lock with
311.Xr flock 2
312semantics can be obtained by setting
313.Dv O_SHLOCK
314for a shared lock, or
315.Dv O_EXLOCK
316for an exclusive lock.
317.Pp
318.Dv O_DIRECT
319may be used to minimize or eliminate the cache effects of reading and writing.
320The system will attempt to avoid caching the data you read or write.
321If it cannot avoid caching the data,
322it will minimize the impact the data has on the cache.
323Use of this flag can drastically reduce performance if not used with care.
324The semantics of this flag are filesystem dependent,
325and some filesystems may ignore it entirely.
326.Pp
327.Dv O_NOCTTY
328may be used to ensure the OS does not assign this file as the
329controlling terminal when it opens a tty device.
330This is the default on
331.Fx ,
332but is present for
333POSIX
334compatibility.
335The
336.Fn open
337system call will not assign controlling terminals on
338.Fx .
339.Pp
340.Dv O_TTY_INIT
341may be used to ensure the OS restores the terminal attributes when
342initially opening a TTY.
343This is the default on
344.Fx ,
345but is present for
346POSIX
347compatibility.
348The initial call to
349.Fn open
350on a TTY will always restore default terminal attributes on
351.Fx .
352.Pp
353.Dv O_DIRECTORY
354may be used to ensure the resulting file descriptor refers to a
355directory.
356This flag can be used to prevent applications with elevated privileges
357from opening files which are even unsafe to open with
358.Dv O_RDONLY ,
359such as device nodes.
360.Pp
361.Dv O_CLOEXEC
362may be used to set
363.Dv FD_CLOEXEC
364flag for the newly returned file descriptor.
365.Pp
366.Dv O_CLOFORK
367may be used to set
368.Dv FD_CLOFORK
369flag for the newly returned file descriptor.
370The file will be closed on any child process created with
371.Fn fork 2 ,
372.Fn vfork 2
373or
374.Fn rfork 2
375with the
376.Dv RFFDG
377flag, remaining open in the parent.
378Both the
379.Dv O_CLOEXEC
380and
381.Dv O_CLOFORK
382flags can be modified with the
383.Dv F_SETFD
384.Fn fcntl 2
385command.
386.Pp
387.Dv O_VERIFY
388may be used to indicate to the kernel that the contents of the file should
389be verified before allowing the open to proceed.
390The details of what
391.Dq verified
392means is implementation specific.
393The run-time linker (rtld) uses this flag to ensure shared objects have
394been verified before operating on them.
395.Pp
396.Dv O_RESOLVE_BENEATH
397returns
398.Er ENOTCAPABLE
399if any intermediate component of the specified relative path does not
400reside in the directory hierarchy beneath the starting directory.
401Absolute paths or even the temporal escape from beneath of the starting
402directory is not allowed.
403.Pp
404When a directory
405is opened with
406.Dv O_SEARCH ,
407execute permissions are checked at open time.
408The returned file descriptor
409may not be used for any read operations like
410.Xr getdirentries 2 .
411The primary use of this descriptor is as the lookup descriptor for the
412.Fn *at
413family of functions.
414If
415.Dv O_SEARCH
416was not requested at open time, then the
417.Fn *at
418functions use the current directory permissions for the directory referenced
419by the descriptor at the time of the
420.Fn *at
421call.
422.Pp
423.Dv O_PATH
424returns a file descriptor that can be used as a directory file descriptor for
425.Fn openat
426and other system calls taking a file descriptor argument, like
427.Xr fstatat 2
428and others.
429The other functionality of the returned file descriptor is limited to
430the following descriptor-level operations:
431.Pp
432.Bl -tag -width __acl_aclcheck_fd -offset indent -compact
433.It Xr fcntl 2
434but advisory locking is not allowed
435.It Xr dup 2
436.It Xr close 2
437.It Xr fstat 2
438.It Xr fstatfs 2
439.It Xr fchdir 2
440.It Xr fchroot 2
441.It Xr fexecve 2
442.It Xr funlinkat 2
443can be passed as the third argument
444.It Dv SCM_RIGHTS
445can be passed over a
446.Xr unix 4
447socket using a
448.Dv SCM_RIGHTS
449message
450.It Xr kqueue 2
451only with
452.Dv EVFILT_VNODE
453.It Xr __acl_get_fd 2
454.It Xr __acl_aclcheck_fd 2
455.It Xr extattr 2
456.It Xr capsicum 4
457can be passed to
458.Fn cap_*_limit
459and
460.Fn cap_*_get
461system calls (such as
462.Xr cap_rights_limit 2 ) .
463.El
464.Pp
465Other operations like
466.Xr read 2 ,
467.Xr ftruncate 2 ,
468and any other that operate on file and not on file descriptor (except
469.Xr fstat 2 ) ,
470are not allowed.
471.Pp
472A file descriptor created with the
473.Dv O_PATH
474flag can be opened as a normal (operable) file descriptor by
475specifying it as the
476.Fa fd
477argument to
478.Fn openat
479with an empty
480.Fa path
481and the
482.Dv O_EMPTY_PATH
483flag.
484Such an open behaves as if the current path of the file referenced by
485.Fa fd
486is passed, except that path walk permissions are not checked.
487See also the description of
488.Dv AT_EMPTY_PATH
489flag for
490.Xr fstatat 2
491and related syscalls.
492.Pp
493Conversely, a file descriptor
494.Dv fd
495referencing a filesystem file can be converted to the
496.Dv O_PATH
497type of descriptor by using the following call
498.Dl opath_fd = openat(fd, \[dq]\[dq], O_EMPTY_PATH | O_PATH);
499.Pp
500If successful,
501.Fn open
502returns a non-negative integer, termed a file descriptor.
503It returns \-1 on failure.
504The file descriptor value returned is the lowest numbered descriptor
505currently not in use by the process.
506The file pointer used to mark the current position within the
507file is set to the beginning of the file.
508.Pp
509If a sleeping open of a device node from
510.Xr devfs 4
511is interrupted by a signal, the call always fails with
512.Er EINTR ,
513even if the
514.Dv SA_RESTART
515flag is set for the signal.
516A sleeping open of a fifo (see
517.Xr mkfifo 2 )
518is restarted as normal.
519.Pp
520When a new file is created, it is assigned the group of the directory
521which contains it.
522.Pp
523Unless
524.Dv O_CLOEXEC
525flag was specified,
526the new descriptor is set to remain open across
527.Xr execve 2
528system calls; see
529.Xr close 2 ,
530.Xr fcntl 2
531and the description of the
532.Dv O_CLOEXEC
533flag.
534.Pp
535When the
536.Dv O_NAMEDATTR
537flag is specified for an
538.Fn openat
539where the
540.Fa fd
541argument is for a file object,
542a named attribute for the file object
543is opened and not the file object itself.
544If the
545.Dv O_CREAT
546flag has been specified as well, the named attribute will be
547created if it does not exist.
548When the
549.Dv O_NAMEDATTR
550flag is specified for a
551.Fn open ,
552a named attribute for the current working directory is opened and
553not the current working directory.
554The
555.Fa path
556argument for this
557.Fn openat
558or
559.Fn open
560must be a single component name with no embedded
561.Ql / .
562If the
563.Fa path
564argument is
565.Ql .\&
566then the named attribute directory for the file object is opened.
567(See
568.Xr named_attribute 7
569for more information.)
570.Pp
571The system imposes a limit on the number of file descriptors
572open simultaneously by one process.
573The
574.Xr getdtablesize 2
575system call returns the current system limit.
576.Sh RETURN VALUES
577If successful,
578.Fn open
579and
580.Fn openat
581return a non-negative integer, termed a file descriptor.
582They return \-1 on failure, and set
583.Va errno
584to indicate the error.
585.Sh ERRORS
586The named file is opened unless:
587.Bl -tag -width Er
588.It Bq Er ENOTDIR
589A component of the path prefix is not a directory.
590.It Bq Er ENAMETOOLONG
591A component of a pathname exceeded 255 characters,
592or an entire path name exceeded 1023 characters.
593.It Bq Er ENOENT
594.Dv O_CREAT
595is not set and the named file does not exist.
596.It Bq Er ENOENT
597A component of the path name that must exist does not exist.
598.It Bq Er EACCES
599Search permission is denied for a component of the path prefix.
600.It Bq Er EACCES
601The required permissions (for reading and/or writing)
602are denied for the given flags.
603.It Bq Er EACCES
604.Dv O_TRUNC
605is specified and write permission is denied.
606.It Bq Er EACCES
607.Dv O_CREAT
608is specified,
609the file does not exist,
610and the directory in which it is to be created
611does not permit writing.
612.It Bq Er EPERM
613.Dv O_CREAT
614is specified, the file does not exist, and the directory in which it is to be
615created has its immutable flag set, see the
616.Xr chflags 2
617manual page for more information.
618.It Bq Er EPERM
619The named file has its immutable flag set and the file is to be modified.
620.It Bq Er EPERM
621The named file has its append-only flag set, the file is to be modified, and
622.Dv O_TRUNC
623is specified or
624.Dv O_APPEND
625is not specified.
626.It Bq Er ELOOP
627Too many symbolic links were encountered in translating the pathname.
628.It Bq Er EISDIR
629The named file is a directory, and the arguments specify
630it is to be modified.
631.It Bq Er EISDIR
632The named file is a directory, and the flags specified
633.Dv O_CREAT
634without
635.Dv O_DIRECTORY .
636.It Bq Er EROFS
637The named file resides on a read-only file system,
638and the file is to be modified.
639.It Bq Er EROFS
640.Dv O_CREAT
641is specified and the named file would reside on a read-only file system.
642.It Bq Er EMFILE
643The process has already reached its limit for open file descriptors.
644.It Bq Er ENFILE
645The system file table is full.
646.It Bq Er EMLINK
647.Dv O_NOFOLLOW
648was specified and the target is a symbolic link.
649POSIX
650specifies a different error for this case; see the note in
651.Sx STANDARDS
652below.
653.It Bq Er ENXIO
654The named file is a character special or block
655special file, and the device associated with this special file
656does not exist.
657.It Bq Er ENXIO
658.Dv O_NONBLOCK
659is set, the named file is a fifo,
660.Dv O_WRONLY
661is set, and no process has the file open for reading.
662.It Bq Er EINTR
663The
664.Fn open
665operation was interrupted by a signal.
666.It Bq Er EOPNOTSUPP
667.Dv O_SHLOCK
668or
669.Dv O_EXLOCK
670is specified but the underlying file system does not support locking.
671.It Bq Er EOPNOTSUPP
672The named file is a special file mounted through a file system that
673does not support access to it (for example, NFS).
674.It Bq Er EWOULDBLOCK
675.Dv O_NONBLOCK
676and one of
677.Dv O_SHLOCK
678or
679.Dv O_EXLOCK
680is specified and the file is locked.
681.It Bq Er ENOSPC
682.Dv O_CREAT
683is specified,
684the file does not exist,
685and the directory in which the entry for the new file is being placed
686cannot be extended because there is no space left on the file
687system containing the directory.
688.It Bq Er ENOSPC
689.Dv O_CREAT
690is specified,
691the file does not exist,
692and there are no free inodes on the file system on which the
693file is being created.
694.It Bq Er EDQUOT
695.Dv O_CREAT
696is specified,
697the file does not exist,
698and the directory in which the entry for the new file
699is being placed cannot be extended because the
700user's quota of disk blocks on the file system
701containing the directory has been exhausted.
702.It Bq Er EDQUOT
703.Dv O_CREAT
704is specified,
705the file does not exist,
706and the user's quota of inodes on the file system on
707which the file is being created has been exhausted.
708.It Bq Er EIO
709An I/O error occurred while making the directory entry or
710allocating the inode for
711.Dv O_CREAT .
712.It Bq Er EINTEGRITY
713Corrupted data was detected while reading from the file system.
714.It Bq Er ETXTBSY
715The file is a pure procedure (shared text) file that is being
716executed and the
717.Fn open
718system call requests write access.
719.It Bq Er EFAULT
720The
721.Fa path
722argument
723points outside the process's allocated address space.
724.It Bq Er EEXIST
725.Dv O_CREAT
726and
727.Dv O_EXCL
728were specified and the file exists.
729.It Bq Er EOPNOTSUPP
730An attempt was made to open a socket (not currently implemented).
731.It Bq Er EINVAL
732An attempt was made to open a descriptor with an illegal combination
733of
734.Dv O_RDONLY ,
735.Dv O_WRONLY ,
736or
737.Dv O_RDWR ,
738and
739.Dv O_EXEC
740or
741.Dv O_SEARCH .
742.It Bq Er EINVAL
743.Dv O_CREAT
744is specified,
745and the last component of the
746.Fa path
747argument is invalid on the file system on which the file is being created.
748.It Bq Er EBADF
749The
750.Fa path
751argument does not specify an absolute path and the
752.Fa fd
753argument is
754neither
755.Dv AT_FDCWD
756nor a valid file descriptor open for searching.
757.It Bq Er ENOTDIR
758The
759.Fa path
760argument is not an absolute path and
761.Fa fd
762is neither
763.Dv AT_FDCWD
764nor a file descriptor associated with a directory.
765.It Bq Er ENOTDIR
766.Dv O_DIRECTORY
767is specified and the file is not a directory.
768.It Bq Er ECAPMODE
769.Dv AT_FDCWD
770is specified and the process is in capability mode.
771.It Bq Er ECAPMODE
772.Fn open
773was called and the process is in capability mode.
774.It Bq Er ENOTCAPABLE
775.Fa path
776is an absolute path and the process is in capability mode.
777.It Bq Er ENOTCAPABLE
778.Fa path
779is an absolute path and
780.Dv O_RESOLVE_BENEATH
781is specified.
782.It Bq Er ENOTCAPABLE
783.Fa path
784contains a ".." component leading to a directory outside
785of the directory hierarchy specified by
786.Fa fd
787and the process is in capability mode.
788.It Bq Er ENOTCAPABLE
789.Fa path
790contains a ".." component leading to a directory outside
791of the directory hierarchy specified by
792.Fa fd
793and
794.Dv O_RESOLVE_BENEATH
795is specified.
796.It Bq Er ENOTCAPABLE
797.Fa path
798contains a ".." component, the
799.Dv vfs.lookup_cap_dotdot
800.Xr sysctl 3
801is set, and the process is in capability mode.
802.It Bq Er ENOATTR
803.Dv O_NAMEDATTR
804has been specified and the file object is not a named attribute
805directory or named attribute.
806.El
807.Sh SEE ALSO
808.Xr chmod 2 ,
809.Xr close 2 ,
810.Xr dup 2 ,
811.Xr fexecve 2 ,
812.Xr fhopen 2 ,
813.Xr getdtablesize 2 ,
814.Xr getfh 2 ,
815.Xr lgetfh 2 ,
816.Xr lseek 2 ,
817.Xr read 2 ,
818.Xr umask 2 ,
819.Xr write 2 ,
820.Xr fopen 3 ,
821.Xr capsicum 4 ,
822.Xr named_attribute 7
823.Sh STANDARDS
824These functions are specified by
825.St -p1003.1-2008 .
826.Pp
827.Fx
828sets
829.Va errno
830to
831.Er EMLINK instead of
832.Er ELOOP
833as specified by
834POSIX
835when
836.Dv O_NOFOLLOW
837is set in flags and the final component of pathname is a symbolic link
838to distinguish it from the case of too many symbolic link traversals
839in one of its non-final components.
840.Pp
841The Open Group Extended API Set 2 specification, that introduced the
842.Fn *at
843API, required that the test for whether
844.Fa fd
845is searchable is based on whether
846.Fa fd
847is open for searching, not whether the underlying directory currently
848permits searches.
849The present implementation of the
850.Fa openat
851system call is believed to be compatible with
852.\" .St -p1003.1-2017 ,
853.\" XXX: This should be replaced in the future when an appropriate argument to
854.\" the St macro is available: -p1003.1-2017
855.No IEEE Std 1003.1-2008, 2017 Edition ("POSIX.1") ,
856which specifies that behavior for
857.Dv O_SEARCH ,
858in the absence of the flag the implementation checks the current
859permissions of a directory.
860.Sh HISTORY
861The
862.Fn open
863function appeared in
864.At v1 .
865The
866.Fn openat
867function was introduced in
868.Fx 8.0 .
869.Dv O_DSYNC
870appeared in 13.0.
871.Dv O_NAMEDATTR
872appeared in 15.0.
873.Dv O_CLOFORK
874appeared in
875.Fx 15.0 .
876.Sh BUGS
877The
878.Fa mode
879argument is variadic and may result in different calling conventions
880than might otherwise be expected.
881