From 20a2ff3d1602c6836223bfb3b367a49a12b55366 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 19 Dec 1995 07:12:53 +0000 Subject: [PATCH] Added utime and utimes --- sys/compat/svr4/svr4_stat.c | 47 +++++++++++++++++++++++++++++- sys/compat/svr4/svr4_syscall.h | 2 ++ sys/compat/svr4/svr4_syscallargs.h | 12 ++++++++ sys/compat/svr4/svr4_syscalls.c | 4 +-- sys/compat/svr4/svr4_sysent.c | 9 +++--- sys/compat/svr4/svr4_time.h | 7 ++++- sys/compat/svr4/syscalls.master | 9 ++++-- 7 files changed, 79 insertions(+), 11 deletions(-) diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c index f8db45508d6d..b09188dfa525 100644 --- a/sys/compat/svr4/svr4_stat.c +++ b/sys/compat/svr4/svr4_stat.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_stat.c,v 1.14 1995/10/14 20:24:43 christos Exp $ */ +/* $NetBSD: svr4_stat.c,v 1.15 1995/12/19 07:12:53 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -509,3 +509,48 @@ svr4_sys_utssys(p, v, retval) } return ENOSYS; } + + +int +svr4_sys_utime(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_utime_args *uap = v; + struct svr4_utimbuf ub; + struct timeval tbuf[2]; + struct sys_utimes_args ap; + int error; + caddr_t sg = stackgap_init(p->p_emul); + + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + SCARG(&ap, path) = SCARG(uap, path); + if (SCARG(uap, ubuf) == NULL) { + if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0) + return error; + tbuf[0].tv_sec = ub.actime; + tbuf[0].tv_usec = 0; + tbuf[1].tv_sec = ub.modtime; + tbuf[1].tv_usec = 0; + SCARG(&ap, tptr) = stackgap_alloc(&sg, sizeof(tbuf)); + if (error = copyout(tbuf, SCARG(&ap, tptr), sizeof(tbuf)) != 0) + return error; + } + else + SCARG(&ap, tptr) = NULL; + return sys_utimes(p, &ap, retval); +} + + +int +svr4_sys_utimes(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_utimes_args *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + return sys_utimes(p, uap, retval); +} diff --git a/sys/compat/svr4/svr4_syscall.h b/sys/compat/svr4/svr4_syscall.h index ed736807598d..b69c5848754e 100644 --- a/sys/compat/svr4/svr4_syscall.h +++ b/sys/compat/svr4/svr4_syscall.h @@ -30,6 +30,7 @@ #define SVR4_SYS_getuid 24 #define SVR4_SYS_alarm 27 #define SVR4_SYS_fstat 28 +#define SVR4_SYS_utime 30 #define SVR4_SYS_access 33 #define SVR4_SYS_sync 36 #define SVR4_SYS_kill 37 @@ -106,6 +107,7 @@ #define SVR4_SYS_systeminfo 139 #define SVR4_SYS_seteuid 141 #define SVR4_SYS_fchroot 153 +#define SVR4_SYS_utimes 154 #define SVR4_SYS_vhangup 155 #define SVR4_SYS_gettimeofday 156 #define SVR4_SYS_getitimer 157 diff --git a/sys/compat/svr4/svr4_syscallargs.h b/sys/compat/svr4/svr4_syscallargs.h index 9823845dfa30..d4ccc8efe577 100644 --- a/sys/compat/svr4/svr4_syscallargs.h +++ b/sys/compat/svr4/svr4_syscallargs.h @@ -55,6 +55,11 @@ struct svr4_sys_fstat_args { syscallarg(struct svr4_stat *) sb; }; +struct svr4_sys_utime_args { + syscallarg(char *) path; + syscallarg(struct svr4_utimbuf *) ubuf; +}; + struct svr4_sys_access_args { syscallarg(char *) path; syscallarg(int) flags; @@ -281,6 +286,11 @@ struct svr4_sys_fchroot_args { syscallarg(int) fd; }; +struct svr4_sys_utimes_args { + syscallarg(char *) path; + syscallarg(struct timeval *) tptr; +}; + struct svr4_sys_gettimeofday_args { syscallarg(struct timeval *) tp; }; @@ -314,6 +324,7 @@ int sys_setuid __P((struct proc *, void *, register_t *)); int sys_getuid __P((struct proc *, void *, register_t *)); int svr4_sys_alarm __P((struct proc *, void *, register_t *)); int svr4_sys_fstat __P((struct proc *, void *, register_t *)); +int svr4_sys_utime __P((struct proc *, void *, register_t *)); int svr4_sys_access __P((struct proc *, void *, register_t *)); int sys_sync __P((struct proc *, void *, register_t *)); int svr4_sys_kill __P((struct proc *, void *, register_t *)); @@ -389,6 +400,7 @@ int sys_adjtime __P((struct proc *, void *, register_t *)); int svr4_sys_systeminfo __P((struct proc *, void *, register_t *)); int sys_seteuid __P((struct proc *, void *, register_t *)); int svr4_sys_fchroot __P((struct proc *, void *, register_t *)); +int svr4_sys_utimes __P((struct proc *, void *, register_t *)); int svr4_sys_vhangup __P((struct proc *, void *, register_t *)); int svr4_sys_gettimeofday __P((struct proc *, void *, register_t *)); int sys_getitimer __P((struct proc *, void *, register_t *)); diff --git a/sys/compat/svr4/svr4_syscalls.c b/sys/compat/svr4/svr4_syscalls.c index 3998cdb8eee4..c652d0060fa3 100644 --- a/sys/compat/svr4/svr4_syscalls.c +++ b/sys/compat/svr4/svr4_syscalls.c @@ -36,7 +36,7 @@ char *svr4_syscallnames[] = { "alarm", /* 27 = alarm */ "fstat", /* 28 = fstat */ "#29 (unimplemented pause)", /* 29 = unimplemented pause */ - "#30 (unimplemented utime)", /* 30 = unimplemented utime */ + "utime", /* 30 = utime */ "#31 (unimplemented was stty)", /* 31 = unimplemented was stty */ "#32 (unimplemented was gtty)", /* 32 = unimplemented was gtty */ "access", /* 33 = access */ @@ -172,7 +172,7 @@ char *svr4_syscallnames[] = { "#151 (unimplemented)", /* 151 = unimplemented */ "#152 (unimplemented modctl)", /* 152 = unimplemented modctl */ "fchroot", /* 153 = fchroot */ - "#154 (unimplemented utimes)", /* 154 = unimplemented utimes */ + "utimes", /* 154 = utimes */ "vhangup", /* 155 = vhangup */ "gettimeofday", /* 156 = gettimeofday */ "getitimer", /* 157 = getitimer */ diff --git a/sys/compat/svr4/svr4_sysent.c b/sys/compat/svr4/svr4_sysent.c index c48f9ebf9e12..6c0b7fa496a1 100644 --- a/sys/compat/svr4/svr4_sysent.c +++ b/sys/compat/svr4/svr4_sysent.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -97,8 +98,8 @@ struct sysent svr4_sysent[] = { svr4_sys_fstat }, /* 28 = fstat */ { 0, 0, sys_nosys }, /* 29 = unimplemented pause */ - { 0, 0, - sys_nosys }, /* 30 = unimplemented utime */ + { 2, s(struct svr4_sys_utime_args), + svr4_sys_utime }, /* 30 = utime */ { 0, 0, sys_nosys }, /* 31 = unimplemented was stty */ { 0, 0, @@ -360,8 +361,8 @@ struct sysent svr4_sysent[] = { sys_nosys }, /* 152 = unimplemented modctl */ { 1, s(struct svr4_sys_fchroot_args), svr4_sys_fchroot }, /* 153 = fchroot */ - { 0, 0, - sys_nosys }, /* 154 = unimplemented utimes */ + { 2, s(struct svr4_sys_utimes_args), + svr4_sys_utimes }, /* 154 = utimes */ { 0, 0, svr4_sys_vhangup }, /* 155 = vhangup */ { 1, s(struct svr4_sys_gettimeofday_args), diff --git a/sys/compat/svr4/svr4_time.h b/sys/compat/svr4/svr4_time.h index 8944788c4a2b..7644cfcb877b 100644 --- a/sys/compat/svr4/svr4_time.h +++ b/sys/compat/svr4/svr4_time.h @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_time.h,v 1.3 1994/10/29 00:43:28 christos Exp $ */ +/* $NetBSD: svr4_time.h,v 1.4 1995/12/19 07:13:23 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -33,4 +33,9 @@ #include #include +struct svr4_utimbuf { + time_t actime; + time_t modtime; +}; + #endif /* !_SVR4_TIME_H_ */ diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master index 2b8a3f11a3de..fb07135a50df 100644 --- a/sys/compat/svr4/syscalls.master +++ b/sys/compat/svr4/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.14 1995/10/14 20:25:06 christos Exp $ + $NetBSD: syscalls.master,v 1.15 1995/12/19 07:13:27 christos Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,8 @@ 27 STD { int svr4_sys_alarm(unsigned sec); } 28 STD { int svr4_sys_fstat(int fd, struct svr4_stat *sb); } 29 UNIMPL pause -30 UNIMPL utime +30 STD { int svr4_sys_utime(char *path, \ + struct svr4_utimbuf *ubuf); } 31 UNIMPL was stty 32 UNIMPL was gtty 33 STD { int svr4_sys_access(char *path, int flags); } @@ -240,7 +242,8 @@ 151 UNIMPL 152 UNIMPL modctl 153 STD { int svr4_sys_fchroot(int fd); } -154 UNIMPL utimes +154 STD { int svr4_sys_utimes(char *path, \ + struct timeval *tptr); } 155 STD { int svr4_sys_vhangup(void); } 156 STD { int svr4_sys_gettimeofday(struct timeval *tp); } 157 NOARGS { int sys_getitimer(u_int which, \