xref: /freebsd/lib/libsys/open.2 (revision b79bd43f9ab3bf0dfd4744dee406782f0329134a)
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 April 3, 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_VERIFY
199verify the contents of the file with
200.Xr mac_veriexec 4
201.It Dv O_RESOLVE_BENEATH
202.Pq Xr openat 2 only
203path resolution must not cross the
204.Fa fd
205directory
206.It Dv O_PATH
207record only the target path in the opened descriptor
208.It Dv O_EMPTY_PATH
209.Pq Xr openat 2 only
210open file referenced by
211.Fa fd
212if path is empty
213.It Dv O_NAMEDATTR
214open a named attribute or named attribute directory
215.El
216.Pp
217Exactly one of the flags
218.Dv O_RDONLY ,
219.Dv O_WRONLY ,
220.Dv O_RDWR ,
221or
222.Dv O_EXEC
223must be provided.
224.Pp
225Opening a file with
226.Dv O_APPEND
227set causes each write on the resulting file descriptor
228to be appended to the end of the file.
229.Pp
230If
231.Dv O_TRUNC
232is specified and the
233file exists, the file is truncated to zero length.
234.Pp
235If
236.Dv O_CREAT
237is set, but file already exists,
238this flag has no effect except when
239.Dv O_EXCL
240is set too, in this case
241.Fn open
242fails with
243.Er EEXIST .
244This may be used to
245implement a simple exclusive access locking mechanism.
246In all other cases, the file is created
247and the access permission bits (see
248.Xr chmod 2)
249of the file mode
250are set to the value of the third argument taken as
251.Fa "mode_t mode"
252and passed through the
253.Xr umask 2 .
254This argument does not affect whether the file is opened
255for reading, writing, or for both.
256The open' request for a lock on the file, created with
257.Dv O_CREAT ,
258will never fail
259provided that the underlying file system supports locking;
260see also
261.Dv O_SHLOCK
262and
263.Dv O_EXLOCK
264below.
265.Pp
266If
267.Dv O_EXCL
268is set and the last component of the pathname is
269a symbolic link,
270.Fn open
271will fail even if the symbolic
272link points to a non-existent name.
273.Pp
274If
275.Dv O_NONBLOCK
276is specified and the
277.Fn open
278system call would
279block for some reason (for example, waiting for
280carrier on a dialup line),
281.Fn open
282returns immediately.
283The descriptor remains in non-blocking mode for subsequent operations.
284.Pp
285If
286.Dv O_SYNC
287is used in the mask, all writes will
288immediately and synchronously be written to disk.
289.Dv O_FSYNC
290is an historical synonym for
291.Dv O_SYNC .
292.Pp
293If
294.Dv O_DSYNC
295is used in the mask, all data and metadata required to read the data will be
296synchronously written to disk, but changes to metadata such as file access and
297modification timestamps may be written later.
298.Pp
299If
300.Dv O_NOFOLLOW
301is used in the mask and the target file passed to
302.Fn open
303is a symbolic link then the
304.Fn open
305will fail.
306.Pp
307When opening a file, a lock with
308.Xr flock 2
309semantics can be obtained by setting
310.Dv O_SHLOCK
311for a shared lock, or
312.Dv O_EXLOCK
313for an exclusive lock.
314.Pp
315.Dv O_DIRECT
316may be used to minimize or eliminate the cache effects of reading and writing.
317The system will attempt to avoid caching the data you read or write.
318If it cannot avoid caching the data,
319it will minimize the impact the data has on the cache.
320Use of this flag can drastically reduce performance if not used with care.
321The semantics of this flag are filesystem dependent,
322and some filesystems may ignore it entirely.
323.Pp
324.Dv O_NOCTTY
325may be used to ensure the OS does not assign this file as the
326controlling terminal when it opens a tty device.
327This is the default on
328.Fx ,
329but is present for
330POSIX
331compatibility.
332The
333.Fn open
334system call will not assign controlling terminals on
335.Fx .
336.Pp
337.Dv O_TTY_INIT
338may be used to ensure the OS restores the terminal attributes when
339initially opening a TTY.
340This is the default on
341.Fx ,
342but is present for
343POSIX
344compatibility.
345The initial call to
346.Fn open
347on a TTY will always restore default terminal attributes on
348.Fx .
349.Pp
350.Dv O_DIRECTORY
351may be used to ensure the resulting file descriptor refers to a
352directory.
353This flag can be used to prevent applications with elevated privileges
354from opening files which are even unsafe to open with
355.Dv O_RDONLY ,
356such as device nodes.
357.Pp
358.Dv O_CLOEXEC
359may be used to set
360.Dv FD_CLOEXEC
361flag for the newly returned file descriptor.
362.Pp
363.Dv O_VERIFY
364may be used to indicate to the kernel that the contents of the file should
365be verified before allowing the open to proceed.
366The details of what
367.Dq verified
368means is implementation specific.
369The run-time linker (rtld) uses this flag to ensure shared objects have
370been verified before operating on them.
371.Pp
372.Dv O_RESOLVE_BENEATH
373returns
374.Er ENOTCAPABLE
375if any intermediate component of the specified relative path does not
376reside in the directory hierarchy beneath the starting directory.
377Absolute paths or even the temporal escape from beneath of the starting
378directory is not allowed.
379.Pp
380When a directory
381is opened with
382.Dv O_SEARCH ,
383execute permissions are checked at open time.
384The returned file descriptor
385may not be used for any read operations like
386.Xr getdirentries 2 .
387The primary use of this descriptor is as the lookup descriptor for the
388.Fn *at
389family of functions.
390If
391.Dv O_SEARCH
392was not requested at open time, then the
393.Fn *at
394functions use the current directory permissions for the directory referenced
395by the descriptor at the time of the
396.Fn *at
397call.
398.Pp
399.Dv O_PATH
400returns a file descriptor that can be used as a directory file descriptor for
401.Fn openat
402and other system calls taking a file descriptor argument, like
403.Xr fstatat 2
404and others.
405The other functionality of the returned file descriptor is limited to
406the following descriptor-level operations:
407.Pp
408.Bl -tag -width __acl_aclcheck_fd -offset indent -compact
409.It Xr fcntl 2
410but advisory locking is not allowed
411.It Xr dup 2
412.It Xr close 2
413.It Xr fstat 2
414.It Xr fstatfs 2
415.It Xr fchdir 2
416.It Xr fchroot 2
417.It Xr fexecve 2
418.It Xr funlinkat 2
419can be passed as the third argument
420.It Dv SCM_RIGHTS
421can be passed over a
422.Xr unix 4
423socket using a
424.Dv SCM_RIGHTS
425message
426.It Xr kqueue 2
427only with
428.Dv EVFILT_VNODE
429.It Xr __acl_get_fd 2
430.It Xr __acl_aclcheck_fd 2
431.It Xr extattr 2
432.It Xr capsicum 4
433can be passed to
434.Fn cap_*_limit
435and
436.Fn cap_*_get
437system calls (such as
438.Xr cap_rights_limit 2 ) .
439.El
440.Pp
441Other operations like
442.Xr read 2 ,
443.Xr ftruncate 2 ,
444and any other that operate on file and not on file descriptor (except
445.Xr fstat 2 ) ,
446are not allowed.
447.Pp
448A file descriptor created with the
449.Dv O_PATH
450flag can be opened as a normal (operable) file descriptor by
451specifying it as the
452.Fa fd
453argument to
454.Fn openat
455with an empty
456.Fa path
457and the
458.Dv O_EMPTY_PATH
459flag.
460Such an open behaves as if the current path of the file referenced by
461.Fa fd
462is passed, except that path walk permissions are not checked.
463See also the description of
464.Dv AT_EMPTY_PATH
465flag for
466.Xr fstatat 2
467and related syscalls.
468.Pp
469Conversely, a file descriptor
470.Dv fd
471referencing a filesystem file can be converted to the
472.Dv O_PATH
473type of descriptor by using the following call
474.Dl opath_fd = openat(fd, \[dq]\[dq], O_EMPTY_PATH | O_PATH);
475.Pp
476If successful,
477.Fn open
478returns a non-negative integer, termed a file descriptor.
479It returns \-1 on failure.
480The file descriptor value returned is the lowest numbered descriptor
481currently not in use by the process.
482The file pointer used to mark the current position within the
483file is set to the beginning of the file.
484.Pp
485If a sleeping open of a device node from
486.Xr devfs 4
487is interrupted by a signal, the call always fails with
488.Er EINTR ,
489even if the
490.Dv SA_RESTART
491flag is set for the signal.
492A sleeping open of a fifo (see
493.Xr mkfifo 2 )
494is restarted as normal.
495.Pp
496When a new file is created, it is assigned the group of the directory
497which contains it.
498.Pp
499Unless
500.Dv O_CLOEXEC
501flag was specified,
502the new descriptor is set to remain open across
503.Xr execve 2
504system calls; see
505.Xr close 2 ,
506.Xr fcntl 2
507and the description of the
508.Dv O_CLOEXEC
509flag.
510.Pp
511When the
512.Dv O_NAMEDATTR
513flag is specified for an
514.Fn openat
515where the
516.Fa fd
517argument is for a file object,
518a named attribute for the file object
519is opened and not the file object itself.
520If the
521.Dv O_CREAT
522flag has been specified as well, the named attribute will be
523created if it does not exist.
524When the
525.Dv O_NAMEDATTR
526flag is specified for a
527.Fn open ,
528a named attribute for the current working directory is opened and
529not the current working directory.
530The
531.Fa path
532argument for this
533.Fn openat
534or
535.Fn open
536must be a single component name with no embedded
537.Ql / .
538If the
539.Fa path
540argument is
541.Ql .\&
542then the named attribute directory for the file object is opened.
543(See
544.Xr named_attribute 7
545for more information.)
546.Pp
547The system imposes a limit on the number of file descriptors
548open simultaneously by one process.
549The
550.Xr getdtablesize 2
551system call returns the current system limit.
552.Sh RETURN VALUES
553If successful,
554.Fn open
555and
556.Fn openat
557return a non-negative integer, termed a file descriptor.
558They return \-1 on failure, and set
559.Va errno
560to indicate the error.
561.Sh ERRORS
562The named file is opened unless:
563.Bl -tag -width Er
564.It Bq Er ENOTDIR
565A component of the path prefix is not a directory.
566.It Bq Er ENAMETOOLONG
567A component of a pathname exceeded 255 characters,
568or an entire path name exceeded 1023 characters.
569.It Bq Er ENOENT
570.Dv O_CREAT
571is not set and the named file does not exist.
572.It Bq Er ENOENT
573A component of the path name that must exist does not exist.
574.It Bq Er EACCES
575Search permission is denied for a component of the path prefix.
576.It Bq Er EACCES
577The required permissions (for reading and/or writing)
578are denied for the given flags.
579.It Bq Er EACCES
580.Dv O_TRUNC
581is specified and write permission is denied.
582.It Bq Er EACCES
583.Dv O_CREAT
584is specified,
585the file does not exist,
586and the directory in which it is to be created
587does not permit writing.
588.It Bq Er EPERM
589.Dv O_CREAT
590is specified, the file does not exist, and the directory in which it is to be
591created has its immutable flag set, see the
592.Xr chflags 2
593manual page for more information.
594.It Bq Er EPERM
595The named file has its immutable flag set and the file is to be modified.
596.It Bq Er EPERM
597The named file has its append-only flag set, the file is to be modified, and
598.Dv O_TRUNC
599is specified or
600.Dv O_APPEND
601is not specified.
602.It Bq Er ELOOP
603Too many symbolic links were encountered in translating the pathname.
604.It Bq Er EISDIR
605The named file is a directory, and the arguments specify
606it is to be modified.
607.It Bq Er EISDIR
608The named file is a directory, and the flags specified
609.Dv O_CREAT
610without
611.Dv O_DIRECTORY .
612.It Bq Er EROFS
613The named file resides on a read-only file system,
614and the file is to be modified.
615.It Bq Er EROFS
616.Dv O_CREAT
617is specified and the named file would reside on a read-only file system.
618.It Bq Er EMFILE
619The process has already reached its limit for open file descriptors.
620.It Bq Er ENFILE
621The system file table is full.
622.It Bq Er EMLINK
623.Dv O_NOFOLLOW
624was specified and the target is a symbolic link.
625POSIX
626specifies a different error for this case; see the note in
627.Sx STANDARDS
628below.
629.It Bq Er ENXIO
630The named file is a character special or block
631special file, and the device associated with this special file
632does not exist.
633.It Bq Er ENXIO
634.Dv O_NONBLOCK
635is set, the named file is a fifo,
636.Dv O_WRONLY
637is set, and no process has the file open for reading.
638.It Bq Er EINTR
639The
640.Fn open
641operation was interrupted by a signal.
642.It Bq Er EOPNOTSUPP
643.Dv O_SHLOCK
644or
645.Dv O_EXLOCK
646is specified but the underlying file system does not support locking.
647.It Bq Er EOPNOTSUPP
648The named file is a special file mounted through a file system that
649does not support access to it (for example, NFS).
650.It Bq Er EWOULDBLOCK
651.Dv O_NONBLOCK
652and one of
653.Dv O_SHLOCK
654or
655.Dv O_EXLOCK
656is specified and the file is locked.
657.It Bq Er ENOSPC
658.Dv O_CREAT
659is specified,
660the file does not exist,
661and the directory in which the entry for the new file is being placed
662cannot be extended because there is no space left on the file
663system containing the directory.
664.It Bq Er ENOSPC
665.Dv O_CREAT
666is specified,
667the file does not exist,
668and there are no free inodes on the file system on which the
669file is being created.
670.It Bq Er EDQUOT
671.Dv O_CREAT
672is specified,
673the file does not exist,
674and the directory in which the entry for the new file
675is being placed cannot be extended because the
676user's quota of disk blocks on the file system
677containing the directory has been exhausted.
678.It Bq Er EDQUOT
679.Dv O_CREAT
680is specified,
681the file does not exist,
682and the user's quota of inodes on the file system on
683which the file is being created has been exhausted.
684.It Bq Er EIO
685An I/O error occurred while making the directory entry or
686allocating the inode for
687.Dv O_CREAT .
688.It Bq Er EINTEGRITY
689Corrupted data was detected while reading from the file system.
690.It Bq Er ETXTBSY
691The file is a pure procedure (shared text) file that is being
692executed and the
693.Fn open
694system call requests write access.
695.It Bq Er EFAULT
696The
697.Fa path
698argument
699points outside the process's allocated address space.
700.It Bq Er EEXIST
701.Dv O_CREAT
702and
703.Dv O_EXCL
704were specified and the file exists.
705.It Bq Er EOPNOTSUPP
706An attempt was made to open a socket (not currently implemented).
707.It Bq Er EINVAL
708An attempt was made to open a descriptor with an illegal combination
709of
710.Dv O_RDONLY ,
711.Dv O_WRONLY ,
712or
713.Dv O_RDWR ,
714and
715.Dv O_EXEC
716or
717.Dv O_SEARCH .
718.It Bq Er EINVAL
719.Dv O_CREAT
720is specified,
721and the last component of the
722.Fa path
723argument is invalid on the file system on which the file is being created.
724.It Bq Er EBADF
725The
726.Fa path
727argument does not specify an absolute path and the
728.Fa fd
729argument is
730neither
731.Dv AT_FDCWD
732nor a valid file descriptor open for searching.
733.It Bq Er ENOTDIR
734The
735.Fa path
736argument is not an absolute path and
737.Fa fd
738is neither
739.Dv AT_FDCWD
740nor a file descriptor associated with a directory.
741.It Bq Er ENOTDIR
742.Dv O_DIRECTORY
743is specified and the file is not a directory.
744.It Bq Er ECAPMODE
745.Dv AT_FDCWD
746is specified and the process is in capability mode.
747.It Bq Er ECAPMODE
748.Fn open
749was called and the process is in capability mode.
750.It Bq Er ENOTCAPABLE
751.Fa path
752is an absolute path and the process is in capability mode.
753.It Bq Er ENOTCAPABLE
754.Fa path
755is an absolute path and
756.Dv O_RESOLVE_BENEATH
757is specified.
758.It Bq Er ENOTCAPABLE
759.Fa path
760contains a ".." component leading to a directory outside
761of the directory hierarchy specified by
762.Fa fd
763and the process is in capability mode.
764.It Bq Er ENOTCAPABLE
765.Fa path
766contains a ".." component leading to a directory outside
767of the directory hierarchy specified by
768.Fa fd
769and
770.Dv O_RESOLVE_BENEATH
771is specified.
772.It Bq Er ENOTCAPABLE
773.Fa path
774contains a ".." component, the
775.Dv vfs.lookup_cap_dotdot
776.Xr sysctl 3
777is set, and the process is in capability mode.
778.It Bq Er ENOATTR
779.Dv O_NAMEDATTR
780has been specified and the file object is not a named attribute
781directory or named attribute.
782.El
783.Sh SEE ALSO
784.Xr chmod 2 ,
785.Xr close 2 ,
786.Xr dup 2 ,
787.Xr fexecve 2 ,
788.Xr fhopen 2 ,
789.Xr getdtablesize 2 ,
790.Xr getfh 2 ,
791.Xr lgetfh 2 ,
792.Xr lseek 2 ,
793.Xr read 2 ,
794.Xr umask 2 ,
795.Xr write 2 ,
796.Xr fopen 3 ,
797.Xr capsicum 4 ,
798.Xr named_attribute 7
799.Sh STANDARDS
800These functions are specified by
801.St -p1003.1-2008 .
802.Pp
803.Fx
804sets
805.Va errno
806to
807.Er EMLINK instead of
808.Er ELOOP
809as specified by
810POSIX
811when
812.Dv O_NOFOLLOW
813is set in flags and the final component of pathname is a symbolic link
814to distinguish it from the case of too many symbolic link traversals
815in one of its non-final components.
816.Pp
817The Open Group Extended API Set 2 specification, that introduced the
818.Fn *at
819API, required that the test for whether
820.Fa fd
821is searchable is based on whether
822.Fa fd
823is open for searching, not whether the underlying directory currently
824permits searches.
825The present implementation of the
826.Fa openat
827system call is believed to be compatible with
828.\" .St -p1003.1-2017 ,
829.\" XXX: This should be replaced in the future when an appropriate argument to
830.\" the St macro is available: -p1003.1-2017
831.No IEEE Std 1003.1-2008, 2017 Edition ("POSIX.1") ,
832which specifies that behavior for
833.Dv O_SEARCH ,
834in the absence of the flag the implementation checks the current
835permissions of a directory.
836.Sh HISTORY
837The
838.Fn open
839function appeared in
840.At v1 .
841The
842.Fn openat
843function was introduced in
844.Fx 8.0 .
845.Dv O_DSYNC
846appeared in 13.0.
847.Dv O_NAMEDATTR
848appeared in 15.0.
849.Sh BUGS
850The
851.Fa mode
852argument is variadic and may result in different calling conventions
853than might otherwise be expected.
854