vfs_syscalls.c (441eb16a953ac93d356e0cda28b45cb66ad70bcc) | vfs_syscalls.c (de774e422e7f8abf9d4c6084165c9de66f11b2de) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph --- 91 unchanged lines hidden (view full) --- 100static int getutimens(const struct timespec *, enum uio_seg, 101 struct timespec *, int *); 102static int setutimes(struct thread *td, struct vnode *, 103 const struct timespec *, int, int); 104static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred, 105 struct thread *td); 106static int kern_fhlinkat(struct thread *td, int fd, const char *path, 107 enum uio_seg pathseg, fhandle_t *fhp); | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph --- 91 unchanged lines hidden (view full) --- 100static int getutimens(const struct timespec *, enum uio_seg, 101 struct timespec *, int *); 102static int setutimes(struct thread *td, struct vnode *, 103 const struct timespec *, int, int); 104static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred, 105 struct thread *td); 106static int kern_fhlinkat(struct thread *td, int fd, const char *path, 107 enum uio_seg pathseg, fhandle_t *fhp); |
108static int kern_getfhat(struct thread *td, int flags, int fd, 109 const char *path, enum uio_seg pathseg, fhandle_t *fhp); | |
110static int kern_readlink_vp(struct vnode *vp, char *buf, enum uio_seg bufseg, 111 size_t count, struct thread *td); 112static int kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, 113 const char *path, enum uio_seg segflag); 114 115static uint64_t 116at2cnpflags(u_int at_flags, u_int mask) 117{ --- 4192 unchanged lines hidden (view full) --- 4310 fhandle_t *fhp; 4311}; 4312#endif 4313int 4314sys_lgetfh(struct thread *td, struct lgetfh_args *uap) 4315{ 4316 4317 return (kern_getfhat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->fname, | 108static int kern_readlink_vp(struct vnode *vp, char *buf, enum uio_seg bufseg, 109 size_t count, struct thread *td); 110static int kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, 111 const char *path, enum uio_seg segflag); 112 113static uint64_t 114at2cnpflags(u_int at_flags, u_int mask) 115{ --- 4192 unchanged lines hidden (view full) --- 4308 fhandle_t *fhp; 4309}; 4310#endif 4311int 4312sys_lgetfh(struct thread *td, struct lgetfh_args *uap) 4313{ 4314 4315 return (kern_getfhat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->fname, |
4318 UIO_USERSPACE, uap->fhp)); | 4316 UIO_USERSPACE, uap->fhp, UIO_USERSPACE)); |
4319} 4320 4321#ifndef _SYS_SYSPROTO_H_ 4322struct getfh_args { 4323 char *fname; 4324 fhandle_t *fhp; 4325}; 4326#endif 4327int 4328sys_getfh(struct thread *td, struct getfh_args *uap) 4329{ 4330 4331 return (kern_getfhat(td, 0, AT_FDCWD, uap->fname, UIO_USERSPACE, | 4317} 4318 4319#ifndef _SYS_SYSPROTO_H_ 4320struct getfh_args { 4321 char *fname; 4322 fhandle_t *fhp; 4323}; 4324#endif 4325int 4326sys_getfh(struct thread *td, struct getfh_args *uap) 4327{ 4328 4329 return (kern_getfhat(td, 0, AT_FDCWD, uap->fname, UIO_USERSPACE, |
4332 uap->fhp)); | 4330 uap->fhp, UIO_USERSPACE)); |
4333} 4334 4335/* 4336 * syscall for the rpc.lockd to use to translate an open descriptor into 4337 * a NFS file handle. 4338 * 4339 * warning: do not remove the priv_check() call or this becomes one giant 4340 * security hole. --- 9 unchanged lines hidden (view full) --- 4350int 4351sys_getfhat(struct thread *td, struct getfhat_args *uap) 4352{ 4353 4354 if ((uap->flags & ~(AT_SYMLINK_NOFOLLOW | AT_BENEATH | 4355 AT_RESOLVE_BENEATH)) != 0) 4356 return (EINVAL); 4357 return (kern_getfhat(td, uap->flags, uap->fd, uap->path, UIO_USERSPACE, | 4331} 4332 4333/* 4334 * syscall for the rpc.lockd to use to translate an open descriptor into 4335 * a NFS file handle. 4336 * 4337 * warning: do not remove the priv_check() call or this becomes one giant 4338 * security hole. --- 9 unchanged lines hidden (view full) --- 4348int 4349sys_getfhat(struct thread *td, struct getfhat_args *uap) 4350{ 4351 4352 if ((uap->flags & ~(AT_SYMLINK_NOFOLLOW | AT_BENEATH | 4353 AT_RESOLVE_BENEATH)) != 0) 4354 return (EINVAL); 4355 return (kern_getfhat(td, uap->flags, uap->fd, uap->path, UIO_USERSPACE, |
4358 uap->fhp)); | 4356 uap->fhp, UIO_USERSPACE)); |
4359} 4360 | 4357} 4358 |
4361static int | 4359int |
4362kern_getfhat(struct thread *td, int flags, int fd, const char *path, | 4360kern_getfhat(struct thread *td, int flags, int fd, const char *path, |
4363 enum uio_seg pathseg, fhandle_t *fhp) | 4361 enum uio_seg pathseg, fhandle_t *fhp, enum uio_seg fhseg) |
4364{ 4365 struct nameidata nd; 4366 fhandle_t fh; 4367 struct vnode *vp; 4368 int error; 4369 4370 error = priv_check(td, PRIV_VFS_GETFH); 4371 if (error != 0) --- 5 unchanged lines hidden (view full) --- 4377 if (error != 0) 4378 return (error); 4379 NDFREE(&nd, NDF_ONLY_PNBUF); 4380 vp = nd.ni_vp; 4381 bzero(&fh, sizeof(fh)); 4382 fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; 4383 error = VOP_VPTOFH(vp, &fh.fh_fid); 4384 vput(vp); | 4362{ 4363 struct nameidata nd; 4364 fhandle_t fh; 4365 struct vnode *vp; 4366 int error; 4367 4368 error = priv_check(td, PRIV_VFS_GETFH); 4369 if (error != 0) --- 5 unchanged lines hidden (view full) --- 4375 if (error != 0) 4376 return (error); 4377 NDFREE(&nd, NDF_ONLY_PNBUF); 4378 vp = nd.ni_vp; 4379 bzero(&fh, sizeof(fh)); 4380 fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; 4381 error = VOP_VPTOFH(vp, &fh.fh_fid); 4382 vput(vp); |
4385 if (error == 0) 4386 error = copyout(&fh, fhp, sizeof (fh)); | 4383 if (error == 0) { 4384 if (fhseg == UIO_USERSPACE) 4385 error = copyout(&fh, fhp, sizeof (fh)); 4386 else 4387 memcpy(fhp, &fh, sizeof(fh)); 4388 } |
4387 return (error); 4388} 4389 4390#ifndef _SYS_SYSPROTO_H_ 4391struct fhlink_args { 4392 fhandle_t *fhp; 4393 const char *to; 4394}; --- 93 unchanged lines hidden (view full) --- 4488struct fhopen_args { 4489 const struct fhandle *u_fhp; 4490 int flags; 4491}; 4492#endif 4493int 4494sys_fhopen(struct thread *td, struct fhopen_args *uap) 4495{ | 4389 return (error); 4390} 4391 4392#ifndef _SYS_SYSPROTO_H_ 4393struct fhlink_args { 4394 fhandle_t *fhp; 4395 const char *to; 4396}; --- 93 unchanged lines hidden (view full) --- 4490struct fhopen_args { 4491 const struct fhandle *u_fhp; 4492 int flags; 4493}; 4494#endif 4495int 4496sys_fhopen(struct thread *td, struct fhopen_args *uap) 4497{ |
4498 return (kern_fhopen(td, uap->u_fhp, uap->flags)); 4499} 4500 4501int 4502kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags) 4503{ |
|
4496 struct mount *mp; 4497 struct vnode *vp; 4498 struct fhandle fhp; 4499 struct file *fp; 4500 int fmode, error; 4501 int indx; 4502 4503 error = priv_check(td, PRIV_VFS_FHOPEN); 4504 if (error != 0) 4505 return (error); 4506 indx = -1; | 4504 struct mount *mp; 4505 struct vnode *vp; 4506 struct fhandle fhp; 4507 struct file *fp; 4508 int fmode, error; 4509 int indx; 4510 4511 error = priv_check(td, PRIV_VFS_FHOPEN); 4512 if (error != 0) 4513 return (error); 4514 indx = -1; |
4507 fmode = FFLAGS(uap->flags); | 4515 fmode = FFLAGS(flags); |
4508 /* why not allow a non-read/write open for our lockd? */ 4509 if (((fmode & (FREAD | FWRITE)) == 0) || (fmode & O_CREAT)) 4510 return (EINVAL); | 4516 /* why not allow a non-read/write open for our lockd? */ 4517 if (((fmode & (FREAD | FWRITE)) == 0) || (fmode & O_CREAT)) 4518 return (EINVAL); |
4511 error = copyin(uap->u_fhp, &fhp, sizeof(fhp)); | 4519 error = copyin(u_fhp, &fhp, sizeof(fhp)); |
4512 if (error != 0) 4513 return(error); 4514 /* find the mount point */ 4515 mp = vfs_busyfs(&fhp.fh_fsid); 4516 if (mp == NULL) 4517 return (ESTALE); 4518 /* now give me my vnode, it gets returned to me locked */ 4519 error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp); --- 434 unchanged lines hidden --- | 4520 if (error != 0) 4521 return(error); 4522 /* find the mount point */ 4523 mp = vfs_busyfs(&fhp.fh_fsid); 4524 if (mp == NULL) 4525 return (ESTALE); 4526 /* now give me my vnode, it gets returned to me locked */ 4527 error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp); --- 434 unchanged lines hidden --- |