2009-01-11 05:45:45 +03:00
|
|
|
/* $NetBSD: coda_vfsops.c,v 1.68 2009/01/11 02:45:46 christos Exp $ */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-08 21:12:46 +04:00
|
|
|
/*
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Coda: an Experimental Distributed File System
|
|
|
|
* Release 3.1
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Copyright (c) 1987-1998 Carnegie Mellon University
|
|
|
|
* All Rights Reserved
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation, and
|
|
|
|
* that credit is given to Carnegie Mellon University in all documents
|
|
|
|
* and publicity pertaining to direct or indirect use of this code or its
|
|
|
|
* derivatives.
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
|
|
|
|
* SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
|
|
|
|
* FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
|
|
|
|
* DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
|
|
|
|
* RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
|
|
|
|
* ANY DERIVATIVE WORK.
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
1998-09-08 21:12:46 +04:00
|
|
|
* Carnegie Mellon encourages users of this software to return any
|
|
|
|
* improvements or extensions that they make, and to grant Carnegie
|
|
|
|
* Mellon the rights to redistribute these changes without encumbrance.
|
2005-02-27 01:58:54 +03:00
|
|
|
*
|
|
|
|
* @(#) cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:26:45 rvb Exp $
|
1998-09-08 21:12:46 +04:00
|
|
|
*/
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2005-02-27 01:58:54 +03:00
|
|
|
/*
|
1998-08-30 01:26:45 +04:00
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1989 Carnegie-Mellon University
|
|
|
|
* All rights reserved. The CMU software License Agreement specifies
|
|
|
|
* the terms and conditions for use and redistribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code was written for the Coda file system at Carnegie Mellon
|
|
|
|
* University. Contributers include David Steere, James Kistler, and
|
2005-02-27 01:58:54 +03:00
|
|
|
* M. Satyanarayanan.
|
1998-08-30 01:26:45 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 02:08:56 +03:00
|
|
|
#include <sys/cdefs.h>
|
2009-01-11 05:45:45 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.68 2009/01/11 02:45:46 christos Exp $");
|
2001-11-13 02:08:56 +03:00
|
|
|
|
2008-12-30 15:56:12 +03:00
|
|
|
#ifndef _KERNEL_OPT
|
1998-09-25 19:01:12 +04:00
|
|
|
#define NVCODA 4
|
|
|
|
#else
|
1998-09-12 19:05:47 +04:00
|
|
|
#include <vcoda.h>
|
1998-09-25 19:01:12 +04:00
|
|
|
#endif
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
#include <sys/sysctl.h>
|
1998-08-30 01:26:45 +04:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/namei.h>
|
2004-04-21 06:40:42 +04:00
|
|
|
#include <sys/dirent.h>
|
1998-08-30 01:26:45 +04:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/select.h>
|
2006-05-15 01:19:33 +04:00
|
|
|
#include <sys/kauth.h>
|
2008-05-10 06:26:09 +04:00
|
|
|
#include <sys/module.h>
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-15 06:02:55 +04:00
|
|
|
#include <coda/coda.h>
|
|
|
|
#include <coda/cnode.h>
|
|
|
|
#include <coda/coda_vfsops.h>
|
|
|
|
#include <coda/coda_venus.h>
|
|
|
|
#include <coda/coda_subr.h>
|
|
|
|
#include <coda/coda_opstats.h>
|
1998-08-30 01:26:45 +04:00
|
|
|
/* for VN_RDEV */
|
|
|
|
#include <miscfs/specfs/specdev.h>
|
2008-01-28 17:31:15 +03:00
|
|
|
#include <miscfs/genfs/genfs.h>
|
2008-05-10 06:26:09 +04:00
|
|
|
|
|
|
|
MODULE(MODULE_CLASS_VFS, coda, NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2003-02-01 09:23:35 +03:00
|
|
|
MALLOC_DEFINE(M_CODA, "coda", "Coda file system structures and tables");
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
int codadebug = 0;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
int coda_vfsop_print_entry = 0;
|
2001-11-23 20:42:48 +03:00
|
|
|
#define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__func__))
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
struct vnode *coda_ctlvp;
|
|
|
|
struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* structure to keep statistics of internally generated/satisfied calls */
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
#define MARK_ENTRY(op) (coda_vfsopstats[op].entries++)
|
|
|
|
#define MARK_INT_SAT(op) (coda_vfsopstats[op].sat_intrn++)
|
|
|
|
#define MARK_INT_FAIL(op) (coda_vfsopstats[op].unsat_intrn++)
|
|
|
|
#define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
extern const struct cdevsw vcoda_cdevsw;
|
2001-01-22 15:17:35 +03:00
|
|
|
extern const struct vnodeopv_desc coda_vnodeop_opv_desc;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc * const coda_vnodeopv_descs[] = {
|
1998-09-12 19:05:47 +04:00
|
|
|
&coda_vnodeop_opv_desc,
|
1998-08-30 01:26:45 +04:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
struct vfsops coda_vfsops = {
|
|
|
|
MOUNT_CODA,
|
2007-07-12 23:38:26 +04:00
|
|
|
256, /* This is the pathname, unlike every other fs */
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_mount,
|
|
|
|
coda_start,
|
|
|
|
coda_unmount,
|
|
|
|
coda_root,
|
2007-11-26 22:01:26 +03:00
|
|
|
(void *)eopnotsupp, /* vfs_quotactl */
|
2004-04-21 05:05:31 +04:00
|
|
|
coda_nb_statvfs,
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_sync,
|
|
|
|
coda_vget,
|
2006-12-09 19:11:50 +03:00
|
|
|
(void *)eopnotsupp, /* vfs_fhtovp */
|
|
|
|
(void *)eopnotsupp, /* vfs_vptofh */
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_init,
|
2006-08-30 03:45:23 +04:00
|
|
|
NULL, /* vfs_reinit */
|
2000-03-16 21:08:17 +03:00
|
|
|
coda_done,
|
1998-08-30 01:26:45 +04:00
|
|
|
(int (*)(void)) eopnotsupp,
|
2004-05-25 18:54:55 +04:00
|
|
|
(int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp,
|
2005-01-02 19:08:28 +03:00
|
|
|
vfs_stdextattrctl,
|
2007-07-27 02:57:36 +04:00
|
|
|
(void *)eopnotsupp, /* vfs_suspendctl */
|
2008-01-28 17:31:15 +03:00
|
|
|
genfs_renamelock_enter,
|
|
|
|
genfs_renamelock_exit,
|
2008-04-29 22:18:08 +04:00
|
|
|
(void *)eopnotsupp,
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_vnodeopv_descs,
|
2006-08-30 03:45:23 +04:00
|
|
|
0, /* vfs_refcount */
|
|
|
|
{ NULL, NULL }, /* vfs_list */
|
1998-08-30 01:26:45 +04:00
|
|
|
};
|
|
|
|
|
2008-05-10 06:26:09 +04:00
|
|
|
static int
|
|
|
|
coda_modcmd(modcmd_t cmd, void *arg)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case MODULE_CMD_INIT:
|
|
|
|
return vfs_attach(&coda_vfsops);
|
|
|
|
case MODULE_CMD_FINI:
|
|
|
|
return vfs_detach(&coda_vfsops);
|
|
|
|
default:
|
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
}
|
2003-08-27 21:49:48 +04:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
int
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_vfsopstats_init(void)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
int i;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
for (i=0;i<CODA_VFSOPS_SIZE;i++) {
|
|
|
|
coda_vfsopstats[i].opcode = i;
|
|
|
|
coda_vfsopstats[i].entries = 0;
|
|
|
|
coda_vfsopstats[i].sat_intrn = 0;
|
|
|
|
coda_vfsopstats[i].unsat_intrn = 0;
|
|
|
|
coda_vfsopstats[i].gen_intrn = 0;
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cfs mount vfsop
|
|
|
|
* Set up mount info record and attach it to vfs struct.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
2005-08-31 02:24:11 +04:00
|
|
|
coda_mount(struct mount *vfsp, /* Allocated and initialized by mount(2) */
|
2006-11-16 04:32:37 +03:00
|
|
|
const char *path, /* path covered: ignored by the fs-layer */
|
2006-10-12 05:30:41 +04:00
|
|
|
void *data, /* Need to define a data type for this in netbsd? */
|
2007-11-26 22:01:26 +03:00
|
|
|
size_t *data_len)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
2007-11-26 22:01:26 +03:00
|
|
|
struct lwp *l = curlwp;
|
2007-08-01 01:14:15 +04:00
|
|
|
struct nameidata nd;
|
1998-08-30 01:26:45 +04:00
|
|
|
struct vnode *dvp;
|
|
|
|
struct cnode *cp;
|
|
|
|
dev_t dev;
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_mntinfo *mi;
|
2005-05-30 01:05:25 +04:00
|
|
|
struct vnode *rtvp;
|
2002-09-06 17:18:43 +04:00
|
|
|
const struct cdevsw *cdev;
|
2003-08-27 21:49:48 +04:00
|
|
|
CodaFid rootfid = INVAL_FID;
|
|
|
|
CodaFid ctlfid = CTL_FID;
|
1998-08-30 01:26:45 +04:00
|
|
|
int error;
|
|
|
|
|
2002-09-21 22:10:34 +04:00
|
|
|
if (vfsp->mnt_flag & MNT_GETARGS)
|
2007-07-12 23:38:26 +04:00
|
|
|
return EINVAL;
|
1998-08-30 01:26:45 +04:00
|
|
|
ENTRY;
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_vfsopstats_init();
|
|
|
|
coda_vnodeopstats_init();
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_ENTRY(CODA_MOUNT_STATS);
|
|
|
|
if (CODA_MOUNTED(vfsp)) {
|
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(EBUSY);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/* Validate mount device. Similar to getmdev(). */
|
|
|
|
|
2007-07-12 23:38:26 +04:00
|
|
|
/*
|
|
|
|
* XXX: coda passes the mount device as the entire mount args,
|
|
|
|
* All other fs pass a structure contining a pointer.
|
|
|
|
* In order to get sys_mount() to do the copyin() we've set a
|
2007-12-01 03:09:41 +03:00
|
|
|
* fixed default size for the filename buffer.
|
2007-07-12 23:38:26 +04:00
|
|
|
*/
|
2007-12-01 03:09:41 +03:00
|
|
|
/* Ensure that namei() doesn't run off the filename buffer */
|
|
|
|
((char *)data)[*data_len - 1] = 0;
|
2007-12-08 22:29:36 +03:00
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, data);
|
2007-08-01 01:14:15 +04:00
|
|
|
error = namei(&nd);
|
|
|
|
dvp = nd.ni_vp;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
if (error) {
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (dvp->v_type != VCHR) {
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
vrele(dvp);
|
|
|
|
return(ENXIO);
|
|
|
|
}
|
2008-01-15 21:11:25 +03:00
|
|
|
dev = dvp->v_rdev;
|
1998-08-30 01:26:45 +04:00
|
|
|
vrele(dvp);
|
2002-09-06 17:18:43 +04:00
|
|
|
cdev = cdevsw_lookup(dev);
|
|
|
|
if (cdev == NULL) {
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if the device table matches our expectations.
|
|
|
|
*/
|
2002-09-06 17:18:43 +04:00
|
|
|
if (cdev != &vcoda_cdevsw)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
2009-01-11 05:45:45 +03:00
|
|
|
if (minor(dev) >= NVCODA) {
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/*
|
|
|
|
* Initialize the mount record and link it to the vfs struct
|
|
|
|
*/
|
1998-09-12 19:05:47 +04:00
|
|
|
mi = &coda_mnttbl[minor(dev)];
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
if (!VC_OPEN(&mi->mi_vcomm)) {
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(ENODEV);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/* No initialization (here) of mi_vcomm! */
|
2002-07-30 11:40:07 +04:00
|
|
|
vfsp->mnt_data = mi;
|
2004-04-21 05:05:31 +04:00
|
|
|
vfsp->mnt_stat.f_fsidx.__fsid_val[0] = 0;
|
|
|
|
vfsp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CODA);
|
|
|
|
vfsp->mnt_stat.f_fsid = vfsp->mnt_stat.f_fsidx.__fsid_val[0];
|
|
|
|
vfsp->mnt_stat.f_namemax = MAXNAMLEN;
|
1998-08-30 01:26:45 +04:00
|
|
|
mi->mi_vfsp = vfsp;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/*
|
|
|
|
* Make a root vnode to placate the Vnode interface, but don't
|
1998-09-12 19:05:47 +04:00
|
|
|
* actually make the CODA_ROOT call to venus until the first call
|
|
|
|
* to coda_root in case a server is down while venus is starting.
|
1998-08-30 01:26:45 +04:00
|
|
|
*/
|
1998-09-12 19:05:47 +04:00
|
|
|
cp = make_coda_node(&rootfid, vfsp, VDIR);
|
2005-05-30 01:05:25 +04:00
|
|
|
rtvp = CTOV(cp);
|
2007-10-11 00:42:20 +04:00
|
|
|
rtvp->v_vflag |= VV_ROOT;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
/* cp = make_coda_node(&ctlfid, vfsp, VCHR);
|
1998-08-30 01:26:45 +04:00
|
|
|
The above code seems to cause a loop in the cnode links.
|
|
|
|
I don't totally understand when it happens, it is caught
|
|
|
|
when closing down the system.
|
|
|
|
*/
|
1998-09-12 19:05:47 +04:00
|
|
|
cp = make_coda_node(&ctlfid, 0, VCHR);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_ctlvp = CTOV(cp);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* Add vfs and rootvp to chain of vfs hanging off mntinfo */
|
|
|
|
mi->mi_vfsp = vfsp;
|
2005-05-30 01:05:25 +04:00
|
|
|
mi->mi_rootvp = rtvp;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/* set filesystem block size */
|
|
|
|
vfsp->mnt_stat.f_bsize = 8192; /* XXX -JJK */
|
2004-04-21 05:05:31 +04:00
|
|
|
vfsp->mnt_stat.f_frsize = 8192; /* XXX -JJK */
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/* error is currently guaranteed to be zero, but in case some
|
|
|
|
code changes... */
|
1998-09-12 19:05:47 +04:00
|
|
|
CODADEBUG(1,
|
|
|
|
myprintf(("coda_mount returned %d\n",error)););
|
1998-08-30 01:26:45 +04:00
|
|
|
if (error)
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_MOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
else
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_SAT(CODA_MOUNT_STATS);
|
2003-04-17 01:44:18 +04:00
|
|
|
|
2007-07-17 15:19:31 +04:00
|
|
|
return set_statvfs_info("/coda", UIO_SYSSPACE, "CODA", UIO_SYSSPACE,
|
|
|
|
vfsp->mnt_op->vfs_name, vfsp, l);
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-26 22:01:26 +03:00
|
|
|
coda_start(struct mount *vfsp, int flags)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
ENTRY;
|
2003-08-25 14:05:46 +04:00
|
|
|
vftomi(vfsp)->mi_started = 1;
|
1998-08-30 01:26:45 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-11-26 22:01:26 +03:00
|
|
|
coda_unmount(struct mount *vfsp, int mntflags)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_mntinfo *mi = vftomi(vfsp);
|
1998-08-30 01:26:45 +04:00
|
|
|
int active, error = 0;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
ENTRY;
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_ENTRY(CODA_UMOUNT_STATS);
|
|
|
|
if (!CODA_MOUNTED(vfsp)) {
|
|
|
|
MARK_INT_FAIL(CODA_UMOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
if (mi->mi_vfsp == vfsp) { /* We found the victim */
|
|
|
|
if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
|
|
|
|
return (EBUSY); /* Venus is still running */
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-09-12 19:05:47 +04:00
|
|
|
printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
|
1998-08-30 01:26:45 +04:00
|
|
|
#endif
|
2003-08-25 14:05:46 +04:00
|
|
|
mi->mi_started = 0;
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
vrele(mi->mi_rootvp);
|
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
active = coda_kill(vfsp, NOT_DOWNCALL);
|
2007-10-11 00:42:20 +04:00
|
|
|
mi->mi_rootvp->v_vflag &= ~VV_ROOT;
|
1998-08-30 01:26:45 +04:00
|
|
|
error = vflush(mi->mi_vfsp, NULLVP, FORCECLOSE);
|
1998-09-12 19:05:47 +04:00
|
|
|
printf("coda_unmount: active = %d, vflush active %d\n", active, error);
|
1998-08-30 01:26:45 +04:00
|
|
|
error = 0;
|
1998-09-08 21:12:46 +04:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/* I'm going to take this out to allow lookups to go through. I'm
|
|
|
|
* not sure it's important anyway. -- DCS 2/2/94
|
|
|
|
*/
|
|
|
|
/* vfsp->VFS_DATA = NULL; */
|
|
|
|
|
|
|
|
/* No more vfsp's to hold onto */
|
|
|
|
mi->mi_vfsp = NULL;
|
|
|
|
mi->mi_rootvp = NULL;
|
|
|
|
|
|
|
|
if (error)
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_UMOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
else
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_SAT(CODA_UMOUNT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find root of cfs
|
|
|
|
*/
|
|
|
|
int
|
2005-08-31 02:24:11 +04:00
|
|
|
coda_root(struct mount *vfsp, struct vnode **vpp)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_mntinfo *mi = vftomi(vfsp);
|
1998-08-30 01:26:45 +04:00
|
|
|
int error;
|
2006-07-21 20:48:45 +04:00
|
|
|
struct lwp *l = curlwp; /* XXX - bnoble */
|
2003-08-27 21:49:48 +04:00
|
|
|
CodaFid VFid;
|
|
|
|
static const CodaFid invalfid = INVAL_FID;
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
ENTRY;
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_ENTRY(CODA_ROOT_STATS);
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
if (vfsp == mi->mi_vfsp) {
|
2003-08-27 21:49:48 +04:00
|
|
|
if (memcmp(&VTOC(mi->mi_rootvp)->c_fid, &invalfid, sizeof(CodaFid)))
|
1998-08-30 01:26:45 +04:00
|
|
|
{ /* Found valid root. */
|
|
|
|
*vpp = mi->mi_rootvp;
|
|
|
|
/* On Mach, this is vref. On NetBSD, VOP_LOCK */
|
|
|
|
vref(*vpp);
|
1998-09-08 21:12:46 +04:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE);
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_SAT(CODA_ROOT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-21 20:48:45 +04:00
|
|
|
error = venus_root(vftomi(vfsp), l->l_cred, l->l_proc, &VFid);
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
/*
|
|
|
|
* Save the new rootfid in the cnode, and rehash the cnode into the
|
|
|
|
* cnode hash with the new fid key.
|
|
|
|
*/
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_unsave(VTOC(mi->mi_rootvp));
|
1998-08-30 01:26:45 +04:00
|
|
|
VTOC(mi->mi_rootvp)->c_fid = VFid;
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_save(VTOC(mi->mi_rootvp));
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
*vpp = mi->mi_rootvp;
|
|
|
|
vref(*vpp);
|
1998-09-08 21:12:46 +04:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE);
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_SAT(CODA_ROOT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
goto exit;
|
1998-12-10 05:22:52 +03:00
|
|
|
} else if (error == ENODEV || error == EINTR) {
|
1998-08-30 01:26:45 +04:00
|
|
|
/* Gross hack here! */
|
|
|
|
/*
|
1998-09-12 19:05:47 +04:00
|
|
|
* If Venus fails to respond to the CODA_ROOT call, coda_call returns
|
1998-08-30 01:26:45 +04:00
|
|
|
* ENODEV. Return the uninitialized root vnode to allow vfs
|
|
|
|
* operations such as unmount to continue. Without this hack,
|
2005-02-27 01:58:54 +03:00
|
|
|
* there is no way to do an unmount if Venus dies before a
|
|
|
|
* successful CODA_ROOT call is done. All vnode operations
|
1998-08-30 01:26:45 +04:00
|
|
|
* will fail.
|
|
|
|
*/
|
|
|
|
*vpp = mi->mi_rootvp;
|
|
|
|
vref(*vpp);
|
1998-09-08 21:12:46 +04:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE);
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_INT_FAIL(CODA_ROOT_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
error = 0;
|
|
|
|
goto exit;
|
|
|
|
} else {
|
1998-09-12 19:05:47 +04:00
|
|
|
CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
|
|
|
|
MARK_INT_FAIL(CODA_ROOT_STATS);
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system statistics.
|
|
|
|
*/
|
|
|
|
int
|
2007-11-26 22:01:26 +03:00
|
|
|
coda_nb_statvfs(struct mount *vfsp, struct statvfs *sbp)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
2007-11-26 22:01:26 +03:00
|
|
|
struct lwp *l = curlwp;
|
2002-03-27 08:10:40 +03:00
|
|
|
struct coda_statfs fsstat;
|
|
|
|
int error;
|
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
ENTRY;
|
2002-03-27 08:10:40 +03:00
|
|
|
MARK_ENTRY(CODA_STATFS_STATS);
|
1998-09-12 19:05:47 +04:00
|
|
|
if (!CODA_MOUNTED(vfsp)) {
|
2002-03-27 08:10:40 +03:00
|
|
|
/* MARK_INT_FAIL(CODA_STATFS_STATS); */
|
1998-08-30 01:26:45 +04:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
/* XXX - what to do about f_flags, others? --bnoble */
|
|
|
|
/* Below This is what AFS does
|
|
|
|
#define NB_SFS_SIZ 0x895440
|
|
|
|
*/
|
|
|
|
/* Note: Normal fs's have a bsize of 0x400 == 1024 */
|
2002-03-27 08:10:40 +03:00
|
|
|
|
2006-07-21 20:48:45 +04:00
|
|
|
error = venus_statfs(vftomi(vfsp), l->l_cred, l, &fsstat);
|
2002-03-27 08:10:40 +03:00
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
sbp->f_bsize = 8192; /* XXX */
|
2004-04-21 05:05:31 +04:00
|
|
|
sbp->f_frsize = 8192; /* XXX */
|
2002-03-27 08:10:40 +03:00
|
|
|
sbp->f_iosize = 8192; /* XXX */
|
|
|
|
sbp->f_blocks = fsstat.f_blocks;
|
|
|
|
sbp->f_bfree = fsstat.f_bfree;
|
|
|
|
sbp->f_bavail = fsstat.f_bavail;
|
2004-04-21 05:05:31 +04:00
|
|
|
sbp->f_bresvd = 0;
|
2002-03-27 08:10:40 +03:00
|
|
|
sbp->f_files = fsstat.f_files;
|
|
|
|
sbp->f_ffree = fsstat.f_ffree;
|
2004-04-21 05:05:31 +04:00
|
|
|
sbp->f_favail = fsstat.f_ffree;
|
|
|
|
sbp->f_fresvd = 0;
|
|
|
|
copy_statvfs_info(sbp, vfsp);
|
2002-03-27 08:10:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MARK_INT_SAT(CODA_STATFS_STATS);
|
|
|
|
return(error);
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush any pending I/O.
|
|
|
|
*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
coda_sync(struct mount *vfsp, int waitfor,
|
2007-11-26 22:01:26 +03:00
|
|
|
kauth_cred_t cred)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
ENTRY;
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_ENTRY(CODA_SYNC_STATS);
|
|
|
|
MARK_INT_SAT(CODA_SYNC_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
coda_vget(struct mount *vfsp, ino_t ino,
|
|
|
|
struct vnode **vpp)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
ENTRY;
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
2005-02-27 01:58:54 +03:00
|
|
|
/*
|
1998-08-30 01:26:45 +04:00
|
|
|
* fhtovp is now what vget used to be in 4.3-derived systems. For
|
|
|
|
* some silly reason, vget is now keyed by a 32 bit ino_t, rather than
|
2005-02-27 01:58:54 +03:00
|
|
|
* a type-specific fid.
|
1998-08-30 01:26:45 +04:00
|
|
|
*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
coda_fhtovp(struct mount *vfsp, struct fid *fhp, struct mbuf *nam,
|
|
|
|
struct vnode **vpp, int *exflagsp,
|
|
|
|
kauth_cred_t *creadanonp)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
struct cfid *cfid = (struct cfid *)fhp;
|
|
|
|
struct cnode *cp = 0;
|
|
|
|
int error;
|
2006-07-21 20:48:45 +04:00
|
|
|
struct lwp *l = curlwp; /* XXX -mach */
|
2003-08-27 21:49:48 +04:00
|
|
|
CodaFid VFid;
|
1998-08-30 01:26:45 +04:00
|
|
|
int vtype;
|
|
|
|
|
|
|
|
ENTRY;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
MARK_ENTRY(CODA_VGET_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
/* Check for vget of control object. */
|
|
|
|
if (IS_CTL_FID(&cfid->cfid_fid)) {
|
1998-09-12 19:05:47 +04:00
|
|
|
*vpp = coda_ctlvp;
|
|
|
|
vref(coda_ctlvp);
|
|
|
|
MARK_INT_SAT(CODA_VGET_STATS);
|
1998-08-30 01:26:45 +04:00
|
|
|
return(0);
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
2006-07-21 20:48:45 +04:00
|
|
|
error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, l->l_cred, l->l_proc, &VFid, &vtype);
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
if (error) {
|
1998-09-12 19:05:47 +04:00
|
|
|
CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
|
1998-08-30 01:26:45 +04:00
|
|
|
*vpp = (struct vnode *)0;
|
|
|
|
} else {
|
2005-02-27 01:58:54 +03:00
|
|
|
CODADEBUG(CODA_VGET,
|
2003-08-27 21:49:48 +04:00
|
|
|
myprintf(("vget: %s type %d result %d\n",
|
|
|
|
coda_f2s(&VFid), vtype, error)); )
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
cp = make_coda_node(&VFid, vfsp, vtype);
|
1998-08-30 01:26:45 +04:00
|
|
|
*vpp = CTOV(cp);
|
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
coda_vptofh(struct vnode *vnp, struct fid *fidp)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
ENTRY;
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-09-12 19:05:47 +04:00
|
|
|
coda_init(void)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
ENTRY;
|
|
|
|
}
|
|
|
|
|
2000-03-16 21:08:17 +03:00
|
|
|
void
|
|
|
|
coda_done(void)
|
|
|
|
{
|
|
|
|
ENTRY;
|
|
|
|
}
|
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
SYSCTL_SETUP(sysctl_vfs_coda_setup, "sysctl vfs.coda subtree setup")
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_NODE, "vfs", NULL,
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_VFS, CTL_EOL);
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
2004-05-25 08:44:43 +04:00
|
|
|
CTLTYPE_NODE, "coda",
|
|
|
|
SYSCTL_DESCR("code vfs options"),
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_VFS, 18, CTL_EOL);
|
|
|
|
/*
|
|
|
|
* XXX the "18" above could be dynamic, thereby eliminating
|
|
|
|
* one more instance of the "number to vfs" mapping problem,
|
|
|
|
* but "18" is the order as taken from sys/mount.h
|
|
|
|
*/
|
1998-08-30 01:26:45 +04:00
|
|
|
|
|
|
|
/*
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
|
2004-05-25 08:44:43 +04:00
|
|
|
CTLTYPE_INT, "clusterread",
|
|
|
|
SYSCTL_DESCR( anyone? ),
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
NULL, 0, &doclusterread, 0,
|
|
|
|
CTL_VFS, 18, FFS_CLUSTERREAD, CTL_EOL);
|
|
|
|
*/
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To allow for greater ease of use, some vnodes may be orphaned when
|
|
|
|
* Venus dies. Certain operations should still be allowed to go
|
2004-03-09 06:14:09 +03:00
|
|
|
* through, but without propagating orphan-ness. So this function will
|
|
|
|
* get a new vnode for the file from the current run of Venus.
|
|
|
|
*/
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
int
|
2005-08-31 02:24:11 +04:00
|
|
|
getNewVnode(struct vnode **vpp)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
struct cfid cfid;
|
1998-09-12 19:05:47 +04:00
|
|
|
struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
ENTRY;
|
|
|
|
|
2003-08-27 21:49:48 +04:00
|
|
|
cfid.cfid_len = (short)sizeof(CodaFid);
|
1998-08-30 01:26:45 +04:00
|
|
|
cfid.cfid_fid = VTOC(*vpp)->c_fid; /* Structure assignment. */
|
|
|
|
/* XXX ? */
|
|
|
|
|
|
|
|
/* We're guessing that if set, the 1st element on the list is a
|
|
|
|
* valid vnode to use. If not, return ENODEV as venus is dead.
|
|
|
|
*/
|
|
|
|
if (mi->mi_vfsp == NULL)
|
|
|
|
return ENODEV;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-09-12 19:05:47 +04:00
|
|
|
return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
|
2003-06-29 22:43:21 +04:00
|
|
|
NULL, NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <ufs/ufs/quota.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
2005-02-27 01:58:54 +03:00
|
|
|
/* get the mount structure corresponding to a given device. Assume
|
1998-08-30 01:26:45 +04:00
|
|
|
* device corresponds to a UFS. Return NULL if no device is found.
|
2005-02-27 01:58:54 +03:00
|
|
|
*/
|
2005-08-31 02:24:11 +04:00
|
|
|
struct mount *devtomp(dev_t dev)
|
1998-08-30 01:26:45 +04:00
|
|
|
{
|
|
|
|
struct mount *mp, *nmp;
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1998-08-30 01:26:45 +04:00
|
|
|
for (mp = mountlist.cqh_first; mp != (void*)&mountlist; mp = nmp) {
|
|
|
|
nmp = mp->mnt_list.cqe_next;
|
1998-09-08 21:12:46 +04:00
|
|
|
if ((!strcmp(mp->mnt_op->vfs_name, MOUNT_UFS)) &&
|
1998-08-30 01:26:45 +04:00
|
|
|
((VFSTOUFS(mp))->um_dev == (dev_t) dev)) {
|
|
|
|
/* mount corresponds to UFS and the device matches one we want */
|
2005-02-27 01:58:54 +03:00
|
|
|
return(mp);
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
/* mount structure wasn't found */
|
|
|
|
return(NULL);
|
1998-08-30 01:26:45 +04:00
|
|
|
}
|