bcc8eda93ec46ef5fe48eb350ab3d2148844ea7d
* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
* @(#)vfs_syscalls.c 7.66 (Berkeley) %G%
* Virtual File System System Calls
register struct nameidata
*ndp
;
register struct vnode
*vp
;
register struct mount
*mp
;
if (error
= suser(p
->p_ucred
, &p
->p_acflag
))
* Get vnode to be covered
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
if (error
= namei(ndp
, p
))
if (uap
->flags
& MNT_UPDATE
) {
if ((vp
->v_flag
& VROOT
) == 0) {
* We allow going from read-only to read-write,
* but not from read-write to read-only.
if ((mp
->mnt_flag
& MNT_RDONLY
) == 0 &&
(uap
->flags
& MNT_RDONLY
) != 0) {
return (EOPNOTSUPP
); /* Needs translation */
mp
->mnt_flag
|= MNT_UPDATE
;
if (vp
->v_usecount
!= 1) {
if (vp
->v_type
!= VDIR
) {
if ((unsigned long)uap
->type
> MOUNT_MAXTYPE
||
vfssw
[uap
->type
] == (struct vfsops
*)0) {
* Allocate and initialize the file system.
mp
= (struct mount
*)malloc((u_long
)sizeof(struct mount
),
mp
->mnt_op
= vfssw
[uap
->type
];
if (error
= vfs_lock(mp
)) {
free((caddr_t
)mp
, M_MOUNT
);
if (vp
->v_mountedhere
!= (struct mount
*)0) {
free((caddr_t
)mp
, M_MOUNT
);
mp
->mnt_vnodecovered
= vp
;
* Set the mount level flags.
if (uap
->flags
& MNT_RDONLY
)
mp
->mnt_flag
|= MNT_RDONLY
;
mp
->mnt_flag
&= ~MNT_RDONLY
;
if (uap
->flags
& MNT_NOSUID
)
mp
->mnt_flag
|= MNT_NOSUID
;
mp
->mnt_flag
&= ~MNT_NOSUID
;
if (uap
->flags
& MNT_NOEXEC
)
mp
->mnt_flag
|= MNT_NOEXEC
;
mp
->mnt_flag
&= ~MNT_NOEXEC
;
if (uap
->flags
& MNT_NODEV
)
mp
->mnt_flag
|= MNT_NODEV
;
mp
->mnt_flag
&= ~MNT_NODEV
;
if (uap
->flags
& MNT_SYNCHRONOUS
)
mp
->mnt_flag
|= MNT_SYNCHRONOUS
;
mp
->mnt_flag
&= ~MNT_SYNCHRONOUS
;
error
= VFS_MOUNT(mp
, uap
->dir
, uap
->data
, ndp
);
if (mp
->mnt_flag
& MNT_UPDATE
) {
mp
->mnt_flag
&= ~MNT_UPDATE
;
* Put the new filesystem on the mount list after root.
mp
->mnt_next
= rootfs
->mnt_next
;
mp
->mnt_next
->mnt_prev
= mp
;
error
= VFS_START(mp
, 0);
free((caddr_t
)mp
, M_MOUNT
);
* Note: unmount takes a path to the vnode mounted on as argument,
* not special file (as before).
register struct vnode
*vp
;
register struct nameidata
*ndp
;
if (error
= suser(p
->p_ucred
, &p
->p_acflag
))
ndp
->ni_nameiop
= LOOKUP
| LOCKLEAF
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->pathp
;
if (error
= namei(ndp
, p
))
* Must be the root of the filesystem
if ((vp
->v_flag
& VROOT
) == 0) {
return (dounmount(mp
, uap
->flags
));
register struct mount
*mp
;
coveredvp
= mp
->mnt_vnodecovered
;
mp
->mnt_flag
|= MNT_UNMOUNT
;
if (error
= vfs_lock(mp
))
vnode_pager_umount(mp
); /* release cached vnodes */
xumount(mp
); /* remove unused sticky files from text table */
cache_purgevfs(mp
); /* remove cache entries for this file sys */
if ((error
= VFS_SYNC(mp
, MNT_WAIT
)) == 0 || (flags
& MNT_FORCE
))
error
= VFS_UNMOUNT(mp
, flags
);
mp
->mnt_flag
&= ~MNT_UNMOUNT
;
free((caddr_t
)mp
, M_MOUNT
);
* Sync each mounted filesystem.
register struct mount
*mp
;
* The lock check below is to avoid races with mount
if ((mp
->mnt_flag
& (MNT_MLOCK
|MNT_RDONLY
|MNT_MPBUSY
)) == 0 &&
VFS_SYNC(mp
, MNT_NOWAIT
);
* operate on filesystem quotas
register struct mount
*mp
;
register struct nameidata
*ndp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->path
;
if (error
= namei(ndp
, p
))
mp
= ndp
->ni_vp
->v_mount
;
return (VFS_QUOTACTL(mp
, uap
->cmd
, uap
->uid
, uap
->arg
));
* get filesystem statistics
register struct mount
*mp
;
register struct nameidata
*ndp
;
register struct statfs
*sp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->path
;
if (error
= namei(ndp
, p
))
mp
= ndp
->ni_vp
->v_mount
;
if (error
= VFS_STATFS(mp
, sp
))
sp
->f_flags
= mp
->mnt_flag
& MNT_VISFLAGMASK
;
return (copyout((caddr_t
)sp
, (caddr_t
)uap
->buf
, sizeof(*sp
)));
* get filesystem statistics
register struct statfs
*sp
;
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
mp
= ((struct vnode
*)fp
->f_data
)->v_mount
;
if (error
= VFS_STATFS(mp
, sp
))
sp
->f_flags
= mp
->mnt_flag
& MNT_VISFLAGMASK
;
return (copyout((caddr_t
)sp
, (caddr_t
)uap
->buf
, sizeof(*sp
)));
* get statistics on all filesystems
getfsstat(p
, uap
, retval
)
register struct mount
*mp
;
register struct statfs
*sp
;
long count
, maxcount
, error
;
maxcount
= uap
->bufsize
/ sizeof(struct statfs
);
sfsp
= (caddr_t
)uap
->buf
;
if (sfsp
&& count
< maxcount
&&
((mp
->mnt_flag
& MNT_MLOCK
) == 0)) {
* If MNT_NOWAIT is specified, do not refresh the
* fsstat cache. MNT_WAIT overrides MNT_NOWAIT.
if (((uap
->flags
& MNT_NOWAIT
) == 0 ||
(uap
->flags
& MNT_WAIT
)) &&
(error
= VFS_STATFS(mp
, sp
))) {
sp
->f_flags
= mp
->mnt_flag
& MNT_VISFLAGMASK
;
if (error
= copyout((caddr_t
)sp
, sfsp
, sizeof(*sp
)))
if (sfsp
&& count
> maxcount
)
* Change current working directory to a given file descriptor.
register struct filedesc
*fdp
= p
->p_fd
;
register struct vnode
*vp
;
if (error
= getvnode(fdp
, uap
->fd
, &fp
))
vp
= (struct vnode
*)fp
->f_data
;
error
= VOP_ACCESS(vp
, VEXEC
, p
->p_ucred
);
* Change current working directory (``.'').
register struct nameidata
*ndp
;
register struct filedesc
*fdp
= p
->p_fd
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= chdirec(ndp
, p
))
fdp
->fd_cdir
= ndp
->ni_vp
;
* Change notion of root (``/'') directory.
register struct nameidata
*ndp
;
register struct filedesc
*fdp
= p
->p_fd
;
if (error
= suser(p
->p_ucred
, &p
->p_acflag
))
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= chdirec(ndp
, p
))
if (fdp
->fd_rdir
!= NULL
)
fdp
->fd_rdir
= ndp
->ni_vp
;
* Common routine for chroot and chdir.
if (error
= namei(ndp
, p
))
error
= VOP_ACCESS(vp
, VEXEC
, p
->p_ucred
);
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
register struct filedesc
*fdp
= p
->p_fd
;
register struct file
*fp
;
extern struct fileops vnops
;
if (error
= falloc(p
, &nfp
, &indx
))
fmode
= FFLAGS(uap
->mode
);
cmode
= ((uap
->crtmode
&~ fdp
->fd_cmask
) & 07777) &~ S_ISVTX
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
p
->p_dupfd
= -indx
- 1; /* XXX check for fdopen */
if (error
= vn_open(ndp
, p
, fmode
, cmode
)) {
if (error
== ENODEV
&& /* XXX from fdopen */
(error
= dupfdopen(fdp
, indx
, p
->p_dupfd
, fmode
)) == 0) {
fdp
->fd_ofiles
[indx
] = NULL
;
fp
->f_flag
= fmode
& FMASK
;
fp
->f_type
= DTYPE_VNODE
;
fp
->f_data
= (caddr_t
)ndp
->ni_vp
;
openuap
.fname
= uap
->fname
;
openuap
.crtmode
= uap
->fmode
;
openuap
.mode
= O_WRONLY
| O_CREAT
| O_TRUNC
;
return (open(p
, &openuap
, retval
));
register struct nameidata
*ndp
;
register struct vnode
*vp
;
if (error
= suser(p
->p_ucred
, &p
->p_acflag
))
ndp
->ni_nameiop
= CREATE
| LOCKPARENT
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
switch (uap
->fmode
& S_IFMT
) {
case S_IFMT
: /* used by badsect to flag bad sectors */
vattr
.va_mode
= (uap
->fmode
& 07777) &~ p
->p_fd
->fd_cmask
;
vattr
.va_rdev
= uap
->dev
;
error
= VOP_MKNOD(ndp
, &vattr
, p
->p_ucred
);
register struct nameidata
*ndp
;
ndp
->ni_nameiop
= CREATE
| LOCKPARENT
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (ndp
->ni_vp
!= NULL
) {
if (ndp
->ni_dvp
== ndp
->ni_vp
)
vattr
.va_mode
= (uap
->fmode
& 07777) &~ p
->p_fd
->fd_cmask
;
return (VOP_MKNOD(ndp
, &vattr
, p
->p_ucred
));
register struct nameidata
*ndp
;
register struct vnode
*vp
, *xp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->target
;
if (error
= namei(ndp
, p
))
if (vp
->v_type
== VDIR
&&
(error
= suser(p
->p_ucred
, &p
->p_acflag
)))
ndp
->ni_nameiop
= CREATE
| LOCKPARENT
;
ndp
->ni_dirp
= (caddr_t
)uap
->linkname
;
if (error
= namei(ndp
, p
))
if (vp
->v_mount
!= xp
->v_mount
)
error
= VOP_LINK(vp
, ndp
);
if (ndp
->ni_dvp
== ndp
->ni_vp
)
* symlink -- make a symbolic link
register struct nameidata
*ndp
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->linkname
;
MALLOC(target
, char *, MAXPATHLEN
, M_NAMEI
, M_WAITOK
);
if (error
= copyinstr(uap
->target
, target
, MAXPATHLEN
, (u_int
*)0))
ndp
->ni_nameiop
= CREATE
| LOCKPARENT
;
if (error
= namei(ndp
, p
))
if (ndp
->ni_dvp
== ndp
->ni_vp
)
vattr
.va_mode
= 0777 &~ p
->p_fd
->fd_cmask
;
error
= VOP_SYMLINK(ndp
, &vattr
, target
);
* Hard to avoid races here, especially
* in unlinking directories.
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= DELETE
| LOCKPARENT
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_type
== VDIR
&&
(error
= suser(p
->p_ucred
, &p
->p_acflag
)))
* Don't unlink a mounted file.
if (vp
->v_flag
& VROOT
) {
(void) vnode_pager_uncache(vp
);
xrele(vp
); /* try once to free text */
struct ucred
*cred
= p
->p_ucred
;
register struct filedesc
*fdp
= p
->p_fd
;
register struct file
*fp
;
if ((unsigned)uap
->fdes
>= fdp
->fd_nfiles
||
(fp
= fdp
->fd_ofiles
[uap
->fdes
]) == NULL
)
if (fp
->f_type
!= DTYPE_VNODE
)
fp
->f_offset
+= uap
->off
;
if (error
= VOP_GETATTR((struct vnode
*)fp
->f_data
,
fp
->f_offset
= uap
->off
+ vattr
.va_size
;
register struct nameidata
*ndp
;
register struct ucred
*cred
= p
->p_ucred
;
register struct vnode
*vp
;
int error
, mode
, svuid
, svgid
;
svgid
= cred
->cr_groups
[0];
cred
->cr_uid
= p
->p_cred
->p_ruid
;
cred
->cr_groups
[0] = p
->p_cred
->p_rgid
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
* fmode == 0 means only check for exist
if ((mode
& VWRITE
) == 0 || (error
= vn_writechk(vp
)) == 0)
error
= VOP_ACCESS(vp
, mode
, cred
);
cred
->cr_groups
[0] = svgid
;
* Stat system call. This version follows links.
register struct nameidata
*ndp
;
ndp
->ni_nameiop
= LOOKUP
| LOCKLEAF
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
error
= vn_stat(ndp
->ni_vp
, &sb
);
error
= copyout((caddr_t
)&sb
, (caddr_t
)uap
->ub
, sizeof (sb
));
* Lstat system call. This version does not follow links.
register struct nameidata
*ndp
;
ndp
->ni_nameiop
= LOOKUP
| LOCKLEAF
| NOFOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
error
= vn_stat(ndp
->ni_vp
, &sb
);
error
= copyout((caddr_t
)&sb
, (caddr_t
)uap
->ub
, sizeof (sb
));
* Return target name of a symbolic link
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= LOOKUP
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->name
;
if (error
= namei(ndp
, p
))
if (vp
->v_type
!= VLNK
) {
aiov
.iov_base
= uap
->buf
;
aiov
.iov_len
= uap
->count
;
auio
.uio_segflg
= UIO_USERSPACE
;
auio
.uio_resid
= uap
->count
;
error
= VOP_READLINK(vp
, &auio
, p
->p_ucred
);
*retval
= uap
->count
- auio
.uio_resid
;
* Change flags of a file given path name.
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
vattr
.va_flags
= uap
->flags
;
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Change flags of a file given a file descriptor.
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
vp
= (struct vnode
*)fp
->f_data
;
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
vattr
.va_flags
= uap
->flags
;
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Change mode of a file given path name.
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
vattr
.va_mode
= uap
->fmode
& 07777;
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Change mode of a file given a file descriptor.
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
vp
= (struct vnode
*)fp
->f_data
;
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
vattr
.va_mode
= uap
->fmode
& 07777;
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Set ownership given a path name.
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= LOOKUP
| NOFOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Set ownership given a file descriptor.
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
vp
= (struct vnode
*)fp
->f_data
;
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Set the access and modification times of a file.
register struct nameidata
*ndp
;
register struct vnode
*vp
;
if (error
= copyin((caddr_t
)uap
->tptr
, (caddr_t
)tv
, sizeof (tv
)))
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) {
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Truncate a file given its path name.
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_type
== VDIR
) {
if ((error
= vn_writechk(vp
)) ||
(error
= VOP_ACCESS(vp
, VWRITE
, p
->p_ucred
)))
vattr
.va_size
= uap
->length
;
error
= VOP_SETATTR(vp
, &vattr
, p
->p_ucred
);
* Truncate a file given a file descriptor.
ftruncate(p
, uap
, retval
)
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
if ((fp
->f_flag
& FWRITE
) == 0)
vp
= (struct vnode
*)fp
->f_data
;
if (vp
->v_type
== VDIR
) {
if (error
= vn_writechk(vp
))
vattr
.va_size
= uap
->length
;
error
= VOP_SETATTR(vp
, &vattr
, fp
->f_cred
);
register struct vnode
*vp
;
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
vp
= (struct vnode
*)fp
->f_data
;
error
= VOP_FSYNC(vp
, fp
->f_flag
, fp
->f_cred
, MNT_WAIT
);
* Source and destination must either both be directories, or both
* not be directories. If target is a directory, it must be empty.
register struct vnode
*tvp
, *fvp
, *tdvp
;
register struct nameidata
*ndp
;
struct nameidata nd
, tond
;
ndp
->ni_nameiop
= DELETE
| WANTPARENT
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->from
;
if (error
= namei(ndp
, p
))
tond
.ni_nameiop
= RENAME
| LOCKPARENT
| LOCKLEAF
| NOCACHE
;
tond
.ni_segflg
= UIO_USERSPACE
;
if (error
= namei(&tond
, p
)) {
if (fvp
->v_type
== VDIR
&& tvp
->v_type
!= VDIR
) {
} else if (fvp
->v_type
!= VDIR
&& tvp
->v_type
== VDIR
) {
if (fvp
->v_mount
!= tvp
->v_mount
) {
if (fvp
->v_mount
!= tdvp
->v_mount
) {
* If source is the same as the destination,
* then there is nothing to do.
error
= VOP_RENAME(ndp
, &tond
);
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= CREATE
| LOCKPARENT
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->name
;
if (error
= namei(ndp
, p
))
vattr
.va_mode
= (uap
->dmode
& 0777) &~ p
->p_fd
->fd_cmask
;
error
= VOP_MKDIR(ndp
, &vattr
);
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= DELETE
| LOCKPARENT
| LOCKLEAF
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->name
;
if (error
= namei(ndp
, p
))
if (vp
->v_type
!= VDIR
) {
* Don't unlink a mounted file.
* Read a block of directory entries in a file system independent format
getdirentries(p
, uap
, retval
)
register struct vnode
*vp
;
if (error
= getvnode(p
->p_fd
, uap
->fd
, &fp
))
if ((fp
->f_flag
& FREAD
) == 0)
vp
= (struct vnode
*)fp
->f_data
;
aiov
.iov_base
= uap
->buf
;
aiov
.iov_len
= uap
->count
;
auio
.uio_segflg
= UIO_USERSPACE
;
auio
.uio_resid
= uap
->count
;
auio
.uio_offset
= off
= fp
->f_offset
;
error
= VOP_READDIR(vp
, &auio
, fp
->f_cred
, &eofflag
);
fp
->f_offset
= auio
.uio_offset
;
error
= copyout((caddr_t
)&off
, (caddr_t
)uap
->basep
, sizeof(long));
*retval
= uap
->count
- auio
.uio_resid
;
* mode mask for creation of files
register struct filedesc
*fdp
= p
->p_fd
;
fdp
->fd_cmask
= uap
->mask
& 07777;
* Void all references to file by ripping underlying filesystem
register struct nameidata
*ndp
;
register struct vnode
*vp
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if (error
= namei(ndp
, p
))
if (vp
->v_type
!= VCHR
&& vp
->v_type
!= VBLK
) {
if (error
= VOP_GETATTR(vp
, &vattr
, p
->p_ucred
))
if (p
->p_ucred
->cr_uid
!= vattr
.va_uid
&&
(error
= suser(p
->p_ucred
, &p
->p_acflag
)))
if (vp
->v_usecount
> 1 || (vp
->v_flag
& VALIASED
))
if ((unsigned)fdes
>= fdp
->fd_nfiles
||
(fp
= fdp
->fd_ofiles
[fdes
]) == NULL
)
if (fp
->f_type
!= DTYPE_VNODE
)