summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-02-07 21:46:43 +0000
committerjhb <jhb@FreeBSD.org>2005-02-07 21:46:43 +0000
commit60bd53b164c6f3ebe8ff23d8c89209d883ddbb7a (patch)
tree8c6a2a777387d07a00bc6d49209eb44568944332
parent221a30b414f82933a09b844b71a55202395df598 (diff)
downloadFreeBSD-src-60bd53b164c6f3ebe8ff23d8c89209d883ddbb7a.zip
FreeBSD-src-60bd53b164c6f3ebe8ff23d8c89209d883ddbb7a.tar.gz
Implement a kern_pathconf() wrapper for pathconf() which can take the
filename from either a user space or a kernel space pointer.
-rw-r--r--sys/kern/vfs_extattr.c18
-rw-r--r--sys/kern/vfs_syscalls.c18
-rw-r--r--sys/sys/syscallsubr.h2
3 files changed, 26 insertions, 12 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index cfefd08..81a3235 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -2223,22 +2223,28 @@ pathconf(td, uap)
int name;
} */ *uap;
{
- int error;
+
+ return (kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name));
+}
+
+int
+kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name)
+{
struct nameidata nd;
- int vfslocked;
+ int error, vfslocked;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, 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 (uap->name == _PC_ASYNC_IO)
+ if (name == _PC_ASYNC_IO)
td->td_retval[0] = async_io_version;
else
- error = VOP_PATHCONF(nd.ni_vp, uap->name, td->td_retval);
+ error = VOP_PATHCONF(nd.ni_vp, name, td->td_retval);
vput(nd.ni_vp);
VFS_UNLOCK_GIANT(vfslocked);
return (error);
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index cfefd08..81a3235 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2223,22 +2223,28 @@ pathconf(td, uap)
int name;
} */ *uap;
{
- int error;
+
+ return (kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name));
+}
+
+int
+kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name)
+{
struct nameidata nd;
- int vfslocked;
+ int error, vfslocked;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, 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 (uap->name == _PC_ASYNC_IO)
+ if (name == _PC_ASYNC_IO)
td->td_retval[0] = async_io_version;
else
- error = VOP_PATHCONF(nd.ni_vp, uap->name, td->td_retval);
+ error = VOP_PATHCONF(nd.ni_vp, name, td->td_retval);
vput(nd.ni_vp);
VFS_UNLOCK_GIANT(vfslocked);
return (error);
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 74ee11e..a996ba7 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -88,6 +88,8 @@ int kern_nanosleep(struct thread *td, struct timespec *rqt,
struct timespec *rmt);
int kern_open(struct thread *td, char *path, enum uio_seg pathseg,
int flags, int mode);
+int kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg,
+ int name);
int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr,
int data);
int kern_readlink(struct thread *td, char *path, enum uio_seg pathseg,
OpenPOWER on IntegriCloud