Commit Graph

330 Commits

Author SHA1 Message Date
Michael Kerrisk bffbb22fda iconv.1, locale.1, memusage.1, memusagestat.1, pldd.1, sprof.1, _syscall.2, add_key.2, adjtimex.2, bind.2, bpf.2, chown.2, clone.2, close.2, copy_file_range.2, eventfd.2, fanotify_init.2, fanotify_mark.2, fork.2, fsync.2, futex.2, getdents.2, getrlimit.2, getxattr.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, ioctl_fat.2, ioctl_getfsmap.2, ioctl_ns.2, ioctl_tty.2, ioctl_userfaultfd.2, kcmp.2, keyctl.2, listen.2, listxattr.2, mbind.2, membarrier.2, memfd_create.2, mkdir.2, move_pages.2, mremap.2, msync.2, nfsservctl.2, open.2, perf_event_open.2, pidfd_send_signal.2, pipe.2, pivot_root.2, pkey_alloc.2, process_vm_readv.2, ptrace.2, readlink.2, readv.2, recv.2, recvmmsg.2, rename.2, request_key.2, s390_runtime_instr.2, sched_setaffinity.2, seccomp.2, send.2, sendmmsg.2, sigaltstack.2, signalfd.2, socket.2, socketpair.2, splice.2, spu_create.2, spu_run.2, statfs.2, syscall.2, sysctl.2, sysfs.2, tee.2, timer_getoverrun.2, timer_settime.2, umount.2, userfaultfd.2, utimensat.2, wait4.2, INFINITY.3, __ppc_get_timebase.3, __setfpucw.3, abort.3, aio_cancel.3, aio_error.3, aio_read.3, aio_return.3, atexit.3, backtrace.3, basename.3, bsearch.3, bswap.3, cacos.3, cacosh.3, catan.3, catanh.3, cexp2.3, clock_getcpuclockid.3, clog2.3, cmsg.3, confstr.3, div.3, dl_iterate_phdr.3, dlerror.3, dlinfo.3, dlopen.3, dlsym.3, duplocale.3, encrypt.3, end.3, endian.3, envz_add.3, err.3, expm1.3, fdim.3, flockfile.3, fmtmsg.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo_a.3, getauxval.3, getdate.3, getdtablesize.3, getgrent_r.3, getgrouplist.3, gethostbyname.3, getline.3, getnameinfo.3, getopt.3, getprotoent_r.3, getpwent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, getutent.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_ntop.3, inet_pton.3, insque.3, killpg.3, makecontext.3, mallinfo.3, malloc.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbsnrtowcs.3, mbstowcs.3, mcheck.3, mempcpy.3, mq_getattr.3, mq_notify.3, mtrace.3, newlocale.3, nextafter.3, ntp_gettime.3, offsetof.3, open_memstream.3, pow.3, printf.3, pthread_attr_init.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setstack.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_detach.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_join.3, pthread_mutex_consistent.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_spin_init.3, pthread_testcancel.3, pthread_tryjoin_np.3, ptsname.3, qsort.3, rand.3, random.3, remainder.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, sem_getvalue.3, sem_wait.3, setaliasent.3, setlogmask.3, sigwait.3, sincos.3, sockatmark.3, stdarg.3, stpcpy.3, strcat.3, strfmon.3, strptime.3, strtod.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, tsearch.3, uselocale.3, wcstok.3, wcstombs.3, wordexp.3, y0.3, loop.4, vcs.4, veth.4, charmap.5, core.5, filesystems.5, gai.conf.5, hosts.5, hosts.equiv.5, locale.5, nss.5, repertoiremap.5, securetty.5, shells.5, ttytype.5, ascii.7, complex.7, cpuset.7, credentials.7, fanotify.7, hier.7, inotify.7, ip.7, mount_namespaces.7, mq_overview.7, netlink.7, network_namespaces.7, pid_namespaces.7, pkeys.7, rtld-audit.7, rtnetlink.7, sem_overview.7, signal-safety.7, sock_diag.7, spufs.7, standards.7, symlink.7, tcp.7, time_namespaces.7, unix.7, user_namespaces.7, xattr.7, ldconfig.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-06-09 14:48:40 +02:00
Michael Kerrisk c8fb1c6d4a gettid.2, open.2, seccomp.2, pthread_mutex_consistent.3, signal.7, xattr.7: Put SEE ALSO entries in alphabetical order
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-19 07:23:34 +02:00
Michael Kerrisk 4146f81b7d open.2: Some '*at' APIs have functionality that isn't in conventional APIs
Note that another reason to use the *at() APIs is to access
'flags' functionality that is not available in the corresponding
conventional APIs.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-12 09:43:01 +02:00
Michael Kerrisk 96c44b8f50 open.2: Explain ways in which a 'directory file descriptor' can be obtained
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-12 08:45:06 +02:00
Michael Kerrisk aec13430b1 open.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-12 08:03:52 +02:00
Michael Kerrisk 5c30e7cd9d open.2: Add a few more APIs to list in "Rationale for openat()..."
There have been a few more dirfd APIs added in recent times.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-12 07:43:41 +02:00
Michael Kerrisk 34aeffa286 open.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-21 20:51:58 +02:00
Michael Kerrisk 510adbed8e open.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-21 16:31:23 +02:00
Michael Kerrisk e64c566c57 open.2: Add openat2() to list of APIs that take a 'dirfd' argument
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-21 16:26:51 +02:00
Michael Kerrisk 53dcd8d262 open.2: tfix
Reported-by: Helge Kreutzmann <debian@helgefjell.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-19 21:59:43 +02:00
Michael Kerrisk d9e7db1b39 open.2: Tweaks to Joseph Sible's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-13 12:27:48 +02:00
Joseph C. Sible 2ddf885a4f open.2: Document fs.protected_fifos and fs.protected_regular
The sysctls fs.protected_fifos and fs.protected_regular can cause
open(2) to fail with EACCES (see Documentation/sysctl/fs.rst for
details.)

