diff options
author | Brad Smith <brad@cvs.openbsd.org> | 1999-10-07 16:14:29 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 1999-10-07 16:14:29 +0000 |
commit | b82e4f7f02749f8c8f7c5edb16b1d682d0416443 (patch) | |
tree | 3076d060f24be59f7076a97e8bfb13f083ee6abb /sys/compat/svr4 | |
parent | 30cec98535b35a16259e6816fbe4a0dcb015f3de (diff) |
- Fix stat and mknod syscalls to properly disassemble and reassemble
dev_t values to/from emulation dev_t's
- Implement fstat64, llseek and open64 system calls; from NetBSD
Diffstat (limited to 'sys/compat/svr4')
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.c | 34 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 8 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stat.c | 67 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stat.h | 25 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_types.h | 103 | ||||
-rw-r--r-- | sys/compat/svr4/syscalls.master | 11 |
6 files changed, 192 insertions, 56 deletions
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index 3772b9f5c0e..248fd36f384 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_fcntl.c,v 1.13 1997/12/20 16:32:08 deraadt Exp $ */ +/* $OpenBSD: svr4_fcntl.c,v 1.14 1999/10/07 16:14:28 brad Exp $ */ /* $NetBSD: svr4_fcntl.c,v 1.14 1995/10/14 20:24:24 christos Exp $ */ /* @@ -275,6 +275,15 @@ svr4_sys_open(p, v, retval) } int +svr4_sys_open64(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + return svr4_sys_open(p, v, retval); +} + +int svr4_sys_creat(p, v, retval) register struct proc *p; void *v; @@ -293,6 +302,29 @@ svr4_sys_creat(p, v, retval) return sys_open(p, &cup, retval); } +int +svr4_sys_llseek(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_llseek_args *uap = v; + struct sys_lseek_args ap; + + SCARG(&ap, fd) = SCARG(uap, fd); + +#if BYTE_ORDER == BIG_ENDIAN + SCARG(&ap, offset) = (((long long) SCARG(uap, offset1)) << 32) | + SCARG(uap, offset2); +#else + SCARG(&ap, offset) = (((long long) SCARG(uap, offset2)) << 32) | + SCARG(uap, offset1); +#endif + SCARG(&ap, whence) = SCARG(uap, whence); + + return sys_lseek(p, &ap, retval); +} + int svr4_sys_access(p, v, retval) register struct proc *p; diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index e011bb514fa..b9d75dce263 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_misc.c,v 1.23 1999/09/11 00:03:16 mickey Exp $ */ +/* $OpenBSD: svr4_misc.c,v 1.24 1999/10/07 16:14:28 brad Exp $ */ /* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */ /* @@ -436,7 +436,8 @@ svr4_sys_mknod(p, v, retval) { struct svr4_sys_mknod_args *uap = v; return svr4_mknod(p, retval, - SCARG(uap, path), SCARG(uap, mode), SCARG(uap, dev)); + SCARG(uap, path), SCARG(uap, mode), + svr4_to_bsd_odev_t(SCARG(uap, dev))); } @@ -448,7 +449,8 @@ svr4_sys_xmknod(p, v, retval) { struct svr4_sys_xmknod_args *uap = v; return svr4_mknod(p, retval, - SCARG(uap, path), SCARG(uap, mode), SCARG(uap, dev)); + SCARG(uap, path), SCARG(uap, mode), + svr4_to_bsd_odev_t(SCARG(uap, dev))); } diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c index a45c995db1b..3e064e83757 100644 --- a/sys/compat/svr4/svr4_stat.c +++ b/sys/compat/svr4/svr4_stat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_stat.c,v 1.16 1999/07/15 19:26:37 deraadt Exp $ */ +/* $OpenBSD: svr4_stat.c,v 1.17 1999/10/07 16:14:28 brad Exp $ */ /* $NetBSD: svr4_stat.c,v 1.21 1996/04/22 01:16:07 christos Exp $ */ /* @@ -69,6 +69,7 @@ #endif static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *)); +static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *)); int svr4_ustat __P((struct proc *, void *, register_t *)); static int svr4_to_bsd_pathconf __P((int)); @@ -88,13 +89,13 @@ bsd_to_svr4_stat(st, st4) struct svr4_stat *st4; { bzero(st4, sizeof(*st4)); - st4->st_dev = st->st_dev; + st4->st_dev = bsd_to_svr4_odev_t(st->st_dev); st4->st_ino = st->st_ino; st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode); st4->st_nlink = st->st_nlink; st4->st_uid = st->st_uid; st4->st_gid = st->st_gid; - st4->st_rdev = st->st_rdev; + st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev); st4->st_size = st->st_size; st4->st_atim = st->st_atimespec.tv_sec; st4->st_mtim = st->st_mtimespec.tv_sec; @@ -103,20 +104,19 @@ bsd_to_svr4_stat(st, st4) #endif - static void bsd_to_svr4_xstat(st, st4) struct stat *st; struct svr4_xstat *st4; { bzero(st4, sizeof(*st4)); - st4->st_dev = st->st_dev; + st4->st_dev = bsd_to_svr4_dev_t(st->st_dev); st4->st_ino = st->st_ino; st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode); st4->st_nlink = st->st_nlink; st4->st_uid = st->st_uid; st4->st_gid = st->st_gid; - st4->st_rdev = st->st_rdev; + st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev); st4->st_size = st->st_size; st4->st_atim = st->st_atimespec; st4->st_mtim = st->st_mtimespec; @@ -126,6 +126,28 @@ bsd_to_svr4_xstat(st, st4) strcpy(st4->st_fstype, "unknown"); } +static void +bsd_to_svr4_stat64(st, st4) + struct stat *st; + struct svr4_stat64 *st4; +{ + bzero(st4, sizeof(*st4)); + st4->st_dev = bsd_to_svr4_dev_t(st->st_dev); + st4->st_ino = st->st_ino; + st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode); + st4->st_nlink = st->st_nlink; + st4->st_uid = st->st_uid; + st4->st_gid = st->st_gid; + st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev); + st4->st_size = st->st_size; + st4->st_atim = st->st_atimespec; + st4->st_mtim = st->st_mtimespec; + st4->st_ctim = st->st_ctimespec; + st4->st_blksize = st->st_blksize; + st4->st_blocks = st->st_blocks; + strcpy(st4->st_fstype, "unknown"); +} + int svr4_sys_stat(p, v, retval) @@ -358,6 +380,39 @@ svr4_sys_fxstat(p, v, retval) return 0; } + +int +svr4_sys_fstat64(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_fstat64_args *uap = v; + struct stat st; + struct svr4_stat64 svr4_st; + struct sys_fstat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + + SCARG(&cup, fd) = SCARG(uap, fd); + SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); + + if ((error = sys_fstat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_stat64(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0) + return error; + + return 0; +} + + struct svr4_ustat_args { syscallarg(svr4_dev_t) dev; syscallarg(struct svr4_ustat *) name; diff --git a/sys/compat/svr4/svr4_stat.h b/sys/compat/svr4/svr4_stat.h index 45c49191ba8..58695297c3d 100644 --- a/sys/compat/svr4/svr4_stat.h +++ b/sys/compat/svr4/svr4_stat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_stat.h,v 1.2 1996/02/26 23:32:02 niklas Exp $ */ +/* $OpenBSD: svr4_stat.h,v 1.3 1999/10/07 16:14:28 brad Exp $ */ /* $NetBSD: svr4_stat.h,v 1.4 1996/02/10 17:12:38 christos Exp $ */ /* @@ -64,7 +64,27 @@ struct svr4_xstat { svr4_timestruc_t st_mtim; svr4_timestruc_t st_ctim; long st_blksize; - long st_blocks; + svr4_blkcnt_t st_blocks; + char st_fstype[16]; + long st_pad4[8]; +}; + +struct svr4_stat64 { + svr4_dev_t st_dev; + long st_pad1[3]; + svr4_ino64_t st_ino; + svr4_mode_t st_mode; + svr4_nlink_t st_nlink; + svr4_uid_t st_uid; + svr4_gid_t st_gid; + svr4_dev_t st_rdev; + long st_pad2[2]; + svr4_off64_t st_size; + svr4_timestruc_t st_atim; + svr4_timestruc_t st_mtim; + svr4_timestruc_t st_ctim; + long st_blksize; + svr4_blkcnt64_t st_blocks; char st_fstype[16]; long st_pad4[8]; }; @@ -81,5 +101,6 @@ struct svr4_xstat { #define SVR4_PC_ASYNC_IO 10 #define SVR4_PC_PRIO_IO 11 #define SVR4_PC_SYNC_IO 12 +#define SVR4_PC_FILESIZEBITS 67 #endif /* !_SVR4_STAT_H_ */ diff --git a/sys/compat/svr4/svr4_types.h b/sys/compat/svr4/svr4_types.h index 433e8eefafc..b40939cfd42 100644 --- a/sys/compat/svr4/svr4_types.h +++ b/sys/compat/svr4/svr4_types.h @@ -1,10 +1,13 @@ -/* $OpenBSD: svr4_types.h,v 1.3 1996/08/02 20:35:46 niklas Exp $ */ -/* $NetBSD: svr4_types.h,v 1.7 1995/10/14 20:25:04 christos Exp $ */ +/* $OpenBSD: svr4_types.h,v 1.4 1999/10/07 16:14:28 brad Exp $ */ +/* $NetBSD: svr4_types.h,v 1.11 1998/09/11 12:34:46 mycroft Exp $ */ -/* - * Copyright (c) 1994 Christos Zoulas +/*- + * Copyright (c) 1994 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,47 +16,67 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _SVR4_TYPES_H_ #define _SVR4_TYPES_H_ -typedef long svr4_off_t; -typedef u_long svr4_dev_t; -typedef u_long svr4_ino_t; -typedef u_long svr4_mode_t; -typedef u_long svr4_nlink_t; -typedef long svr4_uid_t; -typedef long svr4_gid_t; -typedef long svr4_daddr_t; -typedef long svr4_pid_t; -typedef long svr4_time_t; -typedef char *svr4_caddr_t; -typedef u_int svr4_size_t; - -typedef short svr4_o_dev_t; -typedef short svr4_o_pid_t; -typedef u_short svr4_o_ino_t; -typedef u_short svr4_o_mode_t; -typedef short svr4_o_nlink_t; -typedef u_short svr4_o_uid_t; -typedef u_short svr4_o_gid_t; -typedef long svr4_clock_t; -typedef int svr4_key_t; - -typedef struct timespec svr4_timestruc_t; +typedef u_quad_t svr4_ino64_t; +typedef quad_t svr4_off64_t; +typedef quad_t svr4_blkcnt64_t; +typedef u_quad_t svr4_fsblkcnt64_t; + +typedef long svr4_off_t; +typedef u_long svr4_dev_t; +typedef u_long svr4_ino_t; +typedef u_long svr4_mode_t; +typedef u_long svr4_nlink_t; +typedef long svr4_uid_t; +typedef long svr4_gid_t; +typedef long svr4_daddr_t; +typedef long svr4_pid_t; +typedef long svr4_time_t; +typedef long svr4_blkcnt_t; +typedef u_long svr4_fsblkcnt_t; +typedef char *svr4_caddr_t; +typedef u_int svr4_size_t; + +typedef short svr4_o_dev_t; +typedef short svr4_o_pid_t; +typedef u_short svr4_o_ino_t; +typedef u_short svr4_o_mode_t; +typedef short svr4_o_nlink_t; +typedef u_short svr4_o_uid_t; +typedef u_short svr4_o_gid_t; +typedef long svr4_clock_t; +typedef int svr4_key_t; + +typedef struct timespec svr4_timestruc_t; + +#define bsd_to_svr4_odev_t(d) svr4_omakedev(major(d), minor(d)) + +#define svr4_makedev(x,y) ((svr4_dev_t)((((x) << 18) & 0xfffc0000) | \ + (((y) << 0) & 0x0003ffff))) + +#define bsd_to_svr4_dev_t(d) svr4_makedev(major(d), minor(d)) #endif /* !_SVR4_TYPES_H_ */ diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master index 1abb1a1ff86..1cfe8aed631 100644 --- a/sys/compat/svr4/syscalls.master +++ b/sys/compat/svr4/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.24 1999/06/07 07:17:48 deraadt Exp $ + $OpenBSD: syscalls.master,v 1.25 1999/10/07 16:14:28 brad Exp $ ; $NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -276,7 +276,8 @@ size_t nbyte, svr4_off_t off); } 174 STD { ssize_t svr4_sys_pwrite(int fd, const void *buf, \ size_t nbyte, svr4_off_t off); } -175 UNIMPL llseek +175 STD { svr4_off64_t svr4_sys_llseek(int fd, \ + long offset1, long offset2, int whence); } 176 UNIMPL inst_sync 177 UNIMPL 178 UNIMPL kaio @@ -325,7 +326,8 @@ 214 UNIMPL mmap64 215 UNIMPL stat64 216 UNIMPL lstat64 -217 UNIMPL fstat64 +217 STD { int svr4_sys_fstat64(int fd, \ + struct svr4_stat64 *sb); } 218 UNIMPL statvfs64 219 UNIMPL fstatvfs64 220 UNIMPL setrlimit64 @@ -333,7 +335,8 @@ 222 UNIMPL pread64 223 UNIMPL pwrite64 224 UNIMPL creat64 -225 UNIMPL open64 +225 STD { int svr4_sys_open64(char *path, int flags, \ + int mode); } 226 UNIMPL rpcsys 227 UNIMPL 228 UNIMPL |