Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/kern/lib/libsys_sunos Add enough syscall compat for...
details: https://anonhg.NetBSD.org/src/rev/ba68de95626c
branches: trunk
changeset: 785987:ba68de95626c
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Apr 09 13:08:33 2013 +0000
description:
Add enough syscall compat for fs-utils to work on modern Solaris
and derivatives.
diffstat:
sys/rump/kern/lib/libsys_sunos/Makefile | 12 +
sys/rump/kern/lib/libsys_sunos/component.c | 31 +
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c | 377 +++++++++++++
sys/rump/kern/lib/libsys_sunos/shlib_version | 4 +
sys/rump/kern/lib/libsys_sunos/syscalls.conf | 14 +
sys/rump/kern/lib/libsys_sunos/syscalls.master | 576 +++++++++++++++++++++
6 files changed, 1014 insertions(+), 0 deletions(-)
diffs (truncated from 1038 to 300 lines):
diff -r a65bb07f47a8 -r ba68de95626c sys/rump/kern/lib/libsys_sunos/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/kern/lib/libsys_sunos/Makefile Tue Apr 09 13:08:33 2013 +0000
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1 2013/04/09 13:08:33 pooka Exp $
+#
+
+LIB= rumpkern_sys_sunos
+
+SRCS= rump_sunos_compat.c rump_sunos_sysent.c component.c
+
+# XXX
+CPPFLAGS+= -I${.CURDIR} -I${RUMPTOP}/librump/rumpkern
+
+.include <bsd.lib.mk>
+.include <bsd.klinks.mk>
diff -r a65bb07f47a8 -r ba68de95626c sys/rump/kern/lib/libsys_sunos/component.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/kern/lib/libsys_sunos/component.c Tue Apr 09 13:08:33 2013 +0000
@@ -0,0 +1,31 @@
+/* $NetBSD: component.c,v 1.1 2013/04/09 13:08:33 pooka Exp $ */
+
+#include <sys/param.h>
+#include <sys/proc.h>
+
+#include <uvm/uvm_extern.h>
+
+#include "rump_private.h"
+
+#include "rump_sunos_syscall.h"
+
+extern struct sysent rump_sunos_sysent[];
+
+struct emul emul_rump_sys_sunos = {
+ .e_name = "sunos-rump",
+ .e_sysent = rump_sunos_sysent,
+#ifndef __HAVE_MINIMAL_EMUL
+ .e_nsysent = RUMP_SUNOS_SYS_NSYSENT,
+#endif
+ .e_vm_default_addr = uvm_default_mapaddr,
+#ifdef __HAVE_SYSCALL_INTERN
+ .e_syscall_intern = syscall_intern,
+#endif
+};
+
+RUMP_COMPONENT(RUMP_COMPONENT_KERN)
+{
+ extern struct emul *emul_default;
+
+ emul_default = &emul_rump_sys_sunos;
+}
diff -r a65bb07f47a8 -r ba68de95626c sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c Tue Apr 09 13:08:33 2013 +0000
@@ -0,0 +1,377 @@
+/* $NetBSD: rump_sunos_compat.c,v 1.1 2013/04/09 13:08:33 pooka Exp $ */
+
+/*
+ * Copyright (c) 2013 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * 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 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.
+ */
+
+#include <sys/param.h>
+#include <sys/dirent.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/malloc.h>
+#include <sys/namei.h>
+#include <sys/stat.h>
+#include <sys/syscallargs.h>
+#include <sys/vnode.h>
+#include <sys/vfs_syscalls.h>
+
+#include <compat/sys/time_types.h>
+
+#include "rump_sunos_syscallargs.h"
+
+#define SUNOS_MAXNAMLEN 255
+
+struct sunos_dirent {
+ uint64_t d_fileno;
+ int64_t d_off;
+ unsigned short d_reclen;
+ char d_name[SUNOS_MAXNAMLEN + 1];
+};
+
+#define SUNOS_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
+#define SUNOS_RECLEN(de,namlen) ALIGN((SUNOS_NAMEOFF(de) + (namlen) + 1))
+
+/*
+ * Rump kernels always use the _FILE_OFFSET_BITS=64 API.
+ */
+#ifdef __LP64__
+struct sunos_stat {
+ unsigned long st_dev;
+ uint64_t st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned long st_rdev;
+ off_t st_size;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ int st_blksize;
+ uint64_t st_blocks;
+ char st_fstype[16];
+};
+#else
+struct sunos_stat {
+ unsigned long st_dev;
+ long st_pad1[3];
+ uint64_t st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned long st_rdev;
+ long st_pad2[2];
+ off_t st_size;
+
+ struct timespec50 st_atim;
+ struct timespec50 st_mtim;
+ struct timespec50 st_ctim;
+
+ int st_blksize;
+ uint64_t st_blocks;
+ char st_fstype[16];
+ long st_pad4[8];
+};
+#endif
+
+#define PARCOPY(a) ssb->a = sb->a
+static void
+bsd_to_sunos_stat(const struct stat *sb, struct sunos_stat *ssb)
+{
+
+ memset(ssb, 0, sizeof(*ssb));
+ PARCOPY(st_dev);
+ PARCOPY(st_ino);
+ PARCOPY(st_mode);
+ PARCOPY(st_nlink);
+ PARCOPY(st_uid);
+ PARCOPY(st_gid);
+ PARCOPY(st_rdev);
+ PARCOPY(st_size);
+ PARCOPY(st_blksize);
+ PARCOPY(st_blocks);
+
+#ifdef __LP64__
+ ssb->st_atim = sb->st_atimespec;
+ ssb->st_mtim = sb->st_mtimespec;
+ ssb->st_ctim = sb->st_ctimespec;
+#else
+ timespec_to_timespec50(&sb->st_atimespec, &ssb->st_atim);
+ timespec_to_timespec50(&sb->st_mtimespec, &ssb->st_mtim);
+ timespec_to_timespec50(&sb->st_ctimespec, &ssb->st_ctim);
+#endif
+}
+
+int
+rump_sunos_sys_stat(struct lwp *l, const struct rump_sunos_sys_stat_args *uap,
+ register_t *retval)
+{
+ struct sunos_stat ssb;
+ struct stat sb;
+ int error;
+
+ error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
+ if (error)
+ return error;
+
+ bsd_to_sunos_stat(&sb, &ssb);
+
+ return copyout(&ssb, SCARG(uap, sp), sizeof(ssb));
+}
+
+int
+rump_sunos_sys_fstat(struct lwp *l, const struct rump_sunos_sys_fstat_args *uap,
+ register_t *retval)
+{
+ struct sunos_stat ssb;
+ struct stat sb;
+ int error;
+
+ error = do_sys_fstat(SCARG(uap, fd), &sb);
+ if (error)
+ return error;
+
+ bsd_to_sunos_stat(&sb, &ssb);
+
+ return copyout(&ssb, SCARG(uap, sp), sizeof(ssb));
+}
+
+int
+rump_sunos_sys_lstat(struct lwp *l, const struct rump_sunos_sys_lstat_args *uap,
+ register_t *retval)
+{
+ struct sunos_stat ssb;
+ struct stat sb;
+ int error;
+
+ error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
+ if (error)
+ return error;
+
+ bsd_to_sunos_stat(&sb, &ssb);
+
+ return copyout(&ssb, SCARG(uap, sp), sizeof(ssb));
+}
+
+int
+rump_sunos_sys_open(struct lwp *l, const struct rump_sunos_sys_open_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(const char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */
+ struct sys_open_args ua;
+ int sflags, flags;
+
+ sflags = SCARG(uap, flags);
+ flags = (sflags & (0x8 | 0x4 | 0x3)); /* nonblock/append/rw */
+ flags |= (sflags & 0x10) ? O_SYNC : 0;
+ flags |= (sflags & 0x40) ? O_DSYNC : 0;
+ flags |= (sflags & 0x8000) ? O_RSYNC : 0;
+ flags |= (sflags & 0x80) ? O_NONBLOCK : 0;
+ flags |= (sflags & 0x100) ? O_CREAT : 0;
+ flags |= (sflags & 0x200) ? O_TRUNC : 0;
+ flags |= (sflags & 0x400) ? O_EXCL : 0;
+ flags |= (sflags & 0x20000) ? O_NOFOLLOW : 0;
+
+ SCARG(&ua, path) = SCARG(uap, path);
+ SCARG(&ua, flags) = flags;
+ SCARG(&ua, mode) = SCARG(uap, mode);
+
+ return sys_open(l, &ua, retval);
+}
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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. Neither the name of the University 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 REGENTS 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 REGENTS 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.
Home |
Main Index |
Thread Index |
Old Index