Signed-off-by: Joseph C. Sible <josephcsible@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-13 12:27:48 +02:00
Michael Kerrisk ed09120acd accept.2, epoll_create.2, inotify_add_watch.2, open.2, open_by_handle_at.2, pidfd_open.2, dirfd.3, posix_openpt.3, shm_open.3: Fix clumsy wording around "nonnegative file descriptors"
Reported-by: Christian Brauner <christian@brauner.io>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-10 09:41:55 +02:00
Michael Kerrisk ed6fe0056d open.2: Note EINVAL error for invalid character in basename of 'pathname'
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-06 11:37:01 +02:00
Michael Kerrisk 7a11fc63b8 open.2: Clarify that O_NOFOLLOW is relevant (only) for basename of 'pathname'
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-03-30 12:32:07 +02:00
Michael Kerrisk 4b322a2fc8 open.2: Minor tweaks to Aleksa Sarai's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-03-30 08:45:58 +02:00
Aleksa Sarai a2dbb2e378 open.2: Add references to new openat2(2) page
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-03-30 08:37:02 +02:00
Michael Kerrisk 6b621d05b3 _exit.2, capget.2, fcntl.2, futex.2, listen.2, memfd_create.2, modify_ldt.2, move_pages.2, open.2, perf_event_open.2, ptrace.2, set_thread_area.2, stime.2, syscall.2, sysctl.2, userfaultfd.2, cmsg.3, exit.3, ftime.3, getpt.3, malloc.3, console_codes.4, loop.4, inotify.7, netlink.7, packet.7, rtnetlink.7, tcp.7, unix.7, vsock.7, ldconfig.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-02-09 11:53:28 +01:00
Michael Kerrisk a2587fbb2e open.2: In O_TMPFILE example, describe alternative linkat() call
This was already shown in an earlier version of the page,
but Adam Borowski's patch replaced it with an alternative.
Probably, it is better to show both possibilities.

Reported-by: "Joseph C. Sible" <josephcsible@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-02-07 17:59:34 +01:00
Adam Borowski fc29a199d9 open.2: No need for /proc to make an O_TMPFILE file permanent
In the example snippet, we already have the fd, thus there's no
need to refer to the file by name.  And, /proc/ might be not
mounted or not accessible.

Noticed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-02-07 17:30:45 +01:00
Michael Kerrisk f3fdbe2812 open.2: tfix
Reported-by: Дилян Палаузов <dilyan.palauzov@aegee.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-24 12:16:07 +02:00
Michael Kerrisk 352c4c5ca6 open.2: Minor fixes to Eugene's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-01-10 06:42:35 +13:00
Eugene Syromiatnikov 6deb3733ac open.2: Mention presence of unused O_RSYNC definition
O_RSYNC is defined in <asm/fcntl.h> on HP PA-RISC, but is not
used anyway.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-01-10 06:35:10 +13:00
Michael Kerrisk d40e0bfc27 open.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-01-10 06:34:38 +13:00
Michael Kerrisk 319e9b31ed open.2: Minor fixes to Eugene's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-01-10 06:32:39 +13:00
Eugene Syromiatnikov 8132c11589 open.2: Document FASYNC usage in Linux UAPI headers
Linux's <asm/fcntl.h> defines FASYNC instead of O_ASYNC; document
this peculiarity.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-01-10 06:30:47 +13:00
Michael Kerrisk 115bbafa8b open.2: Minor fix: split distinct ENOENT cases into separate list entries
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-09-28 21:48:59 +02:00
Michael Kerrisk 8b5bbcfabc open.2: Minor wording fix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-31 21:34:32 +02:00
Lucas Werkmeister 71b12d0a57 open.2: Document ENXIO for sockets
Linux returns ENXIO when attempting to open() a UNIX domain socket.
Kernel-wise, I believe this happens in fs/inode.c [1], where a constant
`no_open` function returning -ENXIO is registered as the default open()
handler for inodes in inode_init_always(), and is not specialized in
nit_special_inode() as it is for other types.

