SCCS-vsn: sys/kern/sys_generic.c 8.2
SCCS-vsn: sys/kern/vfs_syscalls.c 8.2
SCCS-vsn: sys/kern/tty_subr.c 8.2
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)sys_generic.c 8.1 (Berkeley) %G%
+ * @(#)sys_generic.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
* Read system call.
*/
struct read_args {
* Read system call.
*/
struct read_args {
- int fdes;
- char *cbuf;
- unsigned count;
+ int fd;
+ char *buf;
+ u_int nbyte;
};
/* ARGSUSED */
read(p, uap, retval)
};
/* ARGSUSED */
read(p, uap, retval)
struct iovec ktriov;
#endif
struct iovec ktriov;
#endif
- if (((unsigned)uap->fdes) >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fdes]) == NULL ||
+ if (((u_int)uap->fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[uap->fd]) == NULL ||
(fp->f_flag & FREAD) == 0)
return (EBADF);
(fp->f_flag & FREAD) == 0)
return (EBADF);
- aiov.iov_base = (caddr_t)uap->cbuf;
- aiov.iov_len = uap->count;
+ aiov.iov_base = (caddr_t)uap->buf;
+ aiov.iov_len = uap->nbyte;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
- auio.uio_resid = uap->count;
+ auio.uio_resid = uap->nbyte;
auio.uio_rw = UIO_READ;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
auio.uio_rw = UIO_READ;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
if (KTRPOINT(p, KTR_GENIO))
ktriov = aiov;
#endif
if (KTRPOINT(p, KTR_GENIO))
ktriov = aiov;
#endif
if (error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred))
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
if (error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred))
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
- ktrgenio(p->p_tracep, uap->fdes, UIO_READ, &ktriov, cnt, error);
+ ktrgenio(p->p_tracep, uap->fd, UIO_READ, &ktriov, cnt, error);
#endif
*retval = cnt;
return (error);
#endif
*retval = cnt;
return (error);
struct readv_args {
int fdes;
struct iovec *iovp;
struct readv_args {
int fdes;
struct iovec *iovp;
};
readv(p, uap, retval)
struct proc *p;
};
readv(p, uap, retval)
struct proc *p;
struct iovec *needfree;
struct iovec aiov[UIO_SMALLIOV];
long i, cnt, error = 0;
struct iovec *needfree;
struct iovec aiov[UIO_SMALLIOV];
long i, cnt, error = 0;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
- if (((unsigned)uap->fdes) >= fdp->fd_nfiles ||
+ if (((u_int)uap->fdes) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[uap->fdes]) == NULL ||
(fp->f_flag & FREAD) == 0)
return (EBADF);
(fp = fdp->fd_ofiles[uap->fdes]) == NULL ||
(fp->f_flag & FREAD) == 0)
return (EBADF);
* Write system call
*/
struct write_args {
* Write system call
*/
struct write_args {
- int fdes;
- char *cbuf;
- unsigned count;
+ int fd;
+ char *buf;
+ u_int nbyte;
};
write(p, uap, retval)
struct proc *p;
};
write(p, uap, retval)
struct proc *p;
struct iovec ktriov;
#endif
struct iovec ktriov;
#endif
- if (((unsigned)uap->fdes) >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fdes]) == NULL ||
+ if (((u_int)uap->fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[uap->fd]) == NULL ||
(fp->f_flag & FWRITE) == 0)
return (EBADF);
(fp->f_flag & FWRITE) == 0)
return (EBADF);
- aiov.iov_base = (caddr_t)uap->cbuf;
- aiov.iov_len = uap->count;
+ aiov.iov_base = (caddr_t)uap->buf;
+ aiov.iov_len = uap->nbyte;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
- auio.uio_resid = uap->count;
+ auio.uio_resid = uap->nbyte;
auio.uio_rw = UIO_WRITE;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
auio.uio_rw = UIO_WRITE;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
if (KTRPOINT(p, KTR_GENIO))
ktriov = aiov;
#endif
if (KTRPOINT(p, KTR_GENIO))
ktriov = aiov;
#endif
if (error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred)) {
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
if (error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred)) {
if (auio.uio_resid != cnt && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
- ktrgenio(p->p_tracep, uap->fdes, UIO_WRITE,
+ ktrgenio(p->p_tracep, uap->fd, UIO_WRITE,
&ktriov, cnt, error);
#endif
*retval = cnt;
&ktriov, cnt, error);
#endif
*retval = cnt;
* Gather write system call
*/
struct writev_args {
* Gather write system call
*/
struct writev_args {
};
writev(p, uap, retval)
struct proc *p;
};
writev(p, uap, retval)
struct proc *p;
struct iovec *needfree;
struct iovec aiov[UIO_SMALLIOV];
long i, cnt, error = 0;
struct iovec *needfree;
struct iovec aiov[UIO_SMALLIOV];
long i, cnt, error = 0;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
- if (((unsigned)uap->fdes) >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fdes]) == NULL ||
+ if (((u_int)uap->fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[uap->fd]) == NULL ||
(fp->f_flag & FWRITE) == 0)
return (EBADF);
/* note: can't use iovlen until iovcnt is validated */
(fp->f_flag & FWRITE) == 0)
return (EBADF);
/* note: can't use iovlen until iovcnt is validated */
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
- ktrgenio(p->p_tracep, uap->fdes, UIO_WRITE,
+ ktrgenio(p->p_tracep, uap->fd, UIO_WRITE,
ktriov, cnt, error);
FREE(ktriov, M_TEMP);
}
ktriov, cnt, error);
FREE(ktriov, M_TEMP);
}
* Ioctl system call
*/
struct ioctl_args {
* Ioctl system call
*/
struct ioctl_args {
- int fdes;
- int cmd;
- caddr_t cmarg;
+ int fd;
+ int com;
+ caddr_t data;
};
/* ARGSUSED */
ioctl(p, uap, retval)
};
/* ARGSUSED */
ioctl(p, uap, retval)
caddr_t data = stkbuf;
int tmp;
caddr_t data = stkbuf;
int tmp;
- if ((unsigned)uap->fdes >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fdes]) == NULL)
+ if ((u_int)uap->fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[uap->fd]) == NULL)
return (EBADF);
if ((fp->f_flag & (FREAD|FWRITE)) == 0)
return (EBADF);
return (EBADF);
if ((fp->f_flag & (FREAD|FWRITE)) == 0)
return (EBADF);
- fdp->fd_ofileflags[uap->fdes] |= UF_EXCLOSE;
+ fdp->fd_ofileflags[uap->fd] |= UF_EXCLOSE;
return (0);
}
if (com == FIONCLEX) {
return (0);
}
if (com == FIONCLEX) {
- fdp->fd_ofileflags[uap->fdes] &= ~UF_EXCLOSE;
+ fdp->fd_ofileflags[uap->fd] &= ~UF_EXCLOSE;
}
if (com&IOC_IN) {
if (size) {
}
if (com&IOC_IN) {
if (size) {
- error = copyin(uap->cmarg, data, (u_int)size);
+ error = copyin(uap->data, data, (u_int)size);
if (error) {
if (memp)
free(memp, M_IOCTLOPS);
return (error);
}
} else
if (error) {
if (memp)
free(memp, M_IOCTLOPS);
return (error);
}
} else
- *(caddr_t *)data = uap->cmarg;
+ *(caddr_t *)data = uap->data;
} else if ((com&IOC_OUT) && size)
/*
* Zero the buffer so the user always
} else if ((com&IOC_OUT) && size)
/*
* Zero the buffer so the user always
*/
bzero(data, size);
else if (com&IOC_VOID)
*/
bzero(data, size);
else if (com&IOC_VOID)
- *(caddr_t *)data = uap->cmarg;
+ *(caddr_t *)data = uap->data;
* already set and checked above.
*/
if (error == 0 && (com&IOC_OUT) && size)
* already set and checked above.
*/
if (error == 0 && (com&IOC_OUT) && size)
- error = copyout(data, uap->cmarg, (u_int)size);
+ error = copyout(data, uap->data, (u_int)size);
*
* %sccs.include.proprietary.c%
*
*
* %sccs.include.proprietary.c%
*
- * @(#)tty_subr.c 8.1 (Berkeley) %G%
+ * @(#)tty_subr.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
/*
* Initialize clist by freeing all character blocks.
*/
/*
* Initialize clist by freeing all character blocks.
*/
{
register int ccp;
register struct cblock *cp;
{
register int ccp;
register struct cblock *cp;
/*
* Flush cc bytes from q.
*/
/*
* Flush cc bytes from q.
*/
ndflush(q, cc)
register struct clist *q;
register int cc;
ndflush(q, cc)
register struct clist *q;
register int cc;
* Put the chars in the from que
* on the end of the to que.
*/
* Put the chars in the from que
* on the end of the to que.
*/
catq(from, to)
struct clist *from, *to;
{
catq(from, to)
struct clist *from, *to;
{
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)vfs_syscalls.c 8.1 (Berkeley) %G%
+ * @(#)vfs_syscalls.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
+static int change_dir __P((struct nameidata *ndp, struct proc *p));
+
#ifdef REF_DIAGNOSTIC
#define CURCOUNT (curproc ? curproc->p_spare[0] : 0)
#define CHECKPOINTREF int oldrefcount = CURCOUNT;
#ifdef REF_DIAGNOSTIC
#define CURCOUNT (curproc ? curproc->p_spare[0] : 0)
#define CHECKPOINTREF int oldrefcount = CURCOUNT;
*/
struct mount_args {
int type;
*/
struct mount_args {
int type;
int flags;
caddr_t data;
};
int flags;
caddr_t data;
};
/*
* Get vnode to be covered
*/
/*
* Get vnode to be covered
*/
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->dir, p);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
vput(vp);
return (ENOTDIR);
}
vput(vp);
return (ENOTDIR);
}
- if ((unsigned long)uap->type > MOUNT_MAXTYPE ||
- vfssw[uap->type] == (struct vfsops *)0) {
+ if ((u_long)uap->type > MOUNT_MAXTYPE || vfssw[uap->type] == NULL) {
vput(vp);
return (ENODEV);
}
vput(vp);
return (ENODEV);
}
vput(vp);
return (error);
}
vput(vp);
return (error);
}
- if (vp->v_mountedhere != (struct mount *)0) {
+ if (vp->v_mountedhere != NULL) {
vfs_unlock(mp);
free((caddr_t)mp, M_MOUNT);
vput(vp);
vfs_unlock(mp);
free((caddr_t)mp, M_MOUNT);
vput(vp);
/*
* Mount the filesystem.
*/
/*
* Mount the filesystem.
*/
- error = VFS_MOUNT(mp, uap->dir, uap->data, &nd, p);
+ error = VFS_MOUNT(mp, uap->path, uap->data, &nd, p);
if (mp->mnt_flag & MNT_UPDATE) {
vrele(vp);
if (mp->mnt_flag & MNT_WANTRDWR)
if (mp->mnt_flag & MNT_UPDATE) {
vrele(vp);
if (mp->mnt_flag & MNT_WANTRDWR)
+ * Unmount a file system.
*
* Note: unmount takes a path to the vnode mounted on as argument,
* not special file (as before).
*/
struct unmount_args {
*
* Note: unmount takes a path to the vnode mounted on as argument,
* not special file (as before).
*/
struct unmount_args {
int flags;
};
/* ARGSUSED */
int flags;
};
/* ARGSUSED */
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->pathp, p);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
+ * Do the actual file system unmount.
*/
dounmount(mp, flags, p)
register struct mount *mp;
*/
dounmount(mp, flags, p)
register struct mount *mp;
* Sync each mounted filesystem.
*/
#ifdef DIAGNOSTIC
* Sync each mounted filesystem.
*/
#ifdef DIAGNOSTIC
- * Operate on filesystem quotas.
+ * Change filesystem quotas.
*/
struct quotactl_args {
char *path;
*/
struct quotactl_args {
char *path;
* Change current working directory (``.'').
*/
struct chdir_args {
* Change current working directory (``.'').
*/
struct chdir_args {
};
/* ARGSUSED */
chdir(p, uap, retval)
};
/* ARGSUSED */
chdir(p, uap, retval)
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
- if (error = chdirec(&nd, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
+ if (error = change_dir(&nd, p))
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
* Change notion of root (``/'') directory.
*/
struct chroot_args {
* Change notion of root (``/'') directory.
*/
struct chroot_args {
};
/* ARGSUSED */
chroot(p, uap, retval)
};
/* ARGSUSED */
chroot(p, uap, retval)
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
- if (error = chdirec(&nd, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
+ if (error = change_dir(&nd, p))
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
/*
* Common routine for chroot and chdir.
*/
/*
* Common routine for chroot and chdir.
*/
+static int
+change_dir(ndp, p)
register struct nameidata *ndp;
struct proc *p;
{
register struct nameidata *ndp;
struct proc *p;
{
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
*/
struct open_args {
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
*/
struct open_args {
+ char *path;
+ int flags;
};
open(p, uap, retval)
struct proc *p;
};
open(p, uap, retval)
struct proc *p;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register struct vnode *vp;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register struct vnode *vp;
struct file *nfp;
int type, indx, error;
struct flock lf;
struct file *nfp;
int type, indx, error;
struct flock lf;
if (error = falloc(p, &nfp, &indx))
return (error);
fp = nfp;
if (error = falloc(p, &nfp, &indx))
return (error);
fp = nfp;
- fmode = FFLAGS(uap->mode);
- cmode = ((uap->crtmode &~ fdp->fd_cmask) & 07777) &~ S_ISVTX;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ flags = FFLAGS(uap->flags);
+ cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
- if (error = vn_open(&nd, fmode, cmode)) {
+ if (error = vn_open(&nd, flags, cmode)) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
- (error = dupfdopen(fdp, indx, p->p_dupfd,
- fmode, error)) == 0) {
+ (error =
+ dupfdopen(fdp, indx, p->p_dupfd, flags, error)) == 0) {
*retval = indx;
return (0);
}
*retval = indx;
return (0);
}
}
p->p_dupfd = 0;
vp = nd.ni_vp;
}
p->p_dupfd = 0;
vp = nd.ni_vp;
- fp->f_flag = fmode & FMASK;
+ fp->f_flag = flags & FMASK;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (caddr_t)vp;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (caddr_t)vp;
- if (fmode & (O_EXLOCK | O_SHLOCK)) {
+ if (flags & (O_EXLOCK | O_SHLOCK)) {
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_WRLCK;
else
lf.l_type = F_RDLCK;
type = F_FLOCK;
lf.l_type = F_WRLCK;
else
lf.l_type = F_RDLCK;
type = F_FLOCK;
- if ((fmode & FNONBLOCK) == 0)
+ if ((flags & FNONBLOCK) == 0)
type |= F_WAIT;
if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
VOP_UNLOCK(vp);
type |= F_WAIT;
if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
VOP_UNLOCK(vp);
- char *fname;
- int fmode;
+ char *path;
+ int mode;
};
ocreat(p, uap, retval)
struct proc *p;
};
ocreat(p, uap, retval)
struct proc *p;
{
struct open_args openuap;
{
struct open_args openuap;
- openuap.fname = uap->fname;
- openuap.crtmode = uap->fmode;
- openuap.mode = O_WRONLY | O_CREAT | O_TRUNC;
+ openuap.path = uap->path;
+ openuap.mode = uap->mode;
+ openuap.flags = O_WRONLY | O_CREAT | O_TRUNC;
return (open(p, &openuap, retval));
}
#endif /* COMPAT_43 */
/*
return (open(p, &openuap, retval));
}
#endif /* COMPAT_43 */
/*
+ * Create a special file.
- char *fname;
- int fmode;
+ char *path;
+ int mode;
int dev;
};
/* ARGSUSED */
int dev;
};
/* ARGSUSED */
CHECKPOINTREF;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
CHECKPOINTREF;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
goto out;
}
VATTR_NULL(&vattr);
goto out;
}
VATTR_NULL(&vattr);
- switch (uap->fmode & S_IFMT) {
-
+ switch (uap->mode & S_IFMT) {
case S_IFMT: /* used by badsect to flag bad sectors */
vattr.va_type = VBAD;
break;
case S_IFMT: /* used by badsect to flag bad sectors */
vattr.va_type = VBAD;
break;
error = EINVAL;
goto out;
}
error = EINVAL;
goto out;
}
- vattr.va_mode = (uap->fmode & 07777) &~ p->p_fd->fd_cmask;
+ vattr.va_mode = (uap->mode & ALLPERMS) &~ p->p_fd->fd_cmask;
vattr.va_rdev = uap->dev;
out:
if (!error) {
vattr.va_rdev = uap->dev;
out:
if (!error) {
- char *fname;
- int fmode;
+ char *path;
+ int mode;
};
/* ARGSUSED */
mkfifo(p, uap, retval)
};
/* ARGSUSED */
mkfifo(p, uap, retval)
#ifndef FIFO
return (EOPNOTSUPP);
#else
#ifndef FIFO
return (EOPNOTSUPP);
#else
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
if (nd.ni_vp != NULL) {
if (error = namei(&nd))
return (error);
if (nd.ni_vp != NULL) {
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
- vattr.va_mode = (uap->fmode & 07777) &~ p->p_fd->fd_cmask;
+ vattr.va_mode = (uap->mode & ALLPERMS) &~ p->p_fd->fd_cmask;
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
#endif /* FIFO */
}
/*
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
#endif /* FIFO */
}
/*
+ * Make a hard file link.
- char *target;
- char *linkname;
+ char *path;
+ char *link;
};
/* ARGSUSED */
link(p, uap, retval)
};
/* ARGSUSED */
link(p, uap, retval)
register struct link_args *uap;
int *retval;
{
register struct link_args *uap;
int *retval;
{
- register struct vnode *vp, *xp;
- int error;
+ register struct vnode *vp;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->target, p);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (vp->v_type == VDIR &&
(error = suser(p->p_ucred, &p->p_acflag)))
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (vp->v_type == VDIR &&
(error = suser(p->p_ucred, &p->p_acflag)))
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
- nd.ni_dirp = (caddr_t)uap->linkname;
+ nd.ni_dirp = uap->link;
- goto out1;
- xp = nd.ni_vp;
- if (xp != NULL) {
- error = EEXIST;
- }
- xp = nd.ni_dvp;
-out:
+ if (nd.ni_vp != NULL)
+ error = EEXIST;
- LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
} else {
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
} else {
if (nd.ni_vp)
vrele(nd.ni_vp);
}
if (nd.ni_vp)
vrele(nd.ni_vp);
}
CHECKREFS("link");
return (error);
}
CHECKREFS("link");
return (error);
}
* Make a symbolic link.
*/
struct symlink_args {
* Make a symbolic link.
*/
struct symlink_args {
- char *target;
- char *linkname;
+ char *path;
+ char *link;
};
/* ARGSUSED */
symlink(p, uap, retval)
};
/* ARGSUSED */
symlink(p, uap, retval)
int *retval;
{
struct vattr vattr;
int *retval;
{
struct vattr vattr;
int error;
struct nameidata nd;
CHECKPOINTREF;
int error;
struct nameidata nd;
CHECKPOINTREF;
- MALLOC(target, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
- if (error = copyinstr(uap->target, target, MAXPATHLEN, (u_int *)0))
+ MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
+ if (error = copyinstr(uap->path, path, MAXPATHLEN, NULL))
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->linkname, p);
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
if (error = namei(&nd))
goto out;
if (nd.ni_vp) {
if (error = namei(&nd))
goto out;
if (nd.ni_vp) {
goto out;
}
VATTR_NULL(&vattr);
goto out;
}
VATTR_NULL(&vattr);
- vattr.va_mode = 0777 &~ p->p_fd->fd_cmask;
+ vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask;
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, target);
+ error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
CHECKREFS("symlink");
return (error);
}
CHECKREFS("symlink");
return (error);
}
* Delete a name from the filesystem.
*/
struct unlink_args {
* Delete a name from the filesystem.
*/
struct unlink_args {
};
/* ARGSUSED */
unlink(p, uap, retval)
};
/* ARGSUSED */
unlink(p, uap, retval)
struct nameidata nd;
CHECKPOINTREF;
struct nameidata nd;
CHECKPOINTREF;
- NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->name, p);
+ NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
/*
* The root of a mounted filesystem cannot be deleted.
*/
/*
* The root of a mounted filesystem cannot be deleted.
*/
- if (vp->v_flag & VROOT) {
+ if (vp->v_flag & VROOT)
- goto out;
- }
- (void) vnode_pager_uncache(vp);
-out:
- if (!error) {
+ else
+ (void)vnode_pager_uncache(vp);
+
+out: if (!error) {
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
} else {
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
} else {
+/*
+ * Reposition read/write file offset.
+ */
- off_t off;
- int sbase;
+ off_t offset;
+ int whence;
-
-/*
- * Seek system call.
- */
lseek(p, uap, retval)
struct proc *p;
register struct lseek_args *uap;
lseek(p, uap, retval)
struct proc *p;
register struct lseek_args *uap;
struct vattr vattr;
int error;
struct vattr vattr;
int error;
- if ((unsigned)uap->fdes >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fdes]) == NULL)
+ if ((u_int)uap->fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[uap->fd]) == NULL)
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (ESPIPE);
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (ESPIPE);
- switch (uap->sbase) {
-
- fp->f_offset += uap->off;
+ fp->f_offset += uap->offset;
- if (error = VOP_GETATTR((struct vnode *)fp->f_data,
- &vattr, cred, p))
+ if (error =
+ VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
- fp->f_offset = uap->off + vattr.va_size;
+ fp->f_offset = uap->offset + vattr.va_size;
- fp->f_offset = uap->off;
+ fp->f_offset = uap->offset;
default:
return (EINVAL);
}
default:
return (EINVAL);
}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
/*
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
/*
- * Old lseek system call.
+ * Reposition read/write file offset.
- int fdes;
- long off;
- int sbase;
+ int fd;
+ long offset;
+ int whence;
};
olseek(p, uap, retval)
struct proc *p;
};
olseek(p, uap, retval)
struct proc *p;
- nuap.fdes = uap->fdes;
- nuap.off = uap->off;
- nuap.sbase = uap->sbase;
+ nuap.fd = uap->fd;
+ nuap.offset = uap->offset;
+ nuap.whence = uap->whence;
error = lseek(p, &nuap, &qret);
*(long *)retval = qret;
return (error);
error = lseek(p, &nuap, &qret);
*(long *)retval = qret;
return (error);
* Check access permissions.
*/
struct access_args {
* Check access permissions.
*/
struct access_args {
- char *fname;
- int fmode;
+ char *path;
+ int flags;
};
access(p, uap, retval)
struct proc *p;
};
access(p, uap, retval)
struct proc *p;
{
register struct ucred *cred = p->p_ucred;
register struct vnode *vp;
{
register struct ucred *cred = p->p_ucred;
register struct vnode *vp;
- int error, mode, svuid, svgid;
+ int error, flags, saved_uid, saved_gid;
- svuid = cred->cr_uid;
- svgid = cred->cr_groups[0];
+ saved_uid = cred->cr_uid;
+ saved_gid = cred->cr_groups[0];
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
goto out1;
vp = nd.ni_vp;
if (error = namei(&nd))
goto out1;
vp = nd.ni_vp;
- /*
- * fmode == 0 means only check for exist
- */
- if (uap->fmode) {
- mode = 0;
- if (uap->fmode & R_OK)
- mode |= VREAD;
- if (uap->fmode & W_OK)
- mode |= VWRITE;
- if (uap->fmode & X_OK)
- mode |= VEXEC;
- if ((mode & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
- error = VOP_ACCESS(vp, mode, cred, p);
+
+ /* Flags == 0 means only check for existence. */
+ if (uap->flags) {
+ flags = 0;
+ if (uap->flags & R_OK)
+ flags |= VREAD;
+ if (uap->flags & W_OK)
+ flags |= VWRITE;
+ if (uap->flags & X_OK)
+ flags |= VEXEC;
+ if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
+ error = VOP_ACCESS(vp, flags, cred, p);
- cred->cr_uid = svuid;
- cred->cr_groups[0] = svgid;
+ cred->cr_uid = saved_uid;
+ cred->cr_groups[0] = saved_gid;
return (error);
}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
/*
return (error);
}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
/*
- * Stat system call.
- * This version follows links.
+ * Get file status; this version follows links.
struct ostat *ub;
};
/* ARGSUSED */
struct ostat *ub;
};
/* ARGSUSED */
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
if (error = namei(&nd))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
- * Lstat system call.
- * This version does not follow links.
+ * Get file status; this version does not follow links.
struct ostat *ub;
};
/* ARGSUSED */
struct ostat *ub;
};
/* ARGSUSED */
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
if (error = namei(&nd))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
- * convert from an old to a new stat structure.
+ * Convert from an old to a new stat structure.
*/
cvtstat(st, ost)
struct stat *st;
*/
cvtstat(st, ost)
struct stat *st;
#endif /* COMPAT_43 || COMPAT_SUNOS */
/*
#endif /* COMPAT_43 || COMPAT_SUNOS */
/*
- * Stat system call.
- * This version follows links.
+ * Get file status; this version follows links.
struct stat *ub;
};
/* ARGSUSED */
struct stat *ub;
};
/* ARGSUSED */
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
if (error = namei(&nd))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
- * Lstat system call.
- * This version does not follow links.
+ * Get file status; this version does not follow links.
struct stat *ub;
};
/* ARGSUSED */
struct stat *ub;
};
/* ARGSUSED */
struct nameidata nd;
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
struct nameidata nd;
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
if (error = namei(&nd))
return (error);
/*
if (error = namei(&nd))
return (error);
/*
- * Pathconf system call.
+ * Get configurable pathname variables.
*/
struct pathconf_args {
*/
struct pathconf_args {
int name;
};
/* ARGSUSED */
int name;
};
/* ARGSUSED */
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
if (error = namei(&nd))
return (error);
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
* Return target name of a symbolic link.
*/
struct readlink_args {
* Return target name of a symbolic link.
*/
struct readlink_args {
struct nameidata nd;
CHECKPOINTREF;
struct nameidata nd;
CHECKPOINTREF;
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->name, p);
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
- if (vp->v_type != VLNK) {
+ if (vp->v_type != VLNK)
+ else {
+ aiov.iov_base = uap->buf;
+ aiov.iov_len = uap->count;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_offset = 0;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = uap->count;
+ error = VOP_READLINK(vp, &auio, p->p_ucred);
- aiov.iov_base = uap->buf;
- aiov.iov_len = uap->count;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_procp = p;
- auio.uio_resid = uap->count;
- error = VOP_READLINK(vp, &auio, p->p_ucred);
-out:
vput(vp);
*retval = uap->count - auio.uio_resid;
CHECKREFS("readlink");
vput(vp);
*retval = uap->count - auio.uio_resid;
CHECKREFS("readlink");
- * Change flags of a file given path name.
+ * Change flags of a file given a path name.
int flags;
};
/* ARGSUSED */
int flags;
};
/* ARGSUSED */
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ VATTR_NULL(&vattr);
+ vattr.va_flags = uap->flags;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VATTR_NULL(&vattr);
- vattr.va_flags = uap->flags;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
vput(vp);
return (error);
}
vput(vp);
return (error);
}
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ VATTR_NULL(&vattr);
+ vattr.va_flags = uap->flags;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VATTR_NULL(&vattr);
- vattr.va_flags = uap->flags;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
VOP_UNLOCK(vp);
return (error);
}
VOP_UNLOCK(vp);
return (error);
}
* Change mode of a file given path name.
*/
struct chmod_args {
* Change mode of a file given path name.
*/
struct chmod_args {
- char *fname;
- int fmode;
+ char *path;
+ int mode;
};
/* ARGSUSED */
chmod(p, uap, retval)
};
/* ARGSUSED */
chmod(p, uap, retval)
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ VATTR_NULL(&vattr);
+ vattr.va_mode = uap->mode & ALLPERMS;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VATTR_NULL(&vattr);
- vattr.va_mode = uap->fmode & 07777;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
vput(vp);
return (error);
}
vput(vp);
return (error);
}
*/
struct fchmod_args {
int fd;
*/
struct fchmod_args {
int fd;
};
/* ARGSUSED */
fchmod(p, uap, retval)
};
/* ARGSUSED */
fchmod(p, uap, retval)
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ VATTR_NULL(&vattr);
+ vattr.va_mode = uap->mode & ALLPERMS;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VATTR_NULL(&vattr);
- vattr.va_mode = uap->fmode & 07777;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
VOP_UNLOCK(vp);
return (error);
}
VOP_UNLOCK(vp);
return (error);
}
* Set ownership given a path name.
*/
struct chown_args {
* Set ownership given a path name.
*/
struct chown_args {
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ VATTR_NULL(&vattr);
+ vattr.va_uid = uap->uid;
+ vattr.va_gid = uap->gid;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VATTR_NULL(&vattr);
- vattr.va_uid = uap->uid;
- vattr.va_gid = uap->gid;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
vput(vp);
return (error);
}
vput(vp);
return (error);
}
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ VATTR_NULL(&vattr);
+ vattr.va_uid = uap->uid;
+ vattr.va_gid = uap->gid;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VATTR_NULL(&vattr);
- vattr.va_uid = uap->uid;
- vattr.va_gid = uap->gid;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
VOP_UNLOCK(vp);
return (error);
}
VOP_UNLOCK(vp);
return (error);
}
* Set the access and modification times of a file.
*/
struct utimes_args {
* Set the access and modification times of a file.
*/
struct utimes_args {
struct timeval *tptr;
};
/* ARGSUSED */
struct timeval *tptr;
};
/* ARGSUSED */
vattr.va_vaflags |= VA_UTIMES_NULL;
} else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
return (error);
vattr.va_vaflags |= VA_UTIMES_NULL;
} else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
return (error);
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ else {
+ vattr.va_atime.ts_sec = tv[0].tv_sec;
+ vattr.va_atime.ts_nsec = tv[0].tv_usec * 1000;
+ vattr.va_mtime.ts_sec = tv[1].tv_sec;
+ vattr.va_mtime.ts_nsec = tv[1].tv_usec * 1000;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- vattr.va_atime.ts_sec = tv[0].tv_sec;
- vattr.va_atime.ts_nsec = tv[0].tv_usec * 1000;
- vattr.va_mtime.ts_sec = tv[1].tv_sec;
- vattr.va_mtime.ts_nsec = tv[1].tv_usec * 1000;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
vput(vp);
return (error);
}
vput(vp);
return (error);
}
+/*
+ * Truncate a file given its path name.
+ */
int pad;
off_t length;
};
int pad;
off_t length;
};
-
-/*
- * Truncate a file given its path name.
- */
/* ARGSUSED */
truncate(p, uap, retval)
struct proc *p;
/* ARGSUSED */
truncate(p, uap, retval)
struct proc *p;
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_type == VDIR) {
+ if (vp->v_type == VDIR)
+ else if ((error = vn_writechk(vp)) == 0 &&
+ (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) {
+ VATTR_NULL(&vattr);
+ vattr.va_size = uap->length;
+ error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- if ((error = vn_writechk(vp)) ||
- (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)))
- goto out;
- VATTR_NULL(&vattr);
- vattr.va_size = uap->length;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
-out:
vput(vp);
return (error);
}
vput(vp);
return (error);
}
+/*
+ * Truncate a file given a file descriptor.
+ */
struct ftruncate_args {
int fd;
int pad;
off_t length;
};
struct ftruncate_args {
int fd;
int pad;
off_t length;
};
-
-/*
- * Truncate a file given a file descriptor.
- */
/* ARGSUSED */
ftruncate(p, uap, retval)
struct proc *p;
/* ARGSUSED */
ftruncate(p, uap, retval)
struct proc *p;
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
- if (vp->v_type == VDIR) {
+ if (vp->v_type == VDIR)
+ else if ((error = vn_writechk(vp)) == 0) {
+ VATTR_NULL(&vattr);
+ vattr.va_size = uap->length;
+ error = VOP_SETATTR(vp, &vattr, fp->f_cred, p);
- if (error = vn_writechk(vp))
- goto out;
- VATTR_NULL(&vattr);
- vattr.va_size = uap->length;
- error = VOP_SETATTR(vp, &vattr, fp->f_cred, p);
-out:
VOP_UNLOCK(vp);
return (error);
}
VOP_UNLOCK(vp);
return (error);
}
* Truncate a file given its path name.
*/
struct otruncate_args {
* Truncate a file given its path name.
*/
struct otruncate_args {
long length;
};
/* ARGSUSED */
long length;
};
/* ARGSUSED */
{
struct truncate_args nuap;
{
struct truncate_args nuap;
- nuap.fname = uap->fname;
nuap.length = uap->length;
return (truncate(p, &nuap, retval));
}
nuap.length = uap->length;
return (truncate(p, &nuap, retval));
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
/*
#endif /* COMPAT_43 || COMPAT_SUNOS */
/*
*/
struct fsync_args {
int fd;
*/
struct fsync_args {
int fd;
- * Rename system call.
- *
- * Source and destination must either both be directories, or both
- * not be directories. If target is a directory, it must be empty.
+ * Rename files. Source and destination must either both be directories,
+ * or both not be directories. If target is a directory, it must be empty.
*/
struct rename_args {
char *from;
*/
struct rename_args {
char *from;
+ * Make a directory file.
- char *name;
- int dmode;
+ char *path;
+ int mode;
};
/* ARGSUSED */
mkdir(p, uap, retval)
};
/* ARGSUSED */
mkdir(p, uap, retval)
struct nameidata nd;
CHECKPOINTREF;
struct nameidata nd;
CHECKPOINTREF;
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->name, p);
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
- vattr.va_mode = (uap->dmode & 0777) &~ p->p_fd->fd_cmask;
+ vattr.va_mode = (uap->mode & ACCESSPERMS) &~ p->p_fd->fd_cmask;
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
if (!error)
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
if (!error)
+ * Remove a directory file.
};
/* ARGSUSED */
rmdir(p, uap, retval)
};
/* ARGSUSED */
rmdir(p, uap, retval)
struct nameidata nd;
CHECKPOINTREF;
struct nameidata nd;
CHECKPOINTREF;
- NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
+ NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
struct ogetdirentries_args {
int fd;
char *buf;
struct ogetdirentries_args {
int fd;
char *buf;
long *basep;
};
ogetdirentries(p, uap, retval)
long *basep;
};
ogetdirentries(p, uap, retval)
struct getdirentries_args {
int fd;
char *buf;
struct getdirentries_args {
int fd;
char *buf;
long *basep;
};
getdirentries(p, uap, retval)
long *basep;
};
getdirentries(p, uap, retval)
* Set the mode mask for creation of filesystem nodes.
*/
struct umask_args {
* Set the mode mask for creation of filesystem nodes.
*/
struct umask_args {
};
mode_t /* XXX */
umask(p, uap, retval)
};
mode_t /* XXX */
umask(p, uap, retval)
struct umask_args *uap;
int *retval;
{
struct umask_args *uap;
int *retval;
{
- register struct filedesc *fdp = p->p_fd;
+ register struct filedesc *fdp;
- fdp->fd_cmask = uap->mask & 07777;
+ fdp->fd_cmask = uap->newmask & ALLPERMS;
* away from vnode.
*/
struct revoke_args {
* away from vnode.
*/
struct revoke_args {
};
/* ARGSUSED */
revoke(p, uap, retval)
};
/* ARGSUSED */
revoke(p, uap, retval)
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
if (error = namei(&nd))
return (error);
vp = nd.ni_vp;
/*
* Convert a user file descriptor to a kernel file entry.
*/
/*
* Convert a user file descriptor to a kernel file entry.
*/
-getvnode(fdp, fdes, fpp)
struct filedesc *fdp;
struct file **fpp;
struct filedesc *fdp;
struct file **fpp;
- if ((unsigned)fdes >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[fdes]) == NULL)
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (EINVAL);
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (EINVAL);