Change compat mount code to pass do_sys_mount() kernel resident buffers.

Possibly the standard nfs code needs teaching how to set the length and
address family in order to support non-netbsd sockaddr.
There are now no active stackgap() calls in the compat tree.
This commit is contained in:
dsl 2007-07-12 19:41:57 +00:00
parent 34d9cdbea2
commit 758f9f5cde
6 changed files with 117 additions and 210 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_file.c,v 1.25 2007/04/22 08:29:56 dsl Exp $ */
/* $NetBSD: freebsd_file.c,v 1.26 2007/07/12 19:41:57 dsl Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.25 2007/04/22 08:29:56 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.26 2007/07/12 19:41:57 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@ -105,23 +105,18 @@ freebsd_sys_mount(l, v, retval)
syscallarg(int) flags;
syscallarg(void *) data;
} */ *uap = v;
struct proc *p = l->l_proc;
int error;
const char *type;
char *s;
void *sg = stackgap_init(p, 0);
struct sys_mount_args bma;
struct vfsops *vfsops;
register_t dummy;
if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
return ENODEV;
s = stackgap_alloc(p, &sg, MFSNAMELEN + 1);
if ((error = copyout(type, s, strlen(type) + 1)) != 0)
return error;
SCARG(&bma, type) = s;
SCARG(&bma, path) = SCARG(uap, path);
SCARG(&bma, flags) = SCARG(uap, flags);
SCARG(&bma, data) = SCARG(uap, data);
return sys_mount(l, &bma, retval);
vfsops = vfs_getopsbyname(type);
if (vfsops == NULL)
return ENODEV;
return do_sys_mount(l, vfsops, NULL, SCARG(uap, path),
SCARG(uap, flags), SCARG(uap, data), UIO_USERSPACE, 0, &dummy);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_usema.c,v 1.19 2007/05/13 15:57:39 dsl Exp $ */
/* $NetBSD: irix_usema.c,v 1.20 2007/07/12 19:41:57 dsl Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_usema.c,v 1.19 2007/05/13 15:57:39 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_usema.c,v 1.20 2007/07/12 19:41:57 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -103,7 +103,7 @@ static struct irix_waiting_proc_rec *iur_proc_getfirst
* at driver attach time, in irix_usemaattach().
*/
struct vfsops irix_usema_dummy_vfsops = {
"usema_dummy",
"usema_dummy", 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, irix_usema_dummy_vfs_init, NULL, NULL, NULL, NULL, NULL,
NULL,

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_mount.c,v 1.34 2007/04/22 08:29:58 dsl Exp $ */
/* $NetBSD: osf1_mount.c,v 1.35 2007/07/12 19:41:58 dsl Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.34 2007/04/22 08:29:58 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.35 2007/07/12 19:41:58 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@ -105,10 +105,8 @@ __KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.34 2007/04/22 08:29:58 dsl Exp $");
#define OSF1_UNMOUNT_FLAGS (OSF1_MNT_FORCE|OSF1_MNT_NOFORCE)
static int osf1_mount_mfs __P((struct proc *,
struct osf1_sys_mount_args *, struct sys_mount_args *));
static int osf1_mount_nfs __P((struct proc *,
struct osf1_sys_mount_args *, struct sys_mount_args *));
static int osf1_mount_mfs(struct lwp *, struct osf1_sys_mount_args *);
static int osf1_mount_nfs(struct lwp *, struct osf1_sys_mount_args *);
int
osf1_sys_fstatfs(l, v, retval)
@ -195,31 +193,23 @@ osf1_sys_mount(l, v, retval)
register_t *retval;
{
struct osf1_sys_mount_args *uap = v;
struct sys_mount_args a;
int error;
SCARG(&a, path) = SCARG(uap, path);
if (SCARG(uap, flags) & ~OSF1_MOUNT_FLAGS)
return (EINVAL);
SCARG(&a, flags) = SCARG(uap, flags); /* XXX - xlate */
/* XXX - xlate flags */
switch (SCARG(uap, type)) {
case OSF1_MOUNT_NFS:
if ((error = osf1_mount_nfs(l->l_proc, uap, &a)))
return error;
return osf1_mount_nfs(l, uap);
break;
case OSF1_MOUNT_MFS:
if ((error = osf1_mount_mfs(l->l_proc, uap, &a)))
return error;
break;
return osf1_mount_mfs(l, uap);
default:
return (EINVAL);
}
return sys_mount(l, &a, retval);
}
int
@ -271,18 +261,14 @@ osf1_sys_unmount(l, v, retval)
}
static int
osf1_mount_mfs(p, osf_argp, bsd_argp)
struct proc *p;
struct osf1_sys_mount_args *osf_argp;
struct sys_mount_args *bsd_argp;
osf1_mount_mfs(struct lwp *l, struct osf1_sys_mount_args *uap)
{
struct osf1_mfs_args osf_ma;
struct mfs_args bsd_ma;
void *sg = stackgap_init(p, 0);
int error, len;
static const char mfs_name[] = MOUNT_MFS;
int error;
register_t dummy;
if ((error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma)))
if ((error = copyin(SCARG(uap, data), &osf_ma, sizeof osf_ma)))
return error;
memset(&bsd_ma, 0, sizeof bsd_ma);
@ -291,32 +277,20 @@ osf1_mount_mfs(p, osf_argp, bsd_argp)
bsd_ma.base = osf_ma.base;
bsd_ma.size = osf_ma.size;
SCARG(bsd_argp, data) = stackgap_alloc(p, &sg, sizeof bsd_ma);
if ((error = copyout(&bsd_ma, SCARG(bsd_argp, data), sizeof bsd_ma)))
return error;
len = strlen(mfs_name) + 1;
SCARG(bsd_argp, type) = stackgap_alloc(p, &sg, len);
if ((error = copyout(mfs_name, __UNCONST(SCARG(bsd_argp, type)), len)))
return error;
return 0;
return do_sys_mount(l, vfs_getopsbyname("mfs"), NULL, SCARG(uap, path),
SCARG(uap, flags), &bsd_ma, UIO_SYSSPACE, sizeof bsd_ma, &dummy);
}
static int
osf1_mount_nfs(p, osf_argp, bsd_argp)
struct proc *p;
struct osf1_sys_mount_args *osf_argp;
struct sys_mount_args *bsd_argp;
osf1_mount_nfs(struct lwp *l, struct osf1_sys_mount_args *uap)
{
struct osf1_nfs_args osf_na;
struct nfs_args bsd_na;
void *sg = stackgap_init(p, 0);
int error, len;
static const char nfs_name[] = MOUNT_NFS;
int error;
unsigned long leftovers;
register_t dummy;
if ((error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na)))
if ((error = copyin(SCARG(uap, data), &osf_na, sizeof osf_na)))
return error;
memset(&bsd_na, 0, sizeof bsd_na);
@ -354,14 +328,8 @@ osf1_mount_nfs(p, osf_argp, bsd_argp)
if (bsd_na.flags & NFSMNT_RETRANS)
bsd_na.retrans = osf_na.retrans;
SCARG(bsd_argp, data) = stackgap_alloc(p, &sg, sizeof bsd_na);
if ((error = copyout(&bsd_na, SCARG(bsd_argp, data), sizeof bsd_na)))
return error;
len = strlen(nfs_name) + 1;
SCARG(bsd_argp, type) = stackgap_alloc(p, &sg, len);
if ((error = copyout(MOUNT_NFS, __UNCONST(SCARG(bsd_argp, type)), len)))
return error;
return do_sys_mount(l, vfs_getopsbyname("nfs"), NULL, SCARG(uap, path),
SCARG(uap, flags), &bsd_na, UIO_SYSSPACE, sizeof bsd_na, &dummy);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos_misc.c,v 1.149 2007/05/12 20:27:56 dsl Exp $ */
/* $NetBSD: sunos_misc.c,v 1.150 2007/07/12 19:41:58 dsl Exp $ */
/*
* Copyright (c) 1992, 1993
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.149 2007/05/12 20:27:56 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.150 2007/07/12 19:41:58 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_nfsserver.h"
@ -291,10 +291,9 @@ sunos_sys_mount(l, v, retval)
register_t *retval;
{
struct sunos_sys_mount_args *uap = v;
struct proc *p = l->l_proc;
int oflags = SCARG(uap, flags), nflags, error;
char fsname[MFSNAMELEN];
void *sg = stackgap_init(p, 0);
register_t dummy;
if (oflags & (SUNM_NOSUB | SUNM_SYS5))
return (EINVAL);
@ -307,40 +306,26 @@ sunos_sys_mount(l, v, retval)
nflags |= MNT_NOSUID;
if (oflags & SUNM_REMOUNT)
nflags |= MNT_UPDATE;
SCARG(uap, flags) = nflags;
error = copyinstr((void *)SCARG(uap, type), fsname,
sizeof fsname, (size_t *)0);
error = copyinstr(SCARG(uap, type), fsname, sizeof fsname, NULL);
if (error)
return (error);
if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
SCARG(uap, type) = stackgap_alloc(p, &sg, sizeof("ffs"));
error = copyout("ffs", SCARG(uap, type), sizeof("ffs"));
if (error)
return (error);
} else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
if (strcmp(fsname, "nfs") == 0) {
struct sunos_nfs_args sna;
struct sockaddr_in sain;
struct nfs_args na;
struct sockaddr sa;
int n;
error = copyin(SCARG(uap, data), &sna, sizeof sna);
if (error)
return (error);
error = copyin(sna.addr, &sain, sizeof sain);
if (error)
return (error);
memcpy(&sa, &sain, sizeof sa);
sa.sa_len = sizeof(sain);
SCARG(uap, data) = stackgap_alloc(p, &sg, sizeof(na));
/* sa.sa_len = sizeof(sain); */
na.version = NFS_ARGSVERSION;
na.addr = stackgap_alloc(p, &sg, sizeof(struct sockaddr));
na.addr = (void *)sna.addr;
na.addrlen = sizeof(struct sockaddr);
na.sotype = SOCK_DGRAM;
na.proto = IPPROTO_UDP;
na.fh = (void *)sna.fh;
na.fh = sna.fh;
na.fhsize = NFSX_V2FH;
na.flags = 0;
n = sizeof(sunnfs_flgtab) / sizeof(sunnfs_flgtab[0]);
@ -355,16 +340,19 @@ sunos_sys_mount(l, v, retval)
}
na.timeo = sna.timeo;
na.retrans = sna.retrans;
na.hostname = (char *)(u_long)sna.hostname;
na.hostname = /* (char *)(u_long) */ sna.hostname;
error = copyout(&sa, na.addr, sizeof sa);
if (error)
return (error);
error = copyout(&na, SCARG(uap, data), sizeof na);
if (error)
return (error);
return do_sys_mount(l, vfs_getopsbyname("nfs"), NULL,
SCARG(uap, dir), nflags, &na,
UIO_SYSSPACE, sizeof na, &dummy);
}
return (sys_mount(l, (struct sys_mount_args *)uap, retval));
if (strcmp(fsname, "4.2") == 0)
strcpy(fsname, "ffs");
return do_sys_mount(l, vfs_getopsbyname(fsname), NULL,
SCARG(uap, dir), nflags, SCARG(uap, data),
UIO_USERSPACE, 0, &dummy);
}
#if defined(NFS)

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos32_misc.c,v 1.49 2007/05/12 20:27:56 dsl Exp $ */
/* $NetBSD: sunos32_misc.c,v 1.50 2007/07/12 19:41:58 dsl Exp $ */
/* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
/*
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.49 2007/05/12 20:27:56 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.50 2007/07/12 19:41:58 dsl Exp $");
#define COMPAT_SUNOS 1
@ -499,11 +499,9 @@ sunos32_sys_mount(l, v, retval)
syscallarg(int) flags;
syscallarg(netbsd32_caddr_t) data;
} */ *uap = v;
struct proc *p = l->l_proc;
struct sys_mount_args ua;
int oflags = SCARG(uap, flags), nflags, error;
char fsname[MFSNAMELEN];
void *sg = stackgap_init(p, 0);
register_t dummy;
if (oflags & (SUNM_NOSUB | SUNM_SYS5))
return (EINVAL);
@ -516,40 +514,26 @@ sunos32_sys_mount(l, v, retval)
nflags |= MNT_NOSUID;
if (oflags & SUNM_REMOUNT)
nflags |= MNT_UPDATE;
SCARG(uap, flags) = nflags;
error = copyinstr(SCARG_P32(uap, type), fsname,
sizeof fsname, (size_t *)0);
error = copyinstr(SCARG_P32(uap, type), fsname, sizeof fsname, NULL);
if (error)
return (error);
if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
NETBSD32PTR32(SCARG(uap, type), stackgap_alloc(p, &sg, sizeof("ffs")));
error = copyout("ffs", SCARG_P32(uap, type), sizeof("ffs"));
if (error)
return (error);
} else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
struct sunos_nfs_args sna;
struct sockaddr_in sain;
struct nfs_args na; /* XXX */
struct sockaddr sa;
int n;
error = copyin(SCARG_P32(uap, data), &sna, sizeof sna);
if (error)
return (error);
error = copyin(sna.addr, &sain, sizeof sain);
if (error)
return (error);
memcpy(&sa, &sain, sizeof sa);
sa.sa_len = sizeof(sain);
NETBSD32PTR32(SCARG(uap, data), stackgap_alloc(p, &sg, sizeof(na)));
/* sa.sa_len = sizeof(sain); */
na.version = NFS_ARGSVERSION;
na.addr = stackgap_alloc(p, &sg, sizeof(struct sockaddr));
na.addr = (void *)sna.addr;
na.addrlen = sizeof(struct sockaddr);
na.sotype = SOCK_DGRAM;
na.proto = IPPROTO_UDP;
na.fh = (void *)sna.fh;
na.fh = sna.fh;
na.fhsize = NFSX_V2FH;
na.flags = 0;
n = sizeof(sunnfs_flgtab) / sizeof(sunnfs_flgtab[0]);
@ -566,18 +550,17 @@ sunos32_sys_mount(l, v, retval)
na.retrans = sna.retrans;
na.hostname = (char *)(u_long)sna.hostname;
error = copyout(&sa, na.addr, sizeof sa);
if (error)
return (error);
error = copyout(&na, SCARG_P32(uap, data), sizeof na);
if (error)
return (error);
return do_sys_mount(l, vfs_getopsbyname("nfs"), NULL,
SCARG_P32(uap, path), nflags, &na, UIO_SYSSPACE, sizeof na,
&dummy);
}
SUNOS32TOP_UAP(type, const char);
SUNOS32TOP_UAP(path, const char);
SUNOS32TO64_UAP(flags);
SUNOS32TOP_UAP(data, void);
return (sys_mount(l, &ua, retval));
if (strcmp(fsname, "4.2") == 0)
strcpy(fsname, "ffs");
return do_sys_mount(l, vfs_getopsbyname(fsname), NULL,
SCARG_P32(uap, path), nflags, SCARG_P32(uap, data), UIO_USERSPACE,
0, &dummy);
}
#if defined(NFS)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ultrix_fs.c,v 1.37 2007/03/05 13:56:24 he Exp $ */
/* $NetBSD: ultrix_fs.c,v 1.38 2007/07/12 19:41:58 dsl Exp $ */
/*
* Copyright (c) 1995, 1997 Jonathan Stone
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.37 2007/03/05 13:56:24 he Exp $");
__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.38 2007/07/12 19:41:58 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -346,92 +346,38 @@ int
ultrix_sys_mount(struct lwp *l, void *v, register_t *retval)
{
struct ultrix_sys_mount_args *uap = v;
struct proc *p = l->l_proc;
int error;
int otype = SCARG(uap, type);
char fsname[MFSNAMELEN];
const char *fstype;
struct sys_mount_args nuap;
char *native_fstype;
int nflags;
char *usp = stackgap_init(p, 0);
memset(&nuap, 0, sizeof(nuap));
SCARG(&nuap, flags) = 0;
nflags = 0;
/*
* Translate Ultrix integer mount codes for UFS and NFS to
* NetBSD fstype strings. Other Ultrix filesystem types
* (msdos, DEC ods-2) are not supported.
* Copy resulting string out to userspace (on stack)
* so we can pass it to the native mount syscall.
*/
if (otype == ULTRIX_FSTYPE_ULTRIX)
fstype = "ufs";
else if (otype == ULTRIX_FSTYPE_NFS)
fstype = "nfs";
else
return (EINVAL);
/* Translate the Ultrix mount-readonly option parameter */
if (SCARG(uap, rdonly))
SCARG(&nuap, flags) |= MNT_RDONLY;
nflags |= MNT_RDONLY;
/* Copy string-ified version of mount type back out to user space */
native_fstype = (char *)usp;
SCARG(&nuap, type) = native_fstype;
if ((error = copyout(fstype, native_fstype,
strlen(fstype)+1)) != 0) {
return (error);
}
usp += strlen(fstype)+1;
#ifdef later
parse ultrix mount option string and set NetBSD flags
#endif
SCARG(&nuap, path) = SCARG(uap, dir);
path) = SCARG(uap, dir);
/*
* Translate fstype-dependent mount options from
* Ultrix format to native.
*/
if (otype == ULTRIX_FSTYPE_ULTRIX) {
/* attempt to mount a native, rather than 4.2bsd, ffs */
struct ufs_args ua;
memset(&ua, 0, sizeof(ua));
ua.fspec = SCARG(uap, special);
SCARG(&nuap, data) = usp;
if ((error = copyout(&ua, SCARG(&nuap, data),
sizeof ua)) !=0) {
return(error);
}
/*
* Ultrix mount has no MNT_UPDATE flag.
* Attempt to see if this is the root we're mounting,
* and if so, set MNT_UPDATE so we can mount / read-write.
*/
fsname[0] = 0;
if ((error = copyinstr(SCARG(&nuap, path), fsname,
sizeof fsname, NULL)) != 0)
return(error);
if (strcmp(fsname, "/") == 0) {
SCARG(&nuap, flags) |= MNT_UPDATE;
printf("COMPAT_ULTRIX: mount with MNT_UPDATE on %s\n",
fsname);
}
} else if (otype == ULTRIX_FSTYPE_NFS) {
if (otype == ULTRIX_FSTYPE_NFS) {
struct ultrix_nfs_args una;
struct nfs_args na;
struct osockaddr_in osa;
struct sockaddr_in *sap = (struct sockaddr_in *)& osa;
memset(&osa, 0, sizeof(osa));
memset(&una, 0, sizeof(una));
if ((error = copyin(SCARG(uap, data), &una, sizeof una)) !=0) {
return (error);
}
#if 0
/*
* This is the only syscall boundary the
* address of the server passes, so do backwards
@ -443,14 +389,11 @@ ultrix_sys_mount(struct lwp *l, void *v, register_t *retval)
}
sap->sin_family = (u_char)osa.sin_family;
sap->sin_len = sizeof(*sap);
/* allocate space above caller's stack for nfs_args */
SCARG(&nuap, data) = usp;
usp += sizeof (na);
/* allocate space above caller's stack for server sockaddr */
/* XXXX teach nfs how to do the above */
#endif
na.version = NFS_ARGSVERSION;
na.addr = (struct sockaddr *)usp;
usp += sizeof(*sap);
na.addrlen = sap->sin_len;
na.addr = una.addr;
na.addrlen = sizeof (struct sockaddr_in);
na.sotype = SOCK_DGRAM;
na.proto = IPPROTO_UDP;
na.fh = una.fh;
@ -461,10 +404,40 @@ ultrix_sys_mount(struct lwp *l, void *v, register_t *retval)
na.timeo = una.timeo;
na.retrans = una.retrans;
na.hostname = una.hostname;
if ((error = copyout(sap, na.addr, sizeof (*sap) )) != 0)
return (error);
if ((error = copyout(&na, SCARG(&nuap, data), sizeof na)) != 0)
return (error);
return do_sys_mount(l, vfs_getopsbyname("ngs"), NULL,
SCARG(uap, special), nflags, &na, UIO_SYSSPACE,
sizeof na, &dummy);
}
return (sys_mount(l, &nuap, retval));
/*
* Translate fstype-dependent mount options from
* Ultrix format to native.
*/
if (otype == ULTRIX_FSTYPE_ULTRIX) {
/* attempt to mount a native, rather than 4.2bsd, ffs */
struct ufs_args ua;
memset(&ua, 0, sizeof(ua));
ua.fspec = SCARG(uap, special);
/*
* Ultrix mount has no MNT_UPDATE flag.
* Attempt to see if this is the root we're mounting,
* and if so, set MNT_UPDATE so we can mount / read-write.
*/
fsname[0] = 0;
if ((error = copyinstr(SCARG(&nuap, path), fsname,
sizeof fsname, NULL)) != 0)
return(error);
if (strcmp(fsname, "/") == 0) {
nflags |= MNT_UPDATE;
printf("COMPAT_ULTRIX: mount with MNT_UPDATE on %s\n",
fsname);
}
return do_sys_mount(l, vfs_getopsbyname("ffs"), NULL,
SCARG(uap, root), nflags, &ua, UIO_SYSSPACE, sizeof ua,
&dummy);
}
return (EINVAL);
}