Seen in the systemd v238 source code [2].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/inode.c?h=v4.16
[2]: https://github.com/systemd/systemd/blob/v238/src/core/execute.c#L412

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-31 21:34:32 +02:00
Michael Kerrisk 3897a3f89f open.2: Clarify a special use case of O_NONBLOCK for devices
The wording is a little confusing, suggesting that this is
the primary use of O_NONBLOCK. Fix that.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-18 10:56:16 +02:00
Michael Kerrisk f2a110725b open.2: Clarify that O_NONBLOCK has no effect on poll/epoll/select
Reported-by: Robin Kuzmin <kuzmin.robin@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-18 10:25:53 +02:00
Michael Kerrisk b0972b3b05 open.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-18 10:14:49 +02:00
Andrew Price abd34f349d open.2: Remove O_DIRECT-related quotation
Remove a section that adds no benefit to the discussion of O_DIRECT.

Signed-off-by: Andrew Price <andy@andrewprice.me.uk>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-06 09:29:46 +02:00
Michael Kerrisk 09b8afdc04 execve.2, fallocate.2, getrlimit.2, io_submit.2, membarrier.2, mmap.2, msgget.2, open.2, ptrace.2, readv.2, semget.2, shmget.2, shutdown.2, syscall.2, wait.2, wait4.2, crypt.3, encrypt.3, fseek.3, getcwd.3, makedev.3, pthread_create.3, puts.3, tsearch.3, elf.5, filesystems.5, group.5, passwd.5, sysfs.5, mount_namespaces.7, posixoptions.7, time.7, unix.7, vdso.7, xattr.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-30 17:41:31 +02:00
Jakub Wilk 8e13d56651 open.2: Add missing argument for snprintf() in example code
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-27 14:02:47 +02:00
Jann Horn 19d371260e open.2: Document more -ETXTBSY conditions
The first one happens in
do_filp_open -> path_openat -> do_last -> handle_truncate -> do_truncate
-> notify_change -> simple_setattr -> setattr_prepare -> inode_newsize_ok.

Demo:

[...]
[...]
[...]
open("/x", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 ETXTBSY (Text file busy)
[...]
[...]
open("/x", O_WRONLY|O_CREAT, 0666)      = 3
dup2(3, 1)                              = 1
close(3)                                = 0
read(0, "\0\0\0\0[...]"..., 512) = 512
write(1, "\0\0\0\0[...]"..., 512) = 512
[...]

The second one is in kernel_read_file -> deny_write_access.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-03-27 22:19:49 +02:00
Michael Kerrisk 3130d10bd3 open.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-11-09 10:10:09 +01:00
Michael Kerrisk 76f054b155 open.2: Since glibc 2.26, the open() wrapper always uses the openat() syscall
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-11-09 08:32:33 +01:00
G. Branden Robinson fedb2ff513 open.2: tfix
This one crept in during the first bit of the "will fail" -> "fails"
migration.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-10-23 06:34:09 +02:00
Michael Kerrisk 26cd31fd4a access.2, delete_module.2, eventfd.2, fallocate.2, fcntl.2, getrandom.2, init_module.2, open.2, seccomp.2, timerfd_create.2, openpty.3, pthread_spin_lock.3, shm_open.3, tempnam.3, fifo.7, keyrings.7, pid_namespaces.7, sched.7, thread-keyring.7: wfix (will fail --> fail/fails)
Reported-by: Pedro Alves <palves@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-10-20 16:55:10 +02:00
Michael Kerrisk 9e4be7e9fc open.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-10-20 12:28:06 +02:00
Michael Kerrisk 5c6f8de052 open.2: ERRORS: document EINVAL error for invalid filename
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-29 11:40:03 +02:00
Michael Kerrisk 6a11a5d439 open.2: Clarify that O_TMPFILE creates a *regular* file
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-28 17:21:12 +02:00
Michael Kerrisk ca20a8a5c8 open.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-28 17:21:12 +02:00
Michael Kerrisk 431161696a open.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-28 17:21:12 +02:00
Michael Kerrisk ef81e101f5 open.2: Make the purpose of open() a little clearer at the start of the page
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-28 17:21:12 +02:00
Michael Kerrisk 6f72cae5db open.2: Make it explicit that O_CREAT creates a regular file
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-28 17:21:12 +02:00
Michael Kerrisk 069d2f9aec open.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-19 22:09:25 +02:00
Michael Kerrisk 4a3b9ffc46 open.2: By contrast with O_RDONLY, no file permissions are required for O_PATH
Note one of the significant advantages of O_PATH: many of the
operations applied to O_PATH file descriptors don't require
read permission, so there's no readon why the open() itself
should require read permission.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-19 22:08:26 +02:00
Michael Kerrisk f3cd742ceb open.2: Minor technical fix
In the discussion of O_PATH, make it completely obvious that
fchdir() file descriptor must refer to a directory.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-09-19 15:48:48 +02:00