diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2024-05-18 05:20:23 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2024-05-18 05:20:23 +0000 |
commit | 6555656a94dbb7ea1fec4116aeb681ad815ed723 (patch) | |
tree | efef656f0c553227ab5ee2b518354fa9676b5b29 /lib | |
parent | a91c576090ec3fb4ff42fe8367c30697b6b083af (diff) |
Add pathconfat(2): pathconf(2) but with at-fd and flags arguments,
the latter supporting the ability to get timestamp resolution of
symlinks.
ok deraadt@ millert@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/Symbols.list | 2 | ||||
-rw-r--r-- | lib/libc/hidden/unistd.h | 3 | ||||
-rw-r--r-- | lib/libc/shlib_version | 2 | ||||
-rw-r--r-- | lib/libc/sys/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/sys/pathconf.2 | 93 |
5 files changed, 95 insertions, 9 deletions
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list index b1e7e916bbc..eb4d78cc947 100644 --- a/lib/libc/Symbols.list +++ b/lib/libc/Symbols.list @@ -157,6 +157,7 @@ _thread_sys_nfssvc _thread_sys_open _thread_sys_openat _thread_sys_pathconf +_thread_sys_pathconfat _thread_sys_pipe _thread_sys_pipe2 _thread_sys_pledge @@ -359,6 +360,7 @@ nfssvc open openat pathconf +pathconfat pipe pipe2 pledge diff --git a/lib/libc/hidden/unistd.h b/lib/libc/hidden/unistd.h index 74918f59675..f81cece3dd7 100644 --- a/lib/libc/hidden/unistd.h +++ b/lib/libc/hidden/unistd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unistd.h,v 1.13 2023/12/12 15:30:55 deraadt Exp $ */ +/* $OpenBSD: unistd.h,v 1.14 2024/05/18 05:20:22 guenther Exp $ */ /* * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> * @@ -110,6 +110,7 @@ PROTO_NORMAL(mkstemp); PROTO_NORMAL(nfssvc); PROTO_DEPRECATED(nice); PROTO_NORMAL(pathconf); +PROTO_NORMAL(pathconfat); /*PROTO_CANCEL(pause);*/ PROTO_NORMAL(pipe); PROTO_NORMAL(pipe2); diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index 9a3cbbdfde6..670da2562f6 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ major=100 -minor=0 +minor=1 # note: If changes were made to include/thread_private.h or if system calls # were added/changed then librthread/shlib_version must also be updated. diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index ff0ca6dc558..0e022f11687 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.178 2024/03/29 06:48:04 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.179 2024/05/18 05:20:22 guenther Exp $ # $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 @@ -62,7 +62,7 @@ ASM= __semctl.o __thrsigdivert.o \ mknod.o mknodat.o mlock.o mlockall.o mmap.o mount.o mprotect.o \ mquery.o msgctl.o msgget.o munlock.o munlockall.o munmap.o \ nfssvc.o \ - pathconf.o pipe.o pipe2.o pledge.o profil.o \ + pathconf.o pathconfat.o pipe.o pipe2.o pledge.o profil.o \ quotactl.o \ readlink.o readlinkat.o reboot.o \ rename.o renameat.o revoke.o rmdir.o \ diff --git a/lib/libc/sys/pathconf.2 b/lib/libc/sys/pathconf.2 index 099f3bb5be1..8be0618a7ed 100644 --- a/lib/libc/sys/pathconf.2 +++ b/lib/libc/sys/pathconf.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pathconf.2,v 1.25 2018/06/21 20:30:36 jmc Exp $ +.\" $OpenBSD: pathconf.2,v 1.26 2024/05/18 05:20:22 guenther Exp $ .\" $NetBSD: pathconf.2,v 1.2 1995/02/27 12:35:22 cgd Exp $ .\" .\" Copyright (c) 1993 @@ -30,11 +30,12 @@ .\" .\" @(#)pathconf.2 8.1 (Berkeley) 6/4/93 .\" -.Dd $Mdocdate: June 21 2018 $ +.Dd $Mdocdate: May 18 2024 $ .Dt PATHCONF 2 .Os .Sh NAME .Nm pathconf , +.Nm pathconfat , .Nm fpathconf .Nd get configurable pathname variables .Sh SYNOPSIS @@ -43,9 +44,13 @@ .Fn pathconf "const char *path" "int name" .Ft long .Fn fpathconf "int fd" "int name" +.In fcntl.h +.Ft long +.Fn pathconfat "int fd" "const char *path" "int name" "int flag" .Sh DESCRIPTION The -.Fn pathconf +.Fn pathconf , +.Fn pathconfat , and .Fn fpathconf functions provide a method for applications to determine the current @@ -132,9 +137,48 @@ Returns 1 if synchronized I/O is supported, otherwise 0. .It Dv _PC_TIMESTAMP_RESOLUTION The resolution in nanoseconds of file timestamps. .El +.Pp +The +.Fn pathconfat +function is equivalent to +.Fn pathconf +except in the case where +.Fa path +specifies a relative path. +In this case the file to be changed is determined relative to the directory +associated with the file descriptor +.Fa fd +instead of the current working directory. +.Pp +If +.Fn pathconfat +is passed the special value +.Dv AT_FDCWD +(defined in +.In fcntl.h ) +in the +.Fa fd +parameter, the current working directory is used. +If +.Fa flag +is also zero, the behavior is identical to a call to +.Fn pathconf . +.Pp +The +.Fa flag +argument is the bitwise OR of zero or more of the following values: +.Pp +.Bl -tag -width AT_SYMLINK_NOFOLLOW -offset indent -compact +.It Dv AT_SYMLINK_NOFOLLOW +If +.Fa path +names a symbolic link, then the system variable for the symbolic +link is queried. +.El .Sh RETURN VALUES If the call to -.Fn pathconf +.Fn pathconf , +.Fn pathconfat , or .Fn fpathconf is not successful, \-1 is returned and @@ -147,7 +191,8 @@ is not modified. Otherwise, the current variable value is returned. .Sh ERRORS If any of the following conditions occur, the -.Fn pathconf +.Fn pathconf , +.Fn pathconfat , and .Fn fpathconf functions shall return \-1 and set @@ -166,6 +211,8 @@ An I/O error occurred while reading from the file system. .El .Pp .Fn pathconf +and +.Fn pathconfat will fail if: .Bl -tag -width Er .It Bq Er ENOTDIR @@ -190,6 +237,38 @@ Too many symbolic links were encountered in translating the pathname. points outside the process's allocated address space. .El .Pp +Additionally, the +.Fn pathconfat +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa flag +argument was neither zero nor +.Dv AT_SYMLINK_NOFOLLOW . +.It Bq Er EBADF +The +.Fa path +argument specifies a relative path and the +.Fa fd +argument is neither +.Dv AT_FDCWD +nor a valid file descriptor. +.It Bq Er ENOTDIR +The +.Fa path +argument specifies a relative path and the +.Fa fd +argument is a valid file descriptor but it does not reference a directory. +.It Bq Er EACCES +The +.Fa path +argument specifies a relative path but search permission is denied +for the directory which the +.Fa fd +file descriptor references. +.El +.Pp .Fn fpathconf will fail if: .Bl -tag -width Er @@ -214,3 +293,7 @@ and .Fn fpathconf functions first appeared in .Bx 4.4 . +The +.Fn pathconfat +function first appeared in +.Ox 7.6 . |