Module Name: src
Committed By: matt
Date: Sat Jan 22 22:26:10 UTC 2011
Modified Files:
src/sys/compat/netbsd32: netbsd32.h netbsd32_fs.c
src/sys/nfs: nfsmount.h
Log Message:
Add the ability to mount NFS filesystems in COMPAT_NETBSD32
If in the kernel and NFS_ARGS_ONLY, just export struct nfs_args and its flags.
To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.59 -r1.60 src/sys/compat/netbsd32/netbsd32_fs.c
cvs rdiff -u -r1.50 -r1.51 src/sys/nfs/nfsmount.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/netbsd32.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.84 src/sys/compat/netbsd32/netbsd32.h:1.85
--- src/sys/compat/netbsd32/netbsd32.h:1.84 Mon Dec 14 00:47:11 2009
+++ src/sys/compat/netbsd32/netbsd32.h Sat Jan 22 22:26:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32.h,v 1.84 2009/12/14 00:47:11 matt Exp $ */
+/* $NetBSD: netbsd32.h,v 1.85 2011/01/22 22:26:10 matt Exp $ */
/*
* Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -844,6 +844,28 @@
netbsd32_u_long size;
};
+/* from <nfs/nfsmount,h> */
+struct netbsd32_nfs_args {
+ int32_t version; /* args structure version number */
+ netbsd32_sockaddrp_t addr; /* file server address */
+ int32_t addrlen; /* length of address */
+ int32_t sotype; /* Socket type */
+ int32_t proto; /* and Protocol */
+ netbsd32_u_charp fh; /* File handle to be mounted */
+ int32_t fhsize; /* Size, in bytes, of fh */
+ int32_t flags; /* flags */
+ int32_t wsize; /* write size in bytes */
+ int32_t rsize; /* read size in bytes */
+ int32_t readdirsize; /* readdir size in bytes */
+ int32_t timeo; /* initial timeout in .1 secs */
+ int32_t retrans; /* times to retry send */
+ int32_t maxgrouplist; /* Max. size of group list */
+ int32_t readahead; /* # of blocks to readahead */
+ int32_t leaseterm; /* Ignored; Term (sec) of lease */
+ int32_t deadthresh; /* Retrans threshold */
+ netbsd32_charp hostname; /* server's name */
+};
+
#if 0
int netbsd32_kevent(struct lwp *, void *, register_t *);
#endif
Index: src/sys/compat/netbsd32/netbsd32_fs.c
diff -u src/sys/compat/netbsd32/netbsd32_fs.c:1.59 src/sys/compat/netbsd32/netbsd32_fs.c:1.60
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.59 Fri Apr 23 15:19:20 2010
+++ src/sys/compat/netbsd32/netbsd32_fs.c Sat Jan 22 22:26:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_fs.c,v 1.59 2010/04/23 15:19:20 rmind Exp $ */
+/* $NetBSD: netbsd32_fs.c,v 1.60 2011/01/22 22:26:10 matt Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.59 2010/04/23 15:19:20 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.60 2011/01/22 22:26:10 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -52,6 +52,9 @@
#include <fs/cd9660/cd9660_mount.h>
#include <ufs/ufs/ufsmount.h>
+#define NFS_ARGS_ONLY
+#include <nfs/nfsmount.h>
+
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
#include <compat/netbsd32/netbsd32_conv.h>
@@ -770,11 +773,13 @@
struct netbsd32_ufs_args ufs_args;
struct netbsd32_mfs_args mfs_args;
struct netbsd32_iso_args iso_args;
+ struct netbsd32_nfs_args nfs_args;
} fs_args32;
union {
struct ufs_args ufs_args;
struct mfs_args mfs_args;
struct iso_args iso_args;
+ struct nfs_args nfs_args;
} fs_args;
const char *type = SCARG_P32(uap, type);
const char *path = SCARG_P32(uap, path);
@@ -838,6 +843,33 @@
data_seg = UIO_SYSSPACE;
data = &fs_args.iso_args;
data_len = sizeof(fs_args.iso_args);
+ } else if (strcmp(mtype, MOUNT_NFS) == 0) {
+ if (data_len != sizeof(fs_args32.nfs_args))
+ return EINVAL;
+ if ((flags & MNT_GETARGS) == 0) {
+ error = copyin(data, &fs_args32.nfs_args,
+ sizeof(fs_args32.nfs_args));
+ if (error)
+ return error;
+ fs_args.nfs_args.version = fs_args32.nfs_args.version;
+ fs_args.nfs_args.addr =
+ NETBSD32PTR64(fs_args32.nfs_args.addr);
+ memcpy(&fs_args.nfs_args.addrlen,
+ &fs_args32.nfs_args.addrlen,
+ offsetof(struct nfs_args, fh)
+ - offsetof(struct nfs_args, addrlen));
+ fs_args.nfs_args.fh =
+ NETBSD32PTR64(fs_args32.nfs_args.fh);
+ memcpy(&fs_args.nfs_args.fhsize,
+ &fs_args32.nfs_args.fhsize,
+ offsetof(struct nfs_args, hostname)
+ - offsetof(struct nfs_args, fhsize));
+ fs_args.nfs_args.hostname =
+ NETBSD32PTR64(fs_args32.nfs_args.hostname);
+ }
+ data_seg = UIO_SYSSPACE;
+ data = &fs_args.nfs_args;
+ data_len = sizeof(fs_args.nfs_args);
} else {
data_seg = UIO_USERSPACE;
}
@@ -876,6 +908,30 @@
fs_args32.iso_args.flags = fs_args.iso_args.flags;
error = copyout(&fs_args32.iso_args, data,
sizeof(fs_args32.iso_args));
+ } else if (strcmp(mtype, MOUNT_NFS) == 0) {
+ if (data_len != sizeof(fs_args.nfs_args))
+ return EINVAL;
+ error = copyin(data, &fs_args32.nfs_args,
+ sizeof(fs_args32.nfs_args));
+ if (error)
+ return error;
+ fs_args.nfs_args.version = fs_args32.nfs_args.version;
+ NETBSD32PTR32(fs_args32.nfs_args.addr,
+ fs_args.nfs_args.addr);
+ memcpy(&fs_args32.nfs_args.addrlen,
+ &fs_args.nfs_args.addrlen,
+ offsetof(struct nfs_args, fh)
+ - offsetof(struct nfs_args, addrlen));
+ NETBSD32PTR32(fs_args32.nfs_args.fh,
+ fs_args.nfs_args.fh);
+ memcpy(&fs_args32.nfs_args.fhsize,
+ &fs_args.nfs_args.fhsize,
+ offsetof(struct nfs_args, hostname)
+ - offsetof(struct nfs_args, fhsize));
+ NETBSD32PTR32(fs_args32.nfs_args.hostname,
+ fs_args.nfs_args.hostname);
+ error = copyout(&fs_args32.nfs_args, data,
+ sizeof(fs_args32.nfs_args));
}
}
return error;
Index: src/sys/nfs/nfsmount.h
diff -u src/sys/nfs/nfsmount.h:1.50 src/sys/nfs/nfsmount.h:1.51
--- src/sys/nfs/nfsmount.h:1.50 Sat Sep 25 01:42:39 2010
+++ src/sys/nfs/nfsmount.h Sat Jan 22 22:26:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nfsmount.h,v 1.50 2010/09/25 01:42:39 matt Exp $ */
+/* $NetBSD: nfsmount.h,v 1.51 2011/01/22 22:26:10 matt Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -37,7 +37,8 @@
#ifndef _NFS_NFSMOUNT_H_
#define _NFS_NFSMOUNT_H_
-#ifdef _KERNEL
+
+#if defined(_KERNEL) && !defined(NFS_ARGS_ONLY)
#include <sys/condvar.h>
#include <sys/rwlock.h>
#include <sys/mutex.h>
@@ -121,7 +122,7 @@
#define NFSMNT_STALEWRITEVERF 0x00008000 /* Write verifier is changing */
#define NFSMNT_WCCKLUDGE 0x00010000 /* see nfs_check_wccdata() */
-#ifdef _KERNEL
+#if defined(_KERNEL) && !defined(NFS_ARGS_ONLY)
/*
* Mount structure.
* One allocated on every NFS mount.