Module Name: src
Committed By: riz
Date: Wed Nov 4 17:46:21 UTC 2015
Modified Files:
src/sys/compat/netbsd32 [netbsd-7]: files.netbsd32 netbsd32.h
netbsd32_conv.h netbsd32_syscall.h netbsd32_syscallargs.h
netbsd32_syscalls.c netbsd32_sysent.c syscalls.master
src/sys/nfs [netbsd-7]: nfs_syscalls.c nfs_var.h
Added Files:
src/sys/compat/netbsd32 [netbsd-7]: netbsd32_nfssvc.c
Log Message:
Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.10.1 src/sys/compat/netbsd32/files.netbsd32
cvs rdiff -u -r1.102 -r1.102.2.1 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.28 -r1.28.4.1 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r0 -r1.3.4.2 src/sys/compat/netbsd32/netbsd32_nfssvc.c
cvs rdiff -u -r1.109.2.1 -r1.109.2.2 \
src/sys/compat/netbsd32/netbsd32_syscall.h \
src/sys/compat/netbsd32/netbsd32_syscallargs.h
cvs rdiff -u -r1.108.2.1 -r1.108.2.2 \
src/sys/compat/netbsd32/netbsd32_syscalls.c \
src/sys/compat/netbsd32/netbsd32_sysent.c
cvs rdiff -u -r1.101.2.1 -r1.101.2.2 src/sys/compat/netbsd32/syscalls.master
cvs rdiff -u -r1.154 -r1.154.4.1 src/sys/nfs/nfs_syscalls.c
cvs rdiff -u -r1.92.2.1 -r1.92.2.2 src/sys/nfs/nfs_var.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/netbsd32/files.netbsd32
diff -u src/sys/compat/netbsd32/files.netbsd32:1.33 src/sys/compat/netbsd32/files.netbsd32:1.33.10.1
--- src/sys/compat/netbsd32/files.netbsd32:1.33 Fri Mar 29 01:04:30 2013
+++ src/sys/compat/netbsd32/files.netbsd32 Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-# $NetBSD: files.netbsd32,v 1.33 2013/03/29 01:04:30 christos Exp $
+# $NetBSD: files.netbsd32,v 1.33.10.1 2015/11/04 17:46:21 riz Exp $
#
# config file description for machine-independent netbsd32 compat code.
# included by ports that need it.
@@ -17,6 +17,7 @@ file compat/netbsd32/netbsd32_ioctl.c co
file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
file compat/netbsd32/netbsd32_lwp.c compat_netbsd32
file compat/netbsd32/netbsd32_mod.c compat_netbsd32
+file compat/netbsd32/netbsd32_nfssvc.c compat_netbsd32 & nfsserver
file compat/netbsd32/netbsd32_select.c compat_netbsd32
file compat/netbsd32/netbsd32_sem.c compat_netbsd32
file compat/netbsd32/netbsd32_signal.c compat_netbsd32
Index: src/sys/compat/netbsd32/netbsd32.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.102 src/sys/compat/netbsd32/netbsd32.h:1.102.2.1
--- src/sys/compat/netbsd32/netbsd32.h:1.102 Sat Jun 28 22:27:50 2014
+++ src/sys/compat/netbsd32/netbsd32.h Wed Nov 4 17:46:21 2015
@@ -1,7 +1,7 @@
-/* $NetBSD: netbsd32.h,v 1.102 2014/06/28 22:27:50 dholland Exp $ */
+/* $NetBSD: netbsd32.h,v 1.102.2.1 2015/11/04 17:46:21 riz Exp $ */
/*
- * Copyright (c) 1998, 2001, 2008 Matthew R. Green
+ * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,8 @@
#include <compat/sys/mount.h>
#include <compat/sys/signal.h>
+#include <nfs/rpcv2.h>
+
/*
* first, define the basic types we need.
*/
@@ -928,6 +930,48 @@ struct netbsd32_mfs_args {
netbsd32_u_long size;
};
+/* from <nfs/nfs.h> */
+struct netbsd32_nfsd_args {
+ int sock;
+ netbsd32_voidp name;
+ int namelen;
+};
+
+typedef netbsd32_pointer_t netbsd32_nfsdp;
+struct netbsd32_nfsd_srvargs {
+ netbsd32_nfsdp nsd_nfsd;
+ uid_t nsd_uid;
+ u_int32_t nsd_haddr;
+ struct uucred nsd_cr;
+ int nsd_authlen;
+ netbsd32_u_charp nsd_authstr;
+ int nsd_verflen;
+ netbsd32_u_charp nsd_verfstr;
+ struct netbsd32_timeval nsd_timestamp;
+ u_int32_t nsd_ttl;
+ NFSKERBKEY_T nsd_key;
+};
+
+typedef netbsd32_pointer_t netbsd32_export_argsp;
+struct netbsd32_export_args {
+ int ex_flags;
+ uid_t ex_root;
+ struct uucred ex_anon;
+ netbsd32_sockaddrp_t ex_addr;
+ int ex_addrlen;
+ netbsd32_sockaddrp_t ex_mask;
+ int ex_masklen;
+ netbsd32_charp ex_indexfile;
+};
+
+struct netbsd32_mountd_exports_list {
+ const netbsd32_charp mel_path;
+ netbsd32_size_t mel_nexports;
+ netbsd32_export_argsp mel_exports;
+};
+
+/* no struct export_args30 yet */
+
/* from <nfs/nfsmount,h> */
struct netbsd32_nfs_args {
int32_t version; /* args structure version number */
@@ -949,6 +993,8 @@ struct netbsd32_nfs_args {
int32_t deadthresh; /* Retrans threshold */
netbsd32_charp hostname; /* server's name */
};
+
+/* from <msdosfs/msdosfsmount.h> */
struct netbsd32_msdosfs_args {
netbsd32_charp fspec; /* blocks special holding the fs to mount */
struct netbsd32_export_args30 _pad1; /* compat with old userland tools */
Index: src/sys/compat/netbsd32/netbsd32_conv.h
diff -u src/sys/compat/netbsd32/netbsd32_conv.h:1.28 src/sys/compat/netbsd32/netbsd32_conv.h:1.28.4.1
--- src/sys/compat/netbsd32/netbsd32_conv.h:1.28 Tue Mar 18 18:20:41 2014
+++ src/sys/compat/netbsd32/netbsd32_conv.h Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_conv.h,v 1.28 2014/03/18 18:20:41 riastradh Exp $ */
+/* $NetBSD: netbsd32_conv.h,v 1.28.4.1 2015/11/04 17:46:21 riz Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -39,6 +39,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/dirent.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#define msg __msg /* Don't ask me! */
Index: src/sys/compat/netbsd32/netbsd32_syscall.h
diff -u src/sys/compat/netbsd32/netbsd32_syscall.h:1.109.2.1 src/sys/compat/netbsd32/netbsd32_syscall.h:1.109.2.2
--- src/sys/compat/netbsd32/netbsd32_syscall.h:1.109.2.1 Sat Mar 7 05:27:53 2015
+++ src/sys/compat/netbsd32/netbsd32_syscall.h Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_syscall.h,v 1.109.2.1 2015/03/07 05:27:53 snj Exp $ */
+/* $NetBSD: netbsd32_syscall.h,v 1.109.2.2 2015/11/04 17:46:21 riz Exp $ */
/*
* System call numbers.
@@ -441,6 +441,9 @@
/* syscall: "compat_43_netbsd32_ogetsockname" ret: "int" args: "int" "netbsd32_voidp" "netbsd32_intp" */
#define NETBSD32_SYS_compat_43_netbsd32_ogetsockname 150
+/* syscall: "netbsd32_nfssvc" ret: "int" args: "int" "netbsd32_voidp" */
+#define NETBSD32_SYS_netbsd32_nfssvc 155
+
/* syscall: "compat_43_netbsd32_ogetdirentries" ret: "int" args: "int" "netbsd32_charp" "u_int" "netbsd32_longp" */
#define NETBSD32_SYS_compat_43_netbsd32_ogetdirentries 156
Index: src/sys/compat/netbsd32/netbsd32_syscallargs.h
diff -u src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.109.2.1 src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.109.2.2
--- src/sys/compat/netbsd32/netbsd32_syscallargs.h:1.109.2.1 Sat Mar 7 05:27:54 2015
+++ src/sys/compat/netbsd32/netbsd32_syscallargs.h Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_syscallargs.h,v 1.109.2.1 2015/03/07 05:27:54 snj Exp $ */
+/* $NetBSD: netbsd32_syscallargs.h,v 1.109.2.2 2015/11/04 17:46:21 riz Exp $ */
/*
* System call argument lists.
@@ -816,6 +816,12 @@ struct compat_43_netbsd32_ogetsockname_a
};
check_syscall_args(compat_43_netbsd32_ogetsockname)
+struct netbsd32_nfssvc_args {
+ syscallarg(int) flag;
+ syscallarg(netbsd32_voidp) argp;
+};
+check_syscall_args(netbsd32_nfssvc)
+
struct compat_43_netbsd32_ogetdirentries_args {
syscallarg(int) fd;
syscallarg(netbsd32_charp) buf;
@@ -2749,6 +2755,8 @@ int compat_43_sys_quota(struct lwp *, co
int compat_43_netbsd32_ogetsockname(struct lwp *, const struct compat_43_netbsd32_ogetsockname_args *, register_t *);
+int netbsd32_nfssvc(struct lwp *, const struct netbsd32_nfssvc_args *, register_t *);
+
int compat_43_netbsd32_ogetdirentries(struct lwp *, const struct compat_43_netbsd32_ogetdirentries_args *, register_t *);
int compat_20_netbsd32_statfs(struct lwp *, const struct compat_20_netbsd32_statfs_args *, register_t *);
Index: src/sys/compat/netbsd32/netbsd32_syscalls.c
diff -u src/sys/compat/netbsd32/netbsd32_syscalls.c:1.108.2.1 src/sys/compat/netbsd32/netbsd32_syscalls.c:1.108.2.2
--- src/sys/compat/netbsd32/netbsd32_syscalls.c:1.108.2.1 Sat Mar 7 05:27:54 2015
+++ src/sys/compat/netbsd32/netbsd32_syscalls.c Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_syscalls.c,v 1.108.2.1 2015/03/07 05:27:54 snj Exp $ */
+/* $NetBSD: netbsd32_syscalls.c,v 1.108.2.2 2015/11/04 17:46:21 riz Exp $ */
/*
* System call names.
@@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.108.2.1 2015/03/07 05:27:54 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscalls.c,v 1.108.2.2 2015/11/04 17:46:21 riz Exp $");
#if defined(_KERNEL_OPT)
#if defined(_KERNEL_OPT)
@@ -182,7 +182,7 @@ const char *const netbsd32_syscallnames[
/* 152 */ "#152 (unimplemented)",
/* 153 */ "#153 (unimplemented)",
/* 154 */ "#154 (unimplemented)",
- /* 155 */ "#155 (unimplemented netbsd32_nfssvc)",
+ /* 155 */ "netbsd32_nfssvc",
/* 156 */ "compat_43_netbsd32_ogetdirentries",
/* 157 */ "compat_20_netbsd32_statfs",
/* 158 */ "compat_20_netbsd32_fstatfs",
Index: src/sys/compat/netbsd32/netbsd32_sysent.c
diff -u src/sys/compat/netbsd32/netbsd32_sysent.c:1.108.2.1 src/sys/compat/netbsd32/netbsd32_sysent.c:1.108.2.2
--- src/sys/compat/netbsd32/netbsd32_sysent.c:1.108.2.1 Sat Mar 7 05:27:54 2015
+++ src/sys/compat/netbsd32/netbsd32_sysent.c Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_sysent.c,v 1.108.2.1 2015/03/07 05:27:54 snj Exp $ */
+/* $NetBSD: netbsd32_sysent.c,v 1.108.2.2 2015/11/04 17:46:21 riz Exp $ */
/*
* System call switch table.
@@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.108.2.1 2015/03/07 05:27:54 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysent.c,v 1.108.2.2 2015/11/04 17:46:21 riz Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -424,7 +424,7 @@ struct sysent netbsd32_sysent[] = {
{ 0, 0, 0,
sys_nosys }, /* 154 = unimplemented */
{ 0, 0, 0,
- sys_nosys }, /* 155 = unimplemented netbsd32_nfssvc */
+ (sy_call_t *)netbsd32_nfssvc }, /* 155 = netbsd32_nfssvc */
{ ns(struct compat_43_netbsd32_ogetdirentries_args), 0,
(sy_call_t *)compat_43(netbsd32_ogetdirentries) },/* 156 = compat_43_netbsd32_ogetdirentries */
{ ns(struct compat_20_netbsd32_statfs_args), 0,
Index: src/sys/compat/netbsd32/syscalls.master
diff -u src/sys/compat/netbsd32/syscalls.master:1.101.2.1 src/sys/compat/netbsd32/syscalls.master:1.101.2.2
--- src/sys/compat/netbsd32/syscalls.master:1.101.2.1 Sat Mar 7 05:22:01 2015
+++ src/sys/compat/netbsd32/syscalls.master Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.101.2.1 2015/03/07 05:22:01 snj Exp $
+ $NetBSD: syscalls.master,v 1.101.2.2 2015/11/04 17:46:21 riz Exp $
; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -317,7 +317,7 @@
152 UNIMPL
153 UNIMPL
154 UNIMPL
-155 UNIMPL netbsd32_nfssvc
+155 STD { int|netbsd32||nfssvc(int flag, netbsd32_voidp argp); }
156 COMPAT_43 { int|netbsd32||ogetdirentries(int fd, \
netbsd32_charp buf, u_int count, \
netbsd32_longp basep); }
Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.154 src/sys/nfs/nfs_syscalls.c:1.154.4.1
--- src/sys/nfs/nfs_syscalls.c:1.154 Wed Nov 27 22:10:47 2013
+++ src/sys/nfs/nfs_syscalls.c Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_syscalls.c,v 1.154 2013/11/27 22:10:47 christos Exp $ */
+/* $NetBSD: nfs_syscalls.c,v 1.154.4.1 2015/11/04 17:46:21 riz Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.154 2013/11/27 22:10:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.154.4.1 2015/11/04 17:46:21 riz Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -99,11 +99,61 @@ struct nfssvc_sock *nfs_udp6sock;
static struct nfssvc_sock *nfsrv_sockalloc(void);
static void nfsrv_sockfree(struct nfssvc_sock *);
static void nfsd_rt(int, struct nfsrv_descript *, int);
+static int nfssvc_nfsd(struct nfssvc_copy_ops *, struct nfsd_srvargs *, void *,
+ struct lwp *);
+
+static int nfssvc_addsock_in(struct nfsd_args *, const void *);
+static int nfssvc_setexports_in(struct mountd_exports_list *, const void *);
+static int nfssvc_nsd_in(struct nfsd_srvargs *, const void *);
+static int nfssvc_nsd_out(void *, const struct nfsd_srvargs *);
+static int nfssvc_exp_in(struct export_args *, const void *, size_t);
+
+static int
+nfssvc_addsock_in(struct nfsd_args *nfsdarg, const void *argp)
+{
+
+ return copyin(argp, nfsdarg, sizeof *nfsdarg);
+}
+
+static int
+nfssvc_setexports_in(struct mountd_exports_list *mel, const void *argp)
+{
+
+ return copyin(argp, mel, sizeof *mel);
+}
+
+static int
+nfssvc_nsd_in(struct nfsd_srvargs *nsd, const void *argp)
+{
+
+ return copyin(argp, nsd, sizeof *nsd);
+}
+
+static int
+nfssvc_nsd_out(void *argp, const struct nfsd_srvargs *nsd)
+{
+
+ return copyout(nsd, argp, sizeof *nsd);
+}
+
+static int
+nfssvc_exp_in(struct export_args *exp, const void *argp, size_t nexports)
+{
+
+ return copyin(argp, exp, sizeof(*exp) * nexports);
+}
/*
* NFS server system calls
*/
+static struct nfssvc_copy_ops native_ops = {
+ .addsock_in = nfssvc_addsock_in,
+ .setexports_in = nfssvc_setexports_in,
+ .nsd_in = nfssvc_nsd_in,
+ .nsd_out = nfssvc_nsd_out,
+ .exp_in = nfssvc_exp_in,
+};
/*
* Nfs server pseudo system call for the nfsd's
@@ -112,6 +162,7 @@ static void nfsd_rt(int, struct nfsrv_de
* - remains in the kernel as an nfsd
* - remains in the kernel as an nfsiod
*/
+
int
sys_nfssvc(struct lwp *l, const struct sys_nfssvc_args *uap, register_t *retval)
{
@@ -119,6 +170,15 @@ sys_nfssvc(struct lwp *l, const struct s
syscallarg(int) flag;
syscallarg(void *) argp;
} */
+ int flag = SCARG(uap, flag);
+ void *argp = SCARG(uap, argp);
+
+ return do_nfssvc(&native_ops, l, flag, argp, retval);
+}
+
+int
+do_nfssvc(struct nfssvc_copy_ops *ops, struct lwp *l, int flag, void *argp, register_t *retval)
+{
int error;
file_t *fp;
struct mbuf *nam;
@@ -139,14 +199,13 @@ sys_nfssvc(struct lwp *l, const struct s
}
mutex_exit(&nfsd_lock);
- if (SCARG(uap, flag) & NFSSVC_BIOD) {
+ if (flag & NFSSVC_BIOD) {
/* Dummy implementation of nfsios for 1.4 and earlier. */
error = kpause("nfsbiod", true, 0, NULL);
- } else if (SCARG(uap, flag) & NFSSVC_MNTD) {
+ } else if (flag & NFSSVC_MNTD) {
error = ENOSYS;
- } else if (SCARG(uap, flag) & NFSSVC_ADDSOCK) {
- error = copyin(SCARG(uap, argp), (void *)&nfsdarg,
- sizeof(nfsdarg));
+ } else if (flag & NFSSVC_ADDSOCK) {
+ error = ops->addsock_in(&nfsdarg, argp);
if (error)
return (error);
/* getsock() will use the descriptor for us */
@@ -171,18 +230,17 @@ sys_nfssvc(struct lwp *l, const struct s
}
error = nfssvc_addsock(fp, nam);
fd_putfile(nfsdarg.sock);
- } else if (SCARG(uap, flag) & NFSSVC_SETEXPORTSLIST) {
+ } else if (flag & NFSSVC_SETEXPORTSLIST) {
struct export_args *args;
struct mountd_exports_list mel;
- error = copyin(SCARG(uap, argp), &mel, sizeof(mel));
+ error = ops->setexports_in(&mel, argp);
if (error != 0)
return error;
args = (struct export_args *)malloc(mel.mel_nexports *
sizeof(struct export_args), M_TEMP, M_WAITOK);
- error = copyin(mel.mel_exports, args, mel.mel_nexports *
- sizeof(struct export_args));
+ error = ops->exp_in(args, mel.mel_exports, mel.mel_nexports);
if (error != 0) {
free(args, M_TEMP);
return error;
@@ -193,10 +251,10 @@ sys_nfssvc(struct lwp *l, const struct s
free(args, M_TEMP);
} else {
- error = copyin(SCARG(uap, argp), (void *)nsd, sizeof (*nsd));
+ error = ops->nsd_in(nsd, argp);
if (error)
return (error);
- if ((SCARG(uap, flag) & NFSSVC_AUTHIN) &&
+ if ((flag & NFSSVC_AUTHIN) &&
((nfsd = nsd->nsd_nfsd)) != NULL &&
(nfsd->nfsd_slp->ns_flags & SLP_VALID)) {
slp = nfsd->nfsd_slp;
@@ -280,10 +338,10 @@ sys_nfssvc(struct lwp *l, const struct s
}
}
}
- if ((SCARG(uap, flag) & NFSSVC_AUTHINFAIL) &&
+ if ((flag & NFSSVC_AUTHINFAIL) &&
(nfsd = nsd->nsd_nfsd))
nfsd->nfsd_flag |= NFSD_AUTHFAIL;
- error = nfssvc_nfsd(nsd, SCARG(uap, argp), l);
+ error = nfssvc_nfsd(ops, nsd, argp, l);
}
if (error == EINTR || error == ERESTART)
error = 0;
@@ -415,8 +473,9 @@ nfssvc_addsock(file_t *fp, struct mbuf *
* Called by nfssvc() for nfsds. Just loops around servicing rpc requests
* until it is killed by a signal.
*/
-int
-nfssvc_nfsd(struct nfsd_srvargs *nsd, void *argp, struct lwp *l)
+static int
+nfssvc_nfsd(struct nfssvc_copy_ops *ops, struct nfsd_srvargs *nsd,
+ void *argp, struct lwp *l)
{
struct timeval tv;
struct mbuf *m;
@@ -564,7 +623,7 @@ nfssvc_nfsd(struct nfsd_srvargs *nsd, vo
nsd->nsd_authstr, nfsd->nfsd_authlen) &&
!copyout(nfsd->nfsd_verfstr,
nsd->nsd_verfstr, nfsd->nfsd_verflen) &&
- !copyout(nsd, argp, sizeof (*nsd))) {
+ !ops->nsd_out(argp, nsd)) {
return (ENEEDAUTH);
}
cacherep = RC_DROPIT;
Index: src/sys/nfs/nfs_var.h
diff -u src/sys/nfs/nfs_var.h:1.92.2.1 src/sys/nfs/nfs_var.h:1.92.2.2
--- src/sys/nfs/nfs_var.h:1.92.2.1 Wed Nov 4 17:32:00 2015
+++ src/sys/nfs/nfs_var.h Wed Nov 4 17:46:21 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_var.h,v 1.92.2.1 2015/11/04 17:32:00 riz Exp $ */
+/* $NetBSD: nfs_var.h,v 1.92.2.2 2015/11/04 17:46:21 riz Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -323,7 +323,6 @@ struct sys_nfssvc_args;
int sys_getfh(struct lwp *, const struct sys_getfh_args *, register_t *);
int sys_nfssvc(struct lwp *, const struct sys_nfssvc_args *, register_t *);
int nfssvc_addsock(struct file *, struct mbuf *);
-int nfssvc_nfsd(struct nfsd_srvargs *, void *, struct lwp *);
void nfsrv_zapsock(struct nfssvc_sock *);
void nfsrv_slpderef(struct nfssvc_sock *);
void nfsrv_init(int);
@@ -338,6 +337,21 @@ int nfs_getnickauth(struct nfsmount *, k
int);
int nfs_savenickauth(struct nfsmount *, kauth_cred_t, int, NFSKERBKEY_T,
struct mbuf **, char **, struct mbuf *);
+/*
+ * Backend copyin/out functions for nfssvc(2), so that netbsd32 can
+ * easily access NFS. Each operation either must perform a copyin or
+ * copyout of the right data for the emulation. exp_in() takes a count
+ * of the number of export_args to copyin, and order arguments for
+ * func(dst, src).
+ */
+struct nfssvc_copy_ops {
+ int (*addsock_in)(struct nfsd_args *, const void *);
+ int (*setexports_in)(struct mountd_exports_list *, const void *);
+ int (*nsd_in)(struct nfsd_srvargs *, const void *);
+ int (*nsd_out)(void *, const struct nfsd_srvargs *);
+ int (*exp_in)(struct export_args *, const void *, size_t);
+};
+int do_nfssvc(struct nfssvc_copy_ops *, struct lwp *, int, void *, register_t *);
/* nfs_export.c */
extern struct nfs_public nfs_pub;
Added files:
Index: src/sys/compat/netbsd32/netbsd32_nfssvc.c
diff -u /dev/null src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.3.4.2
--- /dev/null Wed Nov 4 17:46:21 2015
+++ src/sys/compat/netbsd32/netbsd32_nfssvc.c Wed Nov 4 17:46:21 2015
@@ -0,0 +1,187 @@
+/* $NetBSD: netbsd32_nfssvc.c,v 1.3.4.2 2015/11/04 17:46:21 riz Exp $ */
+
+/*
+ * Copyright (c) 2015 Matthew R. Green
+ * 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.
+ * 3. The name of the author may not 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_nfssvc.c,v 1.3.4.2 2015/11/04 17:46:21 riz Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_nfs.h"
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/vnode.h>
+#include <sys/filedesc.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscall.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+#include <compat/netbsd32/netbsd32_conv.h>
+
+#include <nfs/rpcv2.h>
+#include <nfs/nfsproto.h>
+#include <nfs/nfs.h>
+#include <nfs/nfs_var.h>
+
+static int nfssvc32_addsock_in(struct nfsd_args *, const void *);
+static int nfssvc32_setexports_in(struct mountd_exports_list *, const void *);
+static int nfssvc32_nsd_in(struct nfsd_srvargs *, const void *);
+static int nfssvc32_nsd_out(void *, const struct nfsd_srvargs *);
+static int nfssvc32_exp_in(struct export_args *, const void *, size_t);
+
+static int
+nfssvc32_addsock_in(struct nfsd_args *nfsdarg, const void *argp)
+{
+ struct netbsd32_nfsd_args args32;
+ int error;
+
+ error = copyin(argp, &args32, sizeof args32);
+ if (!error) {
+ nfsdarg->sock = args32.sock;
+ nfsdarg->name = NETBSD32PTR64(args32.name);
+ nfsdarg->namelen = args32.namelen;
+ }
+
+ return error;
+}
+
+static int
+nfssvc32_setexports_in(struct mountd_exports_list *mel, const void *argp)
+{
+ struct netbsd32_mountd_exports_list args32;
+ int error;
+
+ error = copyin(argp, &args32, sizeof args32);
+ if (!error) {
+ mel->mel_path = NETBSD32PTR64(args32.mel_path);
+ mel->mel_nexports = args32.mel_nexports;
+ mel->mel_exports = NETBSD32PTR64(args32.mel_exports);
+ }
+
+ return error;
+}
+
+static int
+nfssvc32_nsd_in(struct nfsd_srvargs *nsd, const void *argp)
+{
+ struct netbsd32_nfsd_srvargs args32;
+ int error;
+
+ error = copyin(argp, &args32, sizeof args32);
+ if (!error) {
+ nsd->nsd_nfsd = NETBSD32PTR64(args32.nsd_nfsd);
+ nsd->nsd_uid = args32.nsd_uid;
+ nsd->nsd_haddr = args32.nsd_haddr;
+ nsd->nsd_cr = args32.nsd_cr;
+ nsd->nsd_authlen = args32.nsd_authlen;
+ nsd->nsd_authstr = NETBSD32PTR64(args32.nsd_authstr);
+ nsd->nsd_verflen = args32.nsd_verflen;
+ nsd->nsd_uid = args32.nsd_uid;
+ netbsd32_to_timeval(&args32.nsd_timestamp, &nsd->nsd_timestamp);
+ nsd->nsd_ttl = args32.nsd_ttl;
+ nsd->nsd_key[0] = args32.nsd_key[0];
+ nsd->nsd_key[1] = args32.nsd_key[1];
+ }
+
+ return error;
+}
+
+static int
+nfssvc32_nsd_out(void *argp, const struct nfsd_srvargs *nsd)
+{
+ struct netbsd32_nfsd_srvargs args32;
+
+ NETBSD32PTR32(args32.nsd_nfsd, nsd->nsd_nfsd);
+ args32.nsd_uid = nsd->nsd_uid;
+ args32.nsd_haddr = nsd->nsd_haddr;
+ args32.nsd_cr = nsd->nsd_cr;
+ args32.nsd_authlen = nsd->nsd_authlen;
+ NETBSD32PTR32(args32.nsd_authstr, nsd->nsd_authstr);
+ args32.nsd_verflen = nsd->nsd_verflen;
+ args32.nsd_uid = nsd->nsd_uid;
+ netbsd32_from_timeval(&nsd->nsd_timestamp, &args32.nsd_timestamp);
+ args32.nsd_ttl = nsd->nsd_ttl;
+ args32.nsd_key[0] = nsd->nsd_key[0];
+ args32.nsd_key[1] = nsd->nsd_key[1];
+
+ return copyout(nsd, argp, sizeof *nsd);
+}
+
+static int
+nfssvc32_exp_in(struct export_args *exp, const void *argp, size_t nexports)
+{
+ struct netbsd32_export_args exp32;
+ struct netbsd32_export_args const *argp32 = argp;
+ int error = 0;
+
+ for (size_t i = 0; i < nexports; i++) {
+ error = copyin(argp32, &exp32, sizeof exp32);
+ if (error)
+ break;
+ exp->ex_flags = exp32.ex_flags;
+ exp->ex_root = exp32.ex_root;
+ exp->ex_anon = exp32.ex_anon;
+ exp->ex_addr = NETBSD32PTR64(exp32.ex_addr);
+ exp->ex_addrlen = exp32.ex_addrlen;
+ exp->ex_mask = NETBSD32PTR64(exp32.ex_mask);
+ exp->ex_masklen = exp32.ex_masklen;
+ exp->ex_indexfile = NETBSD32PTR64(exp32.ex_indexfile);
+ exp++;
+ argp32++;
+ }
+
+ return error;
+}
+
+/*
+ * NFS server system calls
+ */
+
+static struct nfssvc_copy_ops netbsd32_ops = {
+ .addsock_in = nfssvc32_addsock_in,
+ .setexports_in = nfssvc32_setexports_in,
+ .nsd_in = nfssvc32_nsd_in,
+ .nsd_out = nfssvc32_nsd_out,
+ .exp_in = nfssvc32_exp_in,
+};
+
+int
+netbsd32_nfssvc(struct lwp *l, const struct netbsd32_nfssvc_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(int) flag;
+ syscallarg(netbsd32_voidp *) argp;
+ } */
+ int flag = SCARG(uap, flag);
+ void *argp = SCARG_P32(uap, argp);
+
+ return do_nfssvc(&netbsd32_ops, l, flag, argp, retval);
+}