Index: include/unistd.h =================================================================== --- include/unistd.h (revision 195423) +++ include/unistd.h (working copy) @@ -513,6 +513,7 @@ int initgroups(const char *, gid_t); int iruserok(unsigned long, int, const char *, const char *); int iruserok_sa(const void *, int, int, const char *, const char *); int issetugid(void); +long lpathconf(const char *, int); #ifndef _MKDTEMP_DECLARED char *mkdtemp(char *); #define _MKDTEMP_DECLARED Index: lib/libc/sys/pathconf.2 =================================================================== --- lib/libc/sys/pathconf.2 (revision 195423) +++ lib/libc/sys/pathconf.2 (working copy) @@ -28,11 +28,12 @@ .\" @(#)pathconf.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 25, 2009 +.Dd July 7, 2009 .Dt PATHCONF 2 .Os .Sh NAME .Nm pathconf , +.Nm lpathconf , .Nm fpathconf .Nd get configurable pathname variables .Sh LIBRARY @@ -42,10 +43,13 @@ .Ft long .Fn pathconf "const char *path" "int name" .Ft long +.Fn lpathconf "const char *path" "int name" +.Ft long .Fn fpathconf "int fd" "int name" .Sh DESCRIPTION The -.Fn pathconf +.Fn pathconf , +.Fn lpathconf and .Fn fpathconf system calls provide a method for applications to determine the current @@ -53,7 +57,9 @@ value of a configurable system limit or option var with a pathname or file descriptor. .Pp For -.Fn pathconf , +.Fn pathconf +and +.Fn lpathconf , the .Fa path argument is the name of a file or directory. @@ -68,6 +74,18 @@ argument specifies the system variable to be queri Symbolic constants for each name value are found in the include file .Li . .Pp +The +.Fn lpathconf +system call is like +.Fn pathconf +except in the case where the named file is a symbolic link, +in which case +.Fn lpathconf +returns information about the link, +while +.Fn pathconf +returns information about the file the link references. +.Pp The available values are as follows: .Pp .Bl -tag -width 6n @@ -239,3 +257,7 @@ and .Fn fpathconf system calls first appeared in .Bx 4.4 . +The +.Fn lpathconf +system call first appeared in +.Fx 8.0 . Index: lib/libc/sys/Symbol.map =================================================================== --- lib/libc/sys/Symbol.map (revision 195423) +++ lib/libc/sys/Symbol.map (working copy) @@ -346,6 +346,7 @@ FBSD_1.1 { jail_set; jail_remove; linkat; + lpathconf; mkdirat; mkfifoat; mknodat; Index: lib/libc/sys/Makefile.inc =================================================================== --- lib/libc/sys/Makefile.inc (revision 195423) +++ lib/libc/sys/Makefile.inc (working copy) @@ -159,6 +159,7 @@ MLINKS+=mq_send.2 mq_timedsend.2 MLINKS+=ntp_adjtime.2 ntp_gettime.2 MLINKS+=open.2 openat.2 MLINKS+=pathconf.2 fpathconf.2 +MLINKS+=pathconf.2 lpathconf.2 MLINKS+=read.2 pread.2 read.2 preadv.2 read.2 readv.2 MLINKS+=readlink.2 readlinkat.2 MLINKS+=recv.2 recvfrom.2 recv.2 recvmsg.2 Index: bin/chmod/chmod.c =================================================================== --- bin/chmod/chmod.c (revision 195423) +++ bin/chmod/chmod.c (working copy) @@ -238,7 +238,7 @@ may_have_nfs4acl(const FTSENT *ent) previous_dev = ent->fts_statp->st_dev; supports_acls = 0; - ret = pathconf(ent->fts_accpath, _PC_ACL_NFS4); + ret = lpathconf(ent->fts_accpath, _PC_ACL_NFS4); if (ret > 0) supports_acls = 1; else if (ret < 0 && errno != EINVAL) Index: sys/kern/vfs_syscalls.c =================================================================== --- sys/kern/vfs_syscalls.c (revision 195423) +++ sys/kern/vfs_syscalls.c (working copy) @@ -2532,6 +2532,47 @@ kern_pathconf(struct thread *td, char *path, enum return (error); } +#ifndef _SYS_SYSPROTO_H_ +struct lpathconf_args { + char *path; + int name; +}; +#endif +int +lpathconf(td, uap) + struct thread *td; + register struct lpathconf_args /* { + char *path; + int name; + } */ *uap; +{ + + return (kern_lpathconf(td, uap->path, UIO_USERSPACE, uap->name)); +} + +int +kern_lpathconf(struct thread *td, char *path, enum uio_seg pathseg, int name) +{ + struct nameidata nd; + int error, vfslocked; + + NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | + AUDITVNODE1, pathseg, path, td); + if ((error = namei(&nd)) != 0) + return (error); + vfslocked = NDHASGIANT(&nd); + NDFREE(&nd, NDF_ONLY_PNBUF); + + /* If asynchronous I/O is available, it works for all files. */ + if (name == _PC_ASYNC_IO) + td->td_retval[0] = async_io_version; + else + error = VOP_PATHCONF(nd.ni_vp, name, td->td_retval); + vput(nd.ni_vp); + VFS_UNLOCK_GIANT(vfslocked); + return (error); +} + /* * Return target name of a symbolic link. */ Index: sys/kern/syscalls.master =================================================================== --- sys/kern/syscalls.master (revision 195423) +++ sys/kern/syscalls.master (working copy) @@ -910,5 +910,6 @@ struct msqid_ds *buf); } 512 AUE_SHMCTL NOSTD { int shmctl(int shmid, int cmd, \ struct shmid_ds *buf); } +513 AUE_LPATHCONF STD { int lpathconf(char *path, int name); } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master Index: sys/bsm/audit_kevents.h =================================================================== --- sys/bsm/audit_kevents.h (revision 195423) +++ sys/bsm/audit_kevents.h (working copy) @@ -597,6 +597,7 @@ #define AUE_PWRITE 43193 /* Darwin/FreeBSD. */ #define AUE_FSCTL 43194 /* Darwin. */ #define AUE_FFSCTL 43195 /* Darwin. */ +#define AUE_LPATHCONF 43196 /* FreeBSD. */ /* * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the Index: sys/compat/freebsd32/syscalls.master =================================================================== --- sys/compat/freebsd32/syscalls.master (revision 195423) +++ sys/compat/freebsd32/syscalls.master (working copy) @@ -900,3 +900,4 @@ struct msqid_ds32 *buf); } 512 AUE_SHMCTL STD { int freebsd32_shmctl(int shmid, int cmd, \ struct shmid_ds32 *buf); } +513 AUE_LPATHCONF STD { int lpathconf(char *path, int name); } Index: sys/sys/syscallsubr.h =================================================================== --- sys/sys/syscallsubr.h (revision 195423) +++ sys/sys/syscallsubr.h (working copy) @@ -146,6 +146,8 @@ int kern_openat(struct thread *td, int fd, char *p enum uio_seg pathseg, int flags, int mode); int kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name); +int kern_lpathconf(struct thread *td, char *path, enum uio_seg pathseg, + int name); int kern_pipe(struct thread *td, int fildes[2]); int kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset); int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr,