Implement futimes().

This commit is contained in:
mycroft 1996-04-23 10:29:02 +00:00
parent 7ee33b9890
commit 584810c846
1 changed files with 54 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.70 1996/03/22 06:51:04 thorpej Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993
@ -1517,10 +1517,10 @@ sys_fchown(p, v, retval)
syscallarg(int) uid;
syscallarg(int) gid;
} */ *uap = v;
register struct vnode *vp;
struct vattr vattr;
struct vnode *vp;
struct file *fp;
int error;
struct file *fp;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
@ -1540,7 +1540,7 @@ sys_fchown(p, v, retval)
}
/*
* Set the access and modification times of a file.
* Set the access and modification times given a path name.
*/
/* ARGSUSED */
int
@ -1564,8 +1564,7 @@ sys_utimes(p, v, retval)
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
}
else {
} else {
error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv,
sizeof (tv));
if (error)
@ -1590,6 +1589,55 @@ sys_utimes(p, v, retval)
return (error);
}
/*
* Set the access and modification times given a file descriptor.
*/
/* ARGSUSED */
int
sys_futimes(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
register struct sys_futimes_args /* {
syscallarg(int) fd;
syscallarg(struct timeval *) tptr;
} */ *uap = v;
register struct vnode *vp;
struct timeval tv[2];
struct vattr vattr;
int error;
struct file *fp;
VATTR_NULL(&vattr);
if (SCARG(uap, tptr) == NULL) {
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
} else {
error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv,
sizeof (tv));
if (error)
return (error);
}
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
VOP_LOCK(vp);
if (vp->v_mount->mnt_flag & MNT_RDONLY)
error = EROFS;
else {
vattr.va_atime.tv_sec = tv[0].tv_sec;
vattr.va_atime.tv_nsec = tv[0].tv_usec * 1000;
vattr.va_mtime.tv_sec = tv[1].tv_sec;
vattr.va_mtime.tv_nsec = tv[1].tv_usec * 1000;
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
}
VOP_UNLOCK(vp);
return (error);
}
/*
* Truncate a file given its path name.
*/