2008-12-17 23:51:31 +03:00
|
|
|
/* $NetBSD: ultrix_fs.c,v 1.50 2008/12/17 20:51:34 cegger Exp $ */
|
1995-12-26 07:44:37 +03:00
|
|
|
|
|
|
|
/*
|
1997-05-25 14:24:05 +04:00
|
|
|
* Copyright (c) 1995, 1997 Jonathan Stone
|
|
|
|
* All rights reserved.
|
1995-12-26 07:44:37 +03:00
|
|
|
*
|
|
|
|
* 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.
|
1996-10-19 16:40:31 +04:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1997-01-15 04:41:35 +03:00
|
|
|
* This product includes software developed by Jonathan Stone for
|
1996-10-19 16:40:31 +04:00
|
|
|
* the NetBSD Project.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
1995-12-26 07:44:37 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-12-17 23:51:31 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.50 2008/12/17 20:51:34 cegger Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1995-12-26 07:44:37 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
1995-12-26 13:06:14 +03:00
|
|
|
#include <sys/exec.h>
|
|
|
|
#include <sys/namei.h>
|
1995-12-26 07:44:37 +03:00
|
|
|
#include <sys/mount.h>
|
1997-04-07 03:26:52 +04:00
|
|
|
#include <sys/proc.h>
|
2005-08-31 20:01:56 +04:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/vnode_if.h>
|
1995-12-26 13:06:14 +03:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
1995-12-26 07:44:37 +03:00
|
|
|
|
1996-02-19 18:41:38 +03:00
|
|
|
#include <nfs/rpcv2.h>
|
|
|
|
#include <nfs/nfsproto.h>
|
|
|
|
#include <nfs/nfs.h>
|
1998-03-06 01:51:35 +03:00
|
|
|
#include <nfs/nfsmount.h>
|
|
|
|
|
|
|
|
#include <ufs/ufs/quota.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
1995-12-26 13:06:14 +03:00
|
|
|
|
|
|
|
#include <sys/syscallargs.h>
|
1995-12-26 07:44:37 +03:00
|
|
|
#include <compat/ultrix/ultrix_syscallargs.h>
|
1997-04-07 03:26:52 +04:00
|
|
|
#include <compat/common/compat_util.h>
|
2007-07-18 00:54:45 +04:00
|
|
|
#include <compat/sys/mount.h>
|
1995-12-26 07:44:37 +03:00
|
|
|
|
|
|
|
#define ULTRIX_MAXPATHLEN 1024
|
|
|
|
|
|
|
|
/**
|
|
|
|
** Ultrix filesystem operations: mount(), getmnt().
|
|
|
|
** These are included purely so one can place an (ECOFF or ELF)
|
|
|
|
** NetBSD/pmax kernel in an Ultrix root filesystem, boot it,
|
|
|
|
** and over-write the Ultrix root parition with NetBSD binaries.
|
|
|
|
**/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ultrix file system data structure, as modified by
|
|
|
|
* Ultrix getmntent(). This structure is padded to 2560 bytes, for
|
2003-01-06 16:26:24 +03:00
|
|
|
* compatibility with the size the Ultrix kernel and user apps expect.
|
1995-12-26 07:44:37 +03:00
|
|
|
*/
|
|
|
|
struct ultrix_fs_data {
|
|
|
|
u_int32_t ufsd_flags; /* how mounted */
|
|
|
|
u_int32_t ufsd_mtsize; /* max transfer size in bytes */
|
|
|
|
u_int32_t ufsd_otsize; /* optimal transfer size in bytes */
|
|
|
|
u_int32_t ufsd_bsize; /* fs block size (bytes) for vm code */
|
|
|
|
u_int32_t ufsd_fstype; /* see ../h/fs_types.h */
|
|
|
|
u_int32_t ufsd_gtot; /* total number of gnodes */
|
|
|
|
u_int32_t ufsd_gfree; /* # of free gnodes */
|
|
|
|
u_int32_t ufsd_btot; /* total number of 1K blocks */
|
|
|
|
u_int32_t ufsd_bfree; /* # of free 1K blocks */
|
|
|
|
u_int32_t ufsd_bfreen; /* user consumable 1K blocks */
|
|
|
|
u_int32_t ufsd_pgthresh; /* min size in bytes before paging*/
|
|
|
|
int32_t ufsd_uid; /* uid that mounted me */
|
|
|
|
int16_t ufsd_dev; /* major/minor of fs */
|
|
|
|
int16_t ufsd_exroot; /* root mapping from exports */
|
|
|
|
char ufsd_devname[ULTRIX_MAXPATHLEN + 4]; /* name of dev */
|
|
|
|
char ufsd_path[ULTRIX_MAXPATHLEN + 4]; /* name of mnt point */
|
|
|
|
u_int32_t ufsd_nupdate; /* number of writes */
|
|
|
|
u_int32_t ufsd_pad[112]; /* pad to 2560 bytes. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get statistics on mounted filesystems.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
struct ultrix_getmnt_args {
|
|
|
|
int32_t *start;
|
|
|
|
struct ultrix_fs_data *buf;
|
|
|
|
int32_t bufsize;
|
|
|
|
int32_t mode;
|
|
|
|
char *path;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Ultrix getmnt() flags.
|
|
|
|
* The operation getmnt() should perform is incoded in the flag
|
|
|
|
* argument. There are two independent attributes.
|
|
|
|
*
|
|
|
|
* ULTRIX_NOSTAT_xxx will never hang, but it may not return
|
|
|
|
* up-to-date statistics. (For NFS clients, it returns whatever is
|
|
|
|
* in the cache.) ULTRIX_STAT_xxx returns up-to-date info but may
|
|
|
|
* hang (e.g., on dead NFS servers).
|
|
|
|
*
|
|
|
|
* ULTRIX_xxSTAT_ONE returns statistics on just one filesystem, determined
|
|
|
|
* by the parth argument. ULTRIX_xxSTAT_MANY ignores the path argument and
|
|
|
|
* returns info on as many filesystems fit in the structure.
|
|
|
|
* the start argument, which should be zero on the first call,
|
|
|
|
* can be used to iterate over all filesystems.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define ULTRIX_NOSTAT_MANY 1
|
|
|
|
#define ULTRIX_STAT_MANY 2
|
|
|
|
#define ULTRIX_STAT_ONE 3
|
|
|
|
#define ULTRIX_NOSTAT_ONE 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ultrix gnode-layer filesystem codes.
|
|
|
|
*/
|
|
|
|
#define ULTRIX_FSTYPE_UNKNOWN 0x0
|
1995-12-26 13:06:14 +03:00
|
|
|
#define ULTRIX_FSTYPE_ULTRIX 0x1 /* Ultrix UFS: basically 4.2bsd FFS */
|
1995-12-26 07:44:37 +03:00
|
|
|
#define ULTRIX_FSTYPE_NFS 0x5 /* NFS v2 */
|
|
|
|
|
1995-12-26 13:06:14 +03:00
|
|
|
/*
|
|
|
|
* Ultrix mount(2) options
|
|
|
|
*/
|
|
|
|
#define ULTRIX_NM_RONLY 0x0001 /* mount read-only */
|
|
|
|
#define ULTRIX_NM_SOFT 0x0002 /* soft mount (hard is default) */
|
|
|
|
#define ULTRIX_NM_WSIZE 0x0004 /* set write size */
|
|
|
|
#define ULTRIX_NM_RSIZE 0x0008 /* set read size */
|
|
|
|
#define ULTRIX_NM_TIMEO 0x0010 /* set initial timeout */
|
|
|
|
#define ULTRIX_NM_RETRANS 0x0020 /* set number of request retrys */
|
|
|
|
#define ULTRIX_NM_HOSTNAME 0x0040 /* set hostname for error printf */
|
|
|
|
#define ULTRIX_NM_PGTHRESH 0x0080 /* set page threshold for exec */
|
|
|
|
#define ULTRIX_NM_INT 0x0100 /* allow hard mount keyboard interrupts */
|
|
|
|
#define ULTRIX_NM_NOAC 0x0200 /* don't cache attributes */
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1995-12-26 13:06:14 +03:00
|
|
|
|
1997-05-25 14:21:34 +04:00
|
|
|
static void
|
2004-04-21 11:05:07 +04:00
|
|
|
make_ultrix_mntent(struct statvfs *, struct ultrix_fs_data *);
|
1997-05-25 14:21:34 +04:00
|
|
|
|
1995-12-26 07:44:37 +03:00
|
|
|
/*
|
|
|
|
* Construct an Ultrix getmnt() ultrix_fs_data from the native NetBSD
|
|
|
|
* struct statfs.
|
|
|
|
*/
|
|
|
|
static void
|
2004-04-21 11:05:07 +04:00
|
|
|
make_ultrix_mntent(struct statvfs *sp, struct ultrix_fs_data *tem)
|
1995-12-26 07:44:37 +03:00
|
|
|
{
|
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(tem, 0, sizeof (*tem));
|
1995-12-26 13:06:14 +03:00
|
|
|
|
2004-04-21 09:20:27 +04:00
|
|
|
tem->ufsd_flags = sp->f_flag; /* XXX translate */
|
1995-12-26 13:06:14 +03:00
|
|
|
tem->ufsd_mtsize = sp->f_bsize; /* XXX max transfer size */
|
1995-12-26 07:44:37 +03:00
|
|
|
tem->ufsd_otsize = sp->f_iosize;
|
|
|
|
tem->ufsd_bsize = sp->f_bsize;
|
|
|
|
/*
|
1995-12-26 13:06:14 +03:00
|
|
|
* Translate file system type. NetBSD/1.1 has f_type zero,
|
|
|
|
* and uses an fstype string instead.
|
|
|
|
* For now, map types not in Ultrix (kernfs, null, procfs...)
|
|
|
|
* to UFS, since Ultrix mout will try and call mount_unknown
|
|
|
|
* for ULTRIX_FSTYPE_UNKNOWN, but lacks a mount_unknown binary.
|
1995-12-26 07:44:37 +03:00
|
|
|
*/
|
1995-12-26 13:06:14 +03:00
|
|
|
tem->ufsd_fstype = ULTRIX_FSTYPE_NFS;
|
|
|
|
if (strcmp(sp->f_fstypename, "ffs") == 0)
|
|
|
|
tem->ufsd_fstype = ULTRIX_FSTYPE_ULTRIX;
|
1995-12-26 07:44:37 +03:00
|
|
|
|
1995-12-26 13:06:14 +03:00
|
|
|
tem->ufsd_gtot = sp->f_files; /* total "gnodes" */
|
1996-04-07 21:23:04 +04:00
|
|
|
tem->ufsd_gfree = sp->f_ffree; /* free "gnodes" */
|
1995-12-26 13:06:14 +03:00
|
|
|
tem->ufsd_btot = sp->f_blocks; /* total 1k blocks */
|
1996-04-07 21:23:04 +04:00
|
|
|
#ifdef needsmorethought /* XXX */
|
|
|
|
/* tem->ufsd_bfree = sp->f_bfree; */ /* free 1k blocks */
|
|
|
|
/* tem->ufsd_bfree = sp->f_bavail; */ /* free 1k blocks */
|
|
|
|
#endif
|
|
|
|
|
1995-12-26 13:06:14 +03:00
|
|
|
tem->ufsd_bfreen = sp->f_bavail; /* blocks available to users */
|
1995-12-26 07:44:37 +03:00
|
|
|
tem->ufsd_pgthresh = 0; /* not relevant */
|
|
|
|
tem->ufsd_uid = 0; /* XXX kept where ?*/
|
|
|
|
tem->ufsd_dev = 0; /* ?? */
|
|
|
|
tem->ufsd_exroot = 0; /* ?? */
|
|
|
|
strncpy(tem->ufsd_path, sp->f_mntonname, ULTRIX_MAXPATHLEN);
|
|
|
|
strncpy(tem->ufsd_devname, sp->f_mntfromname, ULTRIX_MAXPATHLEN);
|
1995-12-26 13:06:14 +03:00
|
|
|
#if 0
|
|
|
|
/* In NetBSD-1.1, filesystem type is unused and always 0 */
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("mntent: %s type %d\n", tem->ufsd_devname, tem->ufsd_fstype);
|
|
|
|
printf("mntent: %s tot %d free %d user%d\n",
|
1995-12-26 13:06:14 +03:00
|
|
|
tem->ufsd_devname, sp->f_blocks, sp->f_bfree, sp->f_bavail);
|
|
|
|
#endif
|
1995-12-26 07:44:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_getmnt(struct lwp *l, const struct ultrix_sys_getmnt_args *uap, register_t *retval)
|
1995-12-26 07:44:37 +03:00
|
|
|
{
|
|
|
|
struct mount *mp, *nmp;
|
2004-04-21 09:20:27 +04:00
|
|
|
struct statvfs *sp;
|
1995-12-26 07:44:37 +03:00
|
|
|
struct ultrix_fs_data *sfsp;
|
|
|
|
char *path;
|
|
|
|
int mntflags;
|
|
|
|
int skip;
|
|
|
|
int start;
|
|
|
|
long count, maxcount;
|
|
|
|
int error = 0;
|
|
|
|
|
1999-04-25 06:42:01 +04:00
|
|
|
nmp = NULL; /* XXX keep gcc quiet */
|
1995-12-26 07:44:37 +03:00
|
|
|
path = NULL;
|
|
|
|
error = 0;
|
|
|
|
maxcount = SCARG(uap, bufsize) / sizeof(struct ultrix_fs_data);
|
|
|
|
sfsp = SCARG(uap, buf);
|
|
|
|
|
|
|
|
if (SCARG(uap, mode) == ULTRIX_STAT_ONE ||
|
|
|
|
SCARG(uap, mode) == ULTRIX_STAT_MANY)
|
|
|
|
mntflags = MNT_WAIT;
|
|
|
|
else
|
|
|
|
mntflags = MNT_NOWAIT;
|
|
|
|
|
|
|
|
if (SCARG(uap, mode) == ULTRIX_STAT_ONE || SCARG(uap, mode) == ULTRIX_NOSTAT_ONE) {
|
|
|
|
/*
|
|
|
|
* Only get info on mountpoints that matches the path
|
|
|
|
* provided.
|
|
|
|
*/
|
2008-12-17 23:51:31 +03:00
|
|
|
path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
|
1996-04-07 21:23:04 +04:00
|
|
|
if ((error = copyinstr(SCARG(uap, path), path,
|
|
|
|
MAXPATHLEN, NULL)) != 0)
|
1995-12-26 07:44:37 +03:00
|
|
|
goto bad;
|
|
|
|
maxcount = 1;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Get info on any mountpoints, somewhat like readdir().
|
|
|
|
* Find out how many mount list entries to skip, and skip
|
|
|
|
* them.
|
|
|
|
*/
|
2007-03-04 08:59:00 +03:00
|
|
|
if ((error = copyin((void *)SCARG(uap, start), &start,
|
1996-04-07 21:23:04 +04:00
|
|
|
sizeof(*SCARG(uap, start)))) != 0)
|
1995-12-26 07:44:37 +03:00
|
|
|
goto bad;
|
2007-10-11 00:42:20 +04:00
|
|
|
mutex_enter(&mountlist_lock);
|
1995-12-26 07:44:37 +03:00
|
|
|
for (skip = start, mp = mountlist.cqh_first;
|
|
|
|
mp != (void*)&mountlist && skip-- > 0; mp = nmp)
|
|
|
|
nmp = mp->mnt_list.cqe_next;
|
2007-10-11 00:42:20 +04:00
|
|
|
mutex_exit(&mountlist_lock);
|
1995-12-26 07:44:37 +03:00
|
|
|
}
|
|
|
|
|
2007-10-11 00:42:20 +04:00
|
|
|
mutex_enter(&mountlist_lock);
|
1995-12-26 07:44:37 +03:00
|
|
|
for (count = 0, mp = mountlist.cqh_first;
|
|
|
|
mp != (void*)&mountlist && count < maxcount; mp = nmp) {
|
PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.
Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:
- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.
- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.
One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 22:43:44 +04:00
|
|
|
if (vfs_busy(mp, &nmp)) {
|
1998-03-06 01:51:35 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sfsp != NULL) {
|
1995-12-26 07:44:37 +03:00
|
|
|
struct ultrix_fs_data tem;
|
|
|
|
sp = &mp->mnt_stat;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If requested, refresh the fsstat cache.
|
|
|
|
*/
|
1998-03-06 01:51:35 +03:00
|
|
|
if (mntflags != MNT_WAIT &&
|
2007-11-27 12:47:15 +03:00
|
|
|
(error = VFS_STATVFS(mp, sp)) != 0)
|
1995-12-26 07:44:37 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX what does this do? -- cgd
|
|
|
|
*/
|
2004-04-21 09:20:27 +04:00
|
|
|
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
1995-12-26 07:44:37 +03:00
|
|
|
if (path == NULL ||
|
|
|
|
strcmp(path, sp->f_mntonname) == 0) {
|
|
|
|
make_ultrix_mntent(sp, &tem);
|
2007-03-04 08:59:00 +03:00
|
|
|
if ((error = copyout((void *)&tem, sfsp,
|
2008-01-30 14:46:59 +03:00
|
|
|
sizeof(tem))) != 0) {
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mp, false, NULL);
|
1995-12-26 07:44:37 +03:00
|
|
|
goto bad;
|
2008-01-30 14:46:59 +03:00
|
|
|
}
|
1995-12-26 07:44:37 +03:00
|
|
|
sfsp++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mp, false, &nmp);
|
1995-12-26 07:44:37 +03:00
|
|
|
}
|
2007-10-11 00:42:20 +04:00
|
|
|
mutex_exit(&mountlist_lock);
|
1995-12-26 07:44:37 +03:00
|
|
|
|
|
|
|
if (sfsp != NULL && count > maxcount)
|
|
|
|
*retval = maxcount;
|
|
|
|
else
|
|
|
|
*retval = count;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
if (path)
|
2008-12-17 23:51:31 +03:00
|
|
|
free(path, M_TEMP);
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1995-12-26 07:44:37 +03:00
|
|
|
}
|
1995-12-26 13:06:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Old-style inet sockaddr (no len field) as passed to Ultrix mount(2) */
|
|
|
|
struct osockaddr_in {
|
|
|
|
short sin_family;
|
|
|
|
u_short sin_port;
|
|
|
|
struct in_addr sin_addr;
|
|
|
|
char sin_zero[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fstype-dependent structure passed to Ultrix mount(2) when
|
|
|
|
* mounting NFS filesystems
|
|
|
|
*/
|
|
|
|
struct ultrix_nfs_args {
|
|
|
|
struct osockaddr_in *addr; /* file server address */
|
1996-02-19 18:41:38 +03:00
|
|
|
void *fh; /* file handle to be mounted */
|
1995-12-26 13:06:14 +03:00
|
|
|
int flags; /* flags */
|
|
|
|
int wsize; /* write size in bytes */
|
|
|
|
int rsize; /* read size in bytes */
|
|
|
|
int timeo; /* initial timeout in .1 secs */
|
|
|
|
int retrans; /* times to retry send */
|
|
|
|
char *hostname; /* server's hostname */
|
|
|
|
char *optstr; /* string of nfs mount options*/
|
|
|
|
int gfs_flags; /* gnode flags (ugh) */
|
|
|
|
int pg_thresh; /* paging threshold ? */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fstype-dependent structure passed to Ultrix mount(2) when
|
|
|
|
* mounting local (4.2bsd FFS) filesystems
|
|
|
|
*/
|
|
|
|
struct ultrix_ufs_args {
|
|
|
|
u_long ufs_flags; /* mount flags?*/
|
|
|
|
u_long ufs_pgthresh; /* minimum file size to page */
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_mount(struct lwp *l, const struct ultrix_sys_mount_args *uap, register_t *retval)
|
1995-12-26 13:06:14 +03:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int otype = SCARG(uap, type);
|
|
|
|
char fsname[MFSNAMELEN];
|
2007-07-14 21:11:28 +04:00
|
|
|
register_t dummy;
|
2007-07-12 23:41:57 +04:00
|
|
|
int nflags;
|
1995-12-26 13:06:14 +03:00
|
|
|
|
2007-07-12 23:41:57 +04:00
|
|
|
nflags = 0;
|
1995-12-26 13:06:14 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Translate Ultrix integer mount codes for UFS and NFS to
|
|
|
|
* NetBSD fstype strings. Other Ultrix filesystem types
|
|
|
|
* (msdos, DEC ods-2) are not supported.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Translate the Ultrix mount-readonly option parameter */
|
|
|
|
if (SCARG(uap, rdonly))
|
2007-07-12 23:41:57 +04:00
|
|
|
nflags |= MNT_RDONLY;
|
|
|
|
|
1995-12-26 13:06:14 +03:00
|
|
|
|
|
|
|
#ifdef later
|
|
|
|
parse ultrix mount option string and set NetBSD flags
|
|
|
|
#endif
|
|
|
|
|
2007-07-12 23:41:57 +04:00
|
|
|
if (otype == ULTRIX_FSTYPE_NFS) {
|
1995-12-26 13:06:14 +03:00
|
|
|
struct ultrix_nfs_args una;
|
|
|
|
struct nfs_args na;
|
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
if ((error = copyin(SCARG(uap, data), &una, sizeof(una))) != 0)
|
|
|
|
return error;
|
2007-07-12 23:41:57 +04:00
|
|
|
#if 0
|
1995-12-26 13:06:14 +03:00
|
|
|
/*
|
|
|
|
* This is the only syscall boundary the
|
|
|
|
* address of the server passes, so do backwards
|
|
|
|
* compatibility on 4.3style sockaddrs here.
|
|
|
|
*/
|
1996-04-07 21:23:04 +04:00
|
|
|
if ((error = copyin(una.addr, &osa, sizeof osa)) != 0) {
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("ultrix_mount: nfs copyin osa\n");
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1995-12-26 13:06:14 +03:00
|
|
|
}
|
|
|
|
sap->sin_family = (u_char)osa.sin_family;
|
|
|
|
sap->sin_len = sizeof(*sap);
|
2007-07-12 23:41:57 +04:00
|
|
|
/* XXXX teach nfs how to do the above */
|
|
|
|
#endif
|
1996-02-19 18:41:38 +03:00
|
|
|
na.version = NFS_ARGSVERSION;
|
2007-07-14 21:11:28 +04:00
|
|
|
na.addr = (void *)una.addr;
|
2007-07-12 23:41:57 +04:00
|
|
|
na.addrlen = sizeof (struct sockaddr_in);
|
1995-12-26 13:06:14 +03:00
|
|
|
na.sotype = SOCK_DGRAM;
|
|
|
|
na.proto = IPPROTO_UDP;
|
|
|
|
na.fh = una.fh;
|
1996-02-19 18:41:38 +03:00
|
|
|
na.fhsize = NFSX_V2FH;
|
1995-12-26 13:06:14 +03:00
|
|
|
na.flags = /*una.flags;*/ NFSMNT_NOCONN | NFSMNT_RESVPORT;
|
|
|
|
na.wsize = una.wsize;
|
|
|
|
na.rsize = una.rsize;
|
|
|
|
na.timeo = una.timeo;
|
|
|
|
na.retrans = una.retrans;
|
|
|
|
na.hostname = una.hostname;
|
2007-10-23 19:21:31 +04:00
|
|
|
return do_sys_mount(l, vfs_getopsbyname("nfs"), NULL,
|
2007-07-12 23:41:57 +04:00
|
|
|
SCARG(uap, special), nflags, &na, UIO_SYSSPACE,
|
|
|
|
sizeof na, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
2007-07-14 21:11:28 +04:00
|
|
|
if ((error = copyinstr(SCARG(uap, dir), fsname,
|
2007-07-12 23:41:57 +04:00
|
|
|
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,
|
2007-07-14 21:11:28 +04:00
|
|
|
SCARG(uap, dir), nflags, &ua, UIO_SYSSPACE, sizeof ua,
|
2007-07-12 23:41:57 +04:00
|
|
|
&dummy);
|
1995-12-26 13:06:14 +03:00
|
|
|
}
|
2007-07-12 23:41:57 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return EINVAL;
|
1995-12-26 13:06:14 +03:00
|
|
|
}
|