2002-09-22 00:26:49 +04:00
|
|
|
/* $NetBSD: advfsops.c,v 1.56 2002/09/21 20:26:49 mycroft Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994 Christian E. Hopps
|
1996-04-05 09:06:07 +04:00
|
|
|
* Copyright (c) 1996 Matthias Scheler
|
1994-05-11 22:49:06 +04:00
|
|
|
* 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. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Christian E. Hopps.
|
|
|
|
* 4. 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.
|
|
|
|
*/
|
1998-07-05 12:49:30 +04:00
|
|
|
|
2001-11-13 01:54:03 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-09-22 00:26:49 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.56 2002/09/21 20:26:49 mycroft Exp $");
|
2001-11-13 01:54:03 +03:00
|
|
|
|
2001-05-30 15:40:35 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
1998-07-05 12:49:30 +04:00
|
|
|
#include "opt_compat_netbsd.h"
|
|
|
|
#endif
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
1994-06-18 00:06:05 +04:00
|
|
|
#include <sys/proc.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/malloc.h>
|
1998-09-01 07:33:26 +04:00
|
|
|
#include <sys/pool.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <miscfs/specfs/specdev.h> /* XXX */
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/buf.h>
|
2002-09-06 17:18:43 +04:00
|
|
|
#include <sys/conf.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <adosfs/adosfs.h>
|
|
|
|
|
1996-02-09 22:06:38 +03:00
|
|
|
void adosfs_init __P((void));
|
2001-09-15 20:12:54 +04:00
|
|
|
void adosfs_reinit __P((void));
|
2000-03-16 21:08:17 +03:00
|
|
|
void adosfs_done __P((void));
|
1996-12-22 13:10:12 +03:00
|
|
|
int adosfs_mount __P((struct mount *, const char *, void *, struct nameidata *,
|
1996-02-09 22:06:38 +03:00
|
|
|
struct proc *));
|
|
|
|
int adosfs_start __P((struct mount *, int, struct proc *));
|
|
|
|
int adosfs_unmount __P((struct mount *, int, struct proc *));
|
|
|
|
int adosfs_root __P((struct mount *, struct vnode **));
|
|
|
|
int adosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
|
|
|
|
int adosfs_statfs __P((struct mount *, struct statfs *, struct proc *));
|
|
|
|
int adosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
|
|
|
|
int adosfs_vget __P((struct mount *, ino_t, struct vnode **));
|
1999-02-27 02:44:43 +03:00
|
|
|
int adosfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
|
|
|
|
int adosfs_checkexp __P((struct mount *, struct mbuf *, int *,
|
|
|
|
struct ucred **));
|
1996-02-09 22:06:38 +03:00
|
|
|
int adosfs_vptofh __P((struct vnode *, struct fid *));
|
|
|
|
|
|
|
|
int adosfs_mountfs __P((struct vnode *, struct mount *, struct proc *));
|
1996-04-05 09:06:07 +04:00
|
|
|
int adosfs_loadbitmap __P((struct adosfsmount *));
|
1998-03-01 05:20:01 +03:00
|
|
|
int adosfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
|
|
|
|
struct proc *));
|
|
|
|
|
|
|
|
struct simplelock adosfs_hashlock;
|
1996-02-09 22:06:38 +03:00
|
|
|
|
1998-09-01 07:33:26 +04:00
|
|
|
struct pool adosfs_node_pool;
|
|
|
|
|
2001-09-30 22:47:48 +04:00
|
|
|
struct genfs_ops adosfs_genfsops = {
|
|
|
|
genfs_size,
|
|
|
|
};
|
|
|
|
|
2002-05-14 04:05:56 +04:00
|
|
|
int (**adosfs_vnodeop_p) __P((void *));
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
int
|
|
|
|
adosfs_mount(mp, path, data, ndp, p)
|
|
|
|
struct mount *mp;
|
1996-12-22 13:10:12 +03:00
|
|
|
const char *path;
|
|
|
|
void *data;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct nameidata *ndp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-01-18 12:16:37 +03:00
|
|
|
struct vnode *devvp;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct adosfs_args args;
|
1995-01-18 12:16:37 +03:00
|
|
|
struct adosfsmount *amp;
|
1995-03-09 15:05:21 +03:00
|
|
|
size_t size;
|
1994-05-11 22:49:06 +04:00
|
|
|
int error;
|
1995-01-18 12:16:37 +03:00
|
|
|
mode_t accessmode;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
2002-09-21 22:10:04 +04:00
|
|
|
if (mp->mnt_flag & MNT_GETARGS) {
|
|
|
|
amp = VFSTOADOSFS(mp);
|
|
|
|
if (amp == NULL)
|
|
|
|
return EIO;
|
|
|
|
args.uid = amp->uid;
|
|
|
|
args.gid = amp->gid;
|
|
|
|
args.mask = amp->mask;
|
|
|
|
args.fspec = NULL;
|
2002-09-22 00:26:49 +04:00
|
|
|
vfs_showexport(mp, &args.export, &->export);
|
2002-09-21 22:10:04 +04:00
|
|
|
return copyout(&args, data, sizeof(args));
|
|
|
|
}
|
1996-02-09 22:06:38 +03:00
|
|
|
error = copyin(data, (caddr_t)&args, sizeof(struct adosfs_args));
|
|
|
|
if (error)
|
1994-05-11 22:49:06 +04:00
|
|
|
return(error);
|
|
|
|
|
1995-01-18 12:16:37 +03:00
|
|
|
if ((mp->mnt_flag & MNT_RDONLY) == 0)
|
|
|
|
return (EROFS);
|
1995-08-18 19:14:33 +04:00
|
|
|
/*
|
|
|
|
* If updating, check whether changing from read-only to
|
|
|
|
* read/write; if there is no device name, that's all we do.
|
|
|
|
*/
|
|
|
|
if (mp->mnt_flag & MNT_UPDATE) {
|
|
|
|
amp = VFSTOADOSFS(mp);
|
|
|
|
if (args.fspec == 0)
|
|
|
|
return (vfs_export(mp, &->export, &args.export));
|
|
|
|
}
|
1995-01-18 12:16:37 +03:00
|
|
|
/*
|
|
|
|
* Not an update, or updating the name: look up the name
|
|
|
|
* and verify that it refers to a sensible block device.
|
1994-05-11 22:49:06 +04:00
|
|
|
*/
|
1994-06-18 00:06:05 +04:00
|
|
|
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = namei(ndp)) != 0)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
1995-01-18 12:16:37 +03:00
|
|
|
devvp = ndp->ni_vp;
|
1994-06-18 00:06:05 +04:00
|
|
|
|
1995-01-18 12:16:37 +03:00
|
|
|
if (devvp->v_type != VBLK) {
|
|
|
|
vrele(devvp);
|
1994-06-18 00:06:05 +04:00
|
|
|
return (ENOTBLK);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
2002-09-06 17:18:43 +04:00
|
|
|
if (bdevsw_lookup(devvp->v_rdev) == NULL) {
|
1995-01-18 12:16:37 +03:00
|
|
|
vrele(devvp);
|
1994-06-18 00:06:05 +04:00
|
|
|
return (ENXIO);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
1995-01-18 12:16:37 +03:00
|
|
|
/*
|
|
|
|
* If mount by non-root, then verify that user has necessary
|
|
|
|
* permissions on the device.
|
|
|
|
*/
|
|
|
|
if (p->p_ucred->cr_uid != 0) {
|
|
|
|
accessmode = VREAD;
|
|
|
|
if ((mp->mnt_flag & MNT_RDONLY) == 0)
|
|
|
|
accessmode |= VWRITE;
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
|
1996-02-09 22:06:38 +03:00
|
|
|
error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
|
|
|
|
if (error) {
|
1995-01-18 12:16:37 +03:00
|
|
|
vput(devvp);
|
|
|
|
return (error);
|
|
|
|
}
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(devvp, 0);
|
1995-01-18 12:16:37 +03:00
|
|
|
}
|
1995-08-18 19:14:33 +04:00
|
|
|
/* MNT_UPDATE? */
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = adosfs_mountfs(devvp, mp, p)) != 0) {
|
1995-01-18 12:16:37 +03:00
|
|
|
vrele(devvp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
amp = VFSTOADOSFS(mp);
|
|
|
|
amp->uid = args.uid;
|
|
|
|
amp->gid = args.gid;
|
|
|
|
amp->mask = args.mask;
|
|
|
|
(void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
|
1998-08-10 00:15:38 +04:00
|
|
|
memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
|
1995-01-18 12:16:37 +03:00
|
|
|
(void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
|
|
|
|
&size);
|
1998-08-10 00:15:38 +04:00
|
|
|
memset(mp->mnt_stat.f_mntfromname + size, 0, MNAMELEN - size);
|
1995-01-18 12:16:37 +03:00
|
|
|
return (0);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-01-18 12:16:37 +03:00
|
|
|
adosfs_mountfs(devvp, mp, p)
|
|
|
|
struct vnode *devvp;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct mount *mp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct disklabel dl;
|
|
|
|
struct partition *parp;
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1996-04-05 09:06:07 +04:00
|
|
|
struct buf *bp;
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vnode *rvp;
|
1995-03-08 04:26:41 +03:00
|
|
|
int error, part, i;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
1995-01-18 12:16:37 +03:00
|
|
|
part = DISKPART(devvp->v_rdev);
|
1994-06-18 00:06:05 +04:00
|
|
|
amp = NULL;
|
1995-01-18 12:16:37 +03:00
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
/*
|
1995-01-18 12:16:37 +03:00
|
|
|
* Disallow multiple mounts of the same device.
|
|
|
|
* Disallow mounting of a device that is currently in use
|
|
|
|
* (except for root, which might share swap device for miniroot).
|
|
|
|
* Flush out any old buffers remaining from a previous use.
|
1994-05-11 22:49:06 +04:00
|
|
|
*/
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = vfs_mountedon(devvp)) != 0)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
1995-01-18 12:16:37 +03:00
|
|
|
if (vcount(devvp) > 1 && devvp != rootvp)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (EBUSY);
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
/*
|
1994-06-18 00:06:05 +04:00
|
|
|
* open blkdev and read root block
|
1994-05-11 22:49:06 +04:00
|
|
|
*/
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = VOP_OPEN(devvp, FREAD, NOCRED, p)) != 0)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
1996-02-09 22:06:38 +03:00
|
|
|
error = VOP_IOCTL(devvp, DIOCGDINFO,(caddr_t)&dl, FREAD, NOCRED, p);
|
|
|
|
if (error)
|
1994-05-11 22:49:06 +04:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
parp = &dl.d_partitions[part];
|
1995-01-18 12:17:32 +03:00
|
|
|
amp = malloc(sizeof(struct adosfsmount), M_ADOSFSMNT, M_WAITOK);
|
1998-08-10 00:15:38 +04:00
|
|
|
memset((char *)amp, 0, (u_long)sizeof(struct adosfsmount));
|
1994-05-11 22:49:06 +04:00
|
|
|
amp->mp = mp;
|
1996-04-05 09:06:07 +04:00
|
|
|
if (dl.d_type == DTYPE_FLOPPY) {
|
|
|
|
amp->bsize = dl.d_secsize;
|
|
|
|
amp->secsperblk = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
amp->bsize = parp->p_fsize * parp->p_frag;
|
|
|
|
amp->secsperblk = parp->p_frag;
|
|
|
|
}
|
2000-11-08 11:06:24 +03:00
|
|
|
|
|
|
|
/* invalid fs ? */
|
|
|
|
if (amp->secsperblk == 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
1996-04-05 09:06:07 +04:00
|
|
|
|
|
|
|
bp = NULL;
|
|
|
|
if ((error = bread(devvp, (daddr_t)BBOFF,
|
1999-02-10 16:14:08 +03:00
|
|
|
amp->bsize, NOCRED, &bp)) != 0) {
|
|
|
|
brelse(bp);
|
1996-04-05 09:06:07 +04:00
|
|
|
goto fail;
|
1999-02-10 16:14:08 +03:00
|
|
|
}
|
1996-04-05 09:06:07 +04:00
|
|
|
amp->dostype = adoswordn(bp, 0);
|
|
|
|
brelse(bp);
|
|
|
|
|
2000-11-08 11:06:24 +03:00
|
|
|
/* basic sanity checks */
|
1996-04-05 09:06:07 +04:00
|
|
|
if (amp->dostype < 0x444f5300 || amp->dostype > 0x444f5305) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2000-11-08 11:06:24 +03:00
|
|
|
amp->rootb = (parp->p_size / amp->secsperblk - 1 + parp->p_cpg) >> 1;
|
|
|
|
amp->numblks = parp->p_size / amp->secsperblk - parp->p_cpg;
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
amp->nwords = amp->bsize >> 2;
|
1996-04-05 09:06:07 +04:00
|
|
|
amp->dbsize = amp->bsize - (IS_FFS(amp) ? 0 : OFS_DATA_OFFSET);
|
1995-01-18 12:16:37 +03:00
|
|
|
amp->devvp = devvp;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
2002-07-30 11:40:07 +04:00
|
|
|
mp->mnt_data = amp;
|
1995-01-18 12:16:37 +03:00
|
|
|
mp->mnt_stat.f_fsid.val[0] = (long)devvp->v_rdev;
|
1994-05-11 22:49:06 +04:00
|
|
|
mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_ADOSFS);
|
2001-04-03 09:40:27 +04:00
|
|
|
mp->mnt_fs_bshift = ffs(amp->bsize) - 1;
|
|
|
|
mp->mnt_dev_bshift = DEV_BSHIFT; /* XXX */
|
1995-01-18 12:16:37 +03:00
|
|
|
mp->mnt_flag |= MNT_LOCAL;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* init anode table.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ANODEHASHSZ; i++)
|
|
|
|
LIST_INIT(&->anodetab[i]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get the root anode, if not a valid fs this will fail.
|
|
|
|
*/
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = VFS_ROOT(mp, &rvp)) != 0)
|
1994-05-11 22:49:06 +04:00
|
|
|
goto fail;
|
1996-04-05 09:06:07 +04:00
|
|
|
/* allocate and load bitmap, set free space */
|
|
|
|
amp->bitmap = malloc(((amp->numblks + 31) / 32) * sizeof(*amp->bitmap),
|
|
|
|
M_ADOSFSBITMAP, M_WAITOK);
|
|
|
|
if (amp->bitmap)
|
|
|
|
adosfs_loadbitmap(amp);
|
|
|
|
if (mp->mnt_flag & MNT_RDONLY && amp->bitmap) {
|
|
|
|
/*
|
|
|
|
* Don't need the bitmap any more if it's read-only.
|
|
|
|
*/
|
|
|
|
free(amp->bitmap, M_ADOSFSBITMAP);
|
|
|
|
amp->bitmap = NULL;
|
|
|
|
}
|
1994-06-18 00:06:05 +04:00
|
|
|
vput(rvp);
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
return(0);
|
1995-01-18 12:16:37 +03:00
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
fail:
|
1999-10-18 23:52:24 +04:00
|
|
|
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
|
1995-01-18 12:16:37 +03:00
|
|
|
(void) VOP_CLOSE(devvp, FREAD, NOCRED, p);
|
1999-10-18 23:52:24 +04:00
|
|
|
VOP_UNLOCK(devvp, 0);
|
1996-04-05 09:06:07 +04:00
|
|
|
if (amp && amp->bitmap)
|
|
|
|
free(amp->bitmap, M_ADOSFSBITMAP);
|
1994-06-18 00:06:05 +04:00
|
|
|
if (amp)
|
|
|
|
free(amp, M_ADOSFSMNT);
|
1995-01-18 12:16:37 +03:00
|
|
|
return (error);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
adosfs_start(mp, flags, p)
|
|
|
|
struct mount *mp;
|
|
|
|
int flags;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-01-18 12:16:37 +03:00
|
|
|
|
|
|
|
return (0);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-01-18 12:16:37 +03:00
|
|
|
adosfs_unmount(mp, mntflags, p)
|
1994-05-11 22:49:06 +04:00
|
|
|
struct mount *mp;
|
1995-01-18 12:16:37 +03:00
|
|
|
int mntflags;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1995-01-18 12:16:37 +03:00
|
|
|
int error, flags;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
1995-01-18 12:16:37 +03:00
|
|
|
flags = 0;
|
|
|
|
if (mntflags & MNT_FORCE)
|
|
|
|
flags |= FORCECLOSE;
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = vflush(mp, NULLVP, flags)) != 0)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
1995-01-18 12:16:37 +03:00
|
|
|
amp = VFSTOADOSFS(mp);
|
1999-10-20 18:32:09 +04:00
|
|
|
if (amp->devvp->v_type != VBAD)
|
1999-11-15 23:55:48 +03:00
|
|
|
amp->devvp->v_specmountpoint = NULL;
|
1999-10-17 03:53:26 +04:00
|
|
|
vn_lock(amp->devvp, LK_EXCLUSIVE | LK_RETRY);
|
1995-01-18 12:16:37 +03:00
|
|
|
error = VOP_CLOSE(amp->devvp, FREAD, NOCRED, p);
|
1999-10-17 03:53:26 +04:00
|
|
|
vput(amp->devvp);
|
1996-04-05 09:06:07 +04:00
|
|
|
if (amp->bitmap)
|
|
|
|
free(amp->bitmap, M_ADOSFSBITMAP);
|
1994-05-11 22:49:06 +04:00
|
|
|
free(amp, M_ADOSFSMNT);
|
2002-07-30 11:40:07 +04:00
|
|
|
mp->mnt_data = NULL;
|
1994-06-18 00:06:05 +04:00
|
|
|
mp->mnt_flag &= ~MNT_LOCAL;
|
|
|
|
return (error);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
adosfs_root(mp, vpp)
|
|
|
|
struct mount *mp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vnode *nvp;
|
|
|
|
int error;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = VFS_VGET(mp, (ino_t)VFSTOADOSFS(mp)->rootb, &nvp)) != 0)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
1996-04-05 09:06:07 +04:00
|
|
|
/* XXX verify it's a root block? */
|
1994-06-18 00:06:05 +04:00
|
|
|
*vpp = nvp;
|
|
|
|
return (0);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
adosfs_statfs(mp, sbp, p)
|
|
|
|
struct mount *mp;
|
|
|
|
struct statfs *sbp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1995-01-18 12:16:37 +03:00
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
amp = VFSTOADOSFS(mp);
|
1998-03-01 05:20:01 +03:00
|
|
|
#ifdef COMPAT_09
|
|
|
|
sbp->f_type = 16;
|
|
|
|
#else
|
1994-05-11 22:49:06 +04:00
|
|
|
sbp->f_type = 0;
|
1998-03-01 05:20:01 +03:00
|
|
|
#endif
|
1994-05-11 22:49:06 +04:00
|
|
|
sbp->f_bsize = amp->bsize;
|
1996-04-05 09:06:07 +04:00
|
|
|
sbp->f_iosize = amp->dbsize;
|
|
|
|
sbp->f_blocks = amp->numblks;
|
|
|
|
sbp->f_bfree = amp->freeblks;
|
|
|
|
sbp->f_bavail = amp->freeblks;
|
1994-05-11 22:49:06 +04:00
|
|
|
sbp->f_files = 0; /* who knows */
|
|
|
|
sbp->f_ffree = 0; /* " " */
|
|
|
|
if (sbp != &mp->mnt_stat) {
|
1998-08-10 00:15:38 +04:00
|
|
|
memcpy(sbp->f_mntonname, mp->mnt_stat.f_mntonname, MNAMELEN);
|
|
|
|
memcpy(sbp->f_mntfromname, mp->mnt_stat.f_mntfromname, MNAMELEN);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
|
1995-01-18 12:16:37 +03:00
|
|
|
return (0);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
/*
|
|
|
|
* lookup an anode, check mount's hash table if not found, create
|
|
|
|
* return locked and referenced al la vget(vp, 1);
|
|
|
|
*/
|
1994-05-11 22:49:06 +04:00
|
|
|
int
|
1994-06-18 00:06:05 +04:00
|
|
|
adosfs_vget(mp, an, vpp)
|
1994-05-11 22:49:06 +04:00
|
|
|
struct mount *mp;
|
1994-06-18 00:06:05 +04:00
|
|
|
ino_t an;
|
|
|
|
struct vnode **vpp;
|
1994-05-11 22:49:06 +04:00
|
|
|
{
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vnode *vp;
|
|
|
|
struct anode *ap;
|
|
|
|
struct buf *bp;
|
|
|
|
char *nam, *tmp;
|
1996-04-05 09:06:07 +04:00
|
|
|
int namlen, error;
|
1994-06-18 00:06:05 +04:00
|
|
|
|
|
|
|
error = 0;
|
|
|
|
amp = VFSTOADOSFS(mp);
|
|
|
|
bp = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check hash table. we are done if found
|
|
|
|
*/
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((*vpp = adosfs_ahashget(mp, an)) != NULL)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (0);
|
|
|
|
|
1996-02-09 22:06:38 +03:00
|
|
|
error = getnewvnode(VT_ADOSFS, mp, adosfs_vnodeop_p, &vp);
|
|
|
|
if (error)
|
1994-06-18 00:06:05 +04:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* setup, insert in hash, and lock before io.
|
|
|
|
*/
|
1998-09-01 07:33:26 +04:00
|
|
|
vp->v_data = ap = pool_get(&adosfs_node_pool, PR_WAITOK);
|
1998-08-10 00:15:38 +04:00
|
|
|
memset(ap, 0, sizeof(struct anode));
|
1994-06-18 00:06:05 +04:00
|
|
|
ap->vp = vp;
|
|
|
|
ap->amp = amp;
|
|
|
|
ap->block = an;
|
|
|
|
ap->nwords = amp->nwords;
|
|
|
|
adosfs_ainshash(amp, ap);
|
|
|
|
|
1999-06-03 02:04:30 +04:00
|
|
|
if ((error = bread(amp->devvp, an * amp->bsize / DEV_BSIZE,
|
1996-04-05 09:06:07 +04:00
|
|
|
amp->bsize, NOCRED, &bp)) != 0) {
|
1999-02-10 16:14:08 +03:00
|
|
|
brelse(bp);
|
1994-06-18 00:06:05 +04:00
|
|
|
vput(vp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get type and fill rest in based on that.
|
|
|
|
*/
|
|
|
|
switch (ap->type = adosfs_getblktype(amp, bp)) {
|
|
|
|
case AROOT:
|
|
|
|
vp->v_type = VDIR;
|
|
|
|
vp->v_flag |= VROOT;
|
|
|
|
ap->mtimev.days = adoswordn(bp, ap->nwords - 10);
|
|
|
|
ap->mtimev.mins = adoswordn(bp, ap->nwords - 9);
|
|
|
|
ap->mtimev.ticks = adoswordn(bp, ap->nwords - 8);
|
|
|
|
ap->created.days = adoswordn(bp, ap->nwords - 7);
|
|
|
|
ap->created.mins = adoswordn(bp, ap->nwords - 6);
|
|
|
|
ap->created.ticks = adoswordn(bp, ap->nwords - 5);
|
|
|
|
break;
|
|
|
|
case ALDIR:
|
|
|
|
case ADIR:
|
|
|
|
vp->v_type = VDIR;
|
|
|
|
break;
|
|
|
|
case ALFILE:
|
|
|
|
case AFILE:
|
|
|
|
vp->v_type = VREG;
|
|
|
|
ap->fsize = adoswordn(bp, ap->nwords - 47);
|
|
|
|
break;
|
|
|
|
case ASLINK: /* XXX soft link */
|
|
|
|
vp->v_type = VLNK;
|
|
|
|
/*
|
|
|
|
* convert from BCPL string and
|
|
|
|
* from: "part:dir/file" to: "/part/dir/file"
|
|
|
|
*/
|
|
|
|
nam = bp->b_data + (6 * sizeof(long));
|
1996-04-05 09:06:07 +04:00
|
|
|
namlen = strlen(nam);
|
1994-06-18 00:06:05 +04:00
|
|
|
tmp = nam;
|
1996-04-05 09:06:07 +04:00
|
|
|
while (*tmp && *tmp != ':')
|
1994-06-18 00:06:05 +04:00
|
|
|
tmp++;
|
|
|
|
if (*tmp == 0) {
|
|
|
|
ap->slinkto = malloc(namlen + 1, M_ANODE, M_WAITOK);
|
1998-08-10 00:15:38 +04:00
|
|
|
memcpy(ap->slinkto, nam, namlen);
|
1994-06-18 00:06:05 +04:00
|
|
|
} else if (*nam == ':') {
|
|
|
|
ap->slinkto = malloc(namlen + 1, M_ANODE, M_WAITOK);
|
1998-08-10 00:15:38 +04:00
|
|
|
memcpy(ap->slinkto, nam, namlen);
|
1994-06-18 00:06:05 +04:00
|
|
|
ap->slinkto[0] = '/';
|
|
|
|
} else {
|
|
|
|
ap->slinkto = malloc(namlen + 2, M_ANODE, M_WAITOK);
|
|
|
|
ap->slinkto[0] = '/';
|
1998-08-10 00:15:38 +04:00
|
|
|
memcpy(&ap->slinkto[1], nam, namlen);
|
1994-06-18 00:06:05 +04:00
|
|
|
ap->slinkto[tmp - nam + 1] = '/';
|
|
|
|
namlen++;
|
|
|
|
}
|
|
|
|
ap->slinkto[namlen] = 0;
|
1996-04-28 10:18:12 +04:00
|
|
|
ap->fsize = namlen;
|
1994-06-18 00:06:05 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
brelse(bp);
|
|
|
|
vput(vp);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
1996-04-05 09:06:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get appropriate data from this block; hard link needs
|
|
|
|
* to get other data from the "real" block.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* copy in name (from original block)
|
|
|
|
*/
|
1996-10-09 02:18:02 +04:00
|
|
|
nam = bp->b_data + (ap->nwords - 20) * sizeof(u_int32_t);
|
1996-04-05 09:06:07 +04:00
|
|
|
namlen = *(u_char *)nam++;
|
|
|
|
if (namlen > 30) {
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adosfs: aget: name length too long blk %d\n", an);
|
1996-04-05 09:06:07 +04:00
|
|
|
#endif
|
|
|
|
brelse(bp);
|
|
|
|
vput(vp);
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
1998-08-10 00:15:38 +04:00
|
|
|
memcpy(ap->name, nam, namlen);
|
1996-04-05 09:06:07 +04:00
|
|
|
ap->name[namlen] = 0;
|
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
/*
|
|
|
|
* if dir alloc hash table and copy it in
|
|
|
|
*/
|
|
|
|
if (vp->v_type == VDIR) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ap->tab = malloc(ANODETABSZ(ap) * 2, M_ANODE, M_WAITOK);
|
|
|
|
ap->ntabent = ANODETABENT(ap);
|
|
|
|
ap->tabi = (int *)&ap->tab[ap->ntabent];
|
1998-08-10 00:15:38 +04:00
|
|
|
memset(ap->tabi, 0, ANODETABSZ(ap));
|
1994-06-18 00:06:05 +04:00
|
|
|
for (i = 0; i < ap->ntabent; i++)
|
|
|
|
ap->tab[i] = adoswordn(bp, i + 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* misc.
|
|
|
|
*/
|
|
|
|
ap->pblock = adoswordn(bp, ap->nwords - 3);
|
|
|
|
ap->hashf = adoswordn(bp, ap->nwords - 4);
|
|
|
|
ap->linknext = adoswordn(bp, ap->nwords - 10);
|
|
|
|
ap->linkto = adoswordn(bp, ap->nwords - 11);
|
1994-07-11 09:07:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* setup last indirect block cache.
|
|
|
|
*/
|
|
|
|
ap->lastlindblk = 0;
|
1996-04-05 09:06:07 +04:00
|
|
|
if (ap->type == AFILE) {
|
1994-07-11 09:07:38 +04:00
|
|
|
ap->lastindblk = ap->block;
|
1996-04-05 09:06:07 +04:00
|
|
|
if (adoswordn(bp, ap->nwords - 10))
|
|
|
|
ap->linkto = ap->block;
|
|
|
|
} else if (ap->type == ALFILE) {
|
1994-07-11 09:07:38 +04:00
|
|
|
ap->lastindblk = ap->linkto;
|
1996-04-05 09:06:07 +04:00
|
|
|
brelse(bp);
|
|
|
|
bp = NULL;
|
1999-06-03 02:04:30 +04:00
|
|
|
error = bread(amp->devvp, ap->linkto * amp->bsize / DEV_BSIZE,
|
1996-04-05 09:06:07 +04:00
|
|
|
amp->bsize, NOCRED, &bp);
|
1999-02-10 16:14:08 +03:00
|
|
|
if (error) {
|
|
|
|
brelse(bp);
|
|
|
|
vput(vp);
|
|
|
|
return (error);
|
|
|
|
}
|
1996-04-05 09:06:07 +04:00
|
|
|
ap->fsize = adoswordn(bp, ap->nwords - 47);
|
|
|
|
/*
|
|
|
|
* Should ap->block be set to the real file header block?
|
|
|
|
*/
|
|
|
|
ap->block = ap->linkto;
|
|
|
|
}
|
1994-07-11 09:07:38 +04:00
|
|
|
|
1994-12-28 11:51:56 +03:00
|
|
|
if (ap->type == AROOT) {
|
1996-04-05 09:06:07 +04:00
|
|
|
ap->adprot = 15;
|
1994-12-28 11:51:56 +03:00
|
|
|
ap->uid = amp->uid;
|
|
|
|
ap->gid = amp->gid;
|
|
|
|
} else {
|
1996-04-05 09:06:07 +04:00
|
|
|
ap->adprot = adoswordn(bp, ap->nwords - 48) ^ 15;
|
1997-06-27 01:04:32 +04:00
|
|
|
/*
|
|
|
|
* ADOS directories do not have a `x' protection bit as
|
|
|
|
* it is known in VFS; this functionality is fulfilled
|
|
|
|
* by the ADOS `r' bit.
|
|
|
|
*
|
|
|
|
* To retain the ADOS behaviour, fake execute permissions
|
|
|
|
* in that case.
|
|
|
|
*/
|
1997-07-08 13:11:29 +04:00
|
|
|
if ((ap->type == ADIR || ap->type == ALDIR) &&
|
|
|
|
(ap->adprot & 0x00000008) == 0)
|
|
|
|
ap->adprot &= ~0x00000002;
|
1997-06-27 01:04:32 +04:00
|
|
|
|
1994-12-28 11:51:56 +03:00
|
|
|
/*
|
|
|
|
* Get uid/gid from extensions in file header
|
|
|
|
* (really need to know if this is a muFS partition)
|
|
|
|
*/
|
|
|
|
ap->uid = (adoswordn(bp, ap->nwords - 49) >> 16) & 0xffff;
|
|
|
|
ap->gid = adoswordn(bp, ap->nwords - 49) & 0xffff;
|
|
|
|
if (ap->uid || ap->gid) {
|
|
|
|
if (ap->uid == 0xffff)
|
|
|
|
ap->uid = 0;
|
|
|
|
if (ap->gid == 0xffff)
|
|
|
|
ap->gid = 0;
|
|
|
|
ap->adprot |= 0x40000000; /* Kludge */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* uid & gid extension don't exist,
|
|
|
|
* so use the mount-point uid/gid
|
|
|
|
*/
|
|
|
|
ap->uid = amp->uid;
|
|
|
|
ap->gid = amp->gid;
|
|
|
|
}
|
|
|
|
}
|
1994-06-18 00:06:05 +04:00
|
|
|
ap->mtime.days = adoswordn(bp, ap->nwords - 23);
|
|
|
|
ap->mtime.mins = adoswordn(bp, ap->nwords - 22);
|
|
|
|
ap->mtime.ticks = adoswordn(bp, ap->nwords - 21);
|
|
|
|
|
2001-09-30 22:47:48 +04:00
|
|
|
genfs_node_init(vp, &adosfs_genfsops);
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
*vpp = vp;
|
|
|
|
brelse(bp);
|
|
|
|
vp->v_size = ap->fsize;
|
1994-06-18 00:06:05 +04:00
|
|
|
return (0);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
1996-04-05 09:06:07 +04:00
|
|
|
/*
|
|
|
|
* Load the bitmap into memory, and count the number of available
|
|
|
|
* blocks.
|
|
|
|
* The bitmap will be released if the filesystem is read-only; it's
|
|
|
|
* only needed to find the free space.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
adosfs_loadbitmap(amp)
|
|
|
|
struct adosfsmount *amp;
|
|
|
|
{
|
|
|
|
struct buf *bp, *mapbp;
|
|
|
|
u_long bn;
|
|
|
|
int blkix, endix, mapix;
|
|
|
|
int bmsize;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
bp = mapbp = NULL;
|
|
|
|
bn = amp->rootb;
|
1999-06-03 02:04:30 +04:00
|
|
|
if ((error = bread(amp->devvp, bn * amp->bsize / DEV_BSIZE, amp->bsize,
|
1999-02-10 16:14:08 +03:00
|
|
|
NOCRED, &bp)) != 0) {
|
|
|
|
brelse(bp);
|
1996-04-05 09:06:07 +04:00
|
|
|
return (error);
|
1999-02-10 16:14:08 +03:00
|
|
|
}
|
1996-04-05 09:06:07 +04:00
|
|
|
blkix = amp->nwords - 49;
|
|
|
|
endix = amp->nwords - 24;
|
|
|
|
mapix = 0;
|
|
|
|
bmsize = (amp->numblks + 31) / 32;
|
|
|
|
while (mapix < bmsize) {
|
|
|
|
int n;
|
|
|
|
u_long bits;
|
|
|
|
|
|
|
|
if (adoswordn(bp, blkix) == 0)
|
|
|
|
break;
|
|
|
|
if (mapbp != NULL)
|
|
|
|
brelse(mapbp);
|
|
|
|
if ((error = bread(amp->devvp,
|
1999-06-03 02:04:30 +04:00
|
|
|
adoswordn(bp, blkix) * amp->bsize / DEV_BSIZE, amp->bsize,
|
1996-04-05 09:06:07 +04:00
|
|
|
NOCRED, &mapbp)) != 0)
|
|
|
|
break;
|
|
|
|
if (adoscksum(mapbp, amp->nwords)) {
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adosfs: loadbitmap - cksum of blk %d failed\n",
|
1996-10-10 21:47:29 +04:00
|
|
|
adoswordn(bp, blkix));
|
1996-04-05 09:06:07 +04:00
|
|
|
#endif
|
|
|
|
/* XXX Force read-only? Set free space 0? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
n = 1;
|
|
|
|
while (n < amp->nwords && mapix < bmsize) {
|
|
|
|
amp->bitmap[mapix++] = bits = adoswordn(mapbp, n);
|
|
|
|
++n;
|
|
|
|
if (mapix == bmsize && amp->numblks & 31)
|
|
|
|
bits &= ~(0xffffffff << (amp->numblks & 31));
|
|
|
|
while (bits) {
|
|
|
|
if (bits & 1)
|
|
|
|
++amp->freeblks;
|
|
|
|
bits >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++blkix;
|
|
|
|
if (mapix < bmsize && blkix == endix) {
|
|
|
|
bn = adoswordn(bp, blkix);
|
|
|
|
brelse(bp);
|
1999-06-03 02:04:30 +04:00
|
|
|
if ((error = bread(amp->devvp, bn * amp->bsize / DEV_BSIZE,
|
1996-04-05 09:06:07 +04:00
|
|
|
amp->bsize, NOCRED, &bp)) != 0)
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* Why is there no checksum on these blocks?
|
|
|
|
*/
|
|
|
|
blkix = 0;
|
|
|
|
endix = amp->nwords - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bp)
|
|
|
|
brelse(bp);
|
|
|
|
if (mapbp)
|
|
|
|
brelse(mapbp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1995-08-18 19:14:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* File handle to vnode
|
|
|
|
*
|
|
|
|
* Have to be really careful about stale file handles:
|
|
|
|
* - check that the inode number is in range
|
|
|
|
* - call iget() to get the locked inode
|
|
|
|
* - check for an unallocated inode (i_mode == 0)
|
|
|
|
* - check that the generation number matches
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ifid {
|
|
|
|
ushort ifid_len;
|
|
|
|
ushort ifid_pad;
|
|
|
|
int ifid_ino;
|
|
|
|
long ifid_start;
|
|
|
|
};
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
int
|
1999-02-27 02:44:43 +03:00
|
|
|
adosfs_fhtovp(mp, fhp, vpp)
|
1994-05-11 22:49:06 +04:00
|
|
|
struct mount *mp;
|
|
|
|
struct fid *fhp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
1995-08-18 19:14:33 +04:00
|
|
|
struct ifid *ifhp = (struct ifid *)fhp;
|
1996-02-09 22:06:38 +03:00
|
|
|
#if 0
|
1995-08-18 19:14:33 +04:00
|
|
|
struct anode *ap;
|
1996-02-09 22:06:38 +03:00
|
|
|
#endif
|
1995-08-18 19:14:33 +04:00
|
|
|
struct vnode *nvp;
|
|
|
|
int error;
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adfhtovp(%x, %x, %x)\n", mp, fhp, vpp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1995-08-18 19:14:33 +04:00
|
|
|
|
1996-02-09 22:06:38 +03:00
|
|
|
if ((error = VFS_VGET(mp, ifhp->ifid_ino, &nvp)) != 0) {
|
1995-08-18 19:14:33 +04:00
|
|
|
*vpp = NULLVP;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
ap = VTOA(nvp);
|
|
|
|
if (ap->inode.iso_mode == 0) {
|
|
|
|
vput(nvp);
|
|
|
|
*vpp = NULLVP;
|
|
|
|
return (ESTALE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*vpp = nvp;
|
1999-02-27 02:44:43 +03:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
adosfs_checkexp(mp, nam, exflagsp, credanonp)
|
|
|
|
struct mount *mp;
|
|
|
|
struct mbuf *nam;
|
|
|
|
int *exflagsp;
|
|
|
|
struct ucred **credanonp;
|
|
|
|
{
|
|
|
|
struct adosfsmount *amp = VFSTOADOSFS(mp);
|
|
|
|
#if 0
|
|
|
|
struct anode *ap;
|
|
|
|
#endif
|
|
|
|
struct netcred *np;
|
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
|
|
|
printf("adcheckexp(%x, %x, %x)\n", mp, nam, exflagsp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the export permission structure for this <mp, client> tuple.
|
|
|
|
*/
|
|
|
|
np = vfs_export_lookup(mp, &->export, nam);
|
|
|
|
if (np == NULL)
|
|
|
|
return (EACCES);
|
|
|
|
|
1995-08-18 19:14:33 +04:00
|
|
|
*exflagsp = np->netc_exflags;
|
|
|
|
*credanonp = &np->netc_anon;
|
1994-05-11 22:49:06 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
adosfs_vptofh(vp, fhp)
|
|
|
|
struct vnode *vp;
|
|
|
|
struct fid *fhp;
|
|
|
|
{
|
1995-08-18 19:14:33 +04:00
|
|
|
struct anode *ap = VTOA(vp);
|
|
|
|
struct ifid *ifhp;
|
|
|
|
|
|
|
|
ifhp = (struct ifid *)fhp;
|
|
|
|
ifhp->ifid_len = sizeof(struct ifid);
|
|
|
|
|
|
|
|
ifhp->ifid_ino = ap->block;
|
|
|
|
ifhp->ifid_start = ap->block;
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("advptofh(%x, %x)\n", vp, fhp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-06-18 00:06:05 +04:00
|
|
|
adosfs_quotactl(mp, cmds, uid, arg, p)
|
|
|
|
struct mount *mp;
|
|
|
|
int cmds;
|
|
|
|
uid_t uid;
|
|
|
|
caddr_t arg;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
return(EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_sync(mp, waitfor, uc, p)
|
1994-06-18 00:06:05 +04:00
|
|
|
struct mount *mp;
|
|
|
|
int waitfor;
|
1996-02-09 22:06:38 +03:00
|
|
|
struct ucred *uc;
|
|
|
|
struct proc *p;
|
1994-05-11 22:49:06 +04:00
|
|
|
{
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("ad_sync(%x, %x)\n", mp, waitfor);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1996-02-09 22:06:38 +03:00
|
|
|
void
|
1994-06-18 00:06:05 +04:00
|
|
|
adosfs_init()
|
|
|
|
{
|
1998-03-01 05:20:01 +03:00
|
|
|
simple_lock_init(&adosfs_hashlock);
|
1998-09-01 07:33:26 +04:00
|
|
|
|
|
|
|
pool_init(&adosfs_node_pool, sizeof(struct anode), 0, 0, 0,
|
2002-03-08 23:48:27 +03:00
|
|
|
"adosndpl", &pool_allocator_nointr);
|
1998-03-01 05:20:01 +03:00
|
|
|
}
|
|
|
|
|
2000-03-16 21:08:17 +03:00
|
|
|
void
|
|
|
|
adosfs_done()
|
|
|
|
{
|
|
|
|
pool_destroy(&adosfs_node_pool);
|
|
|
|
}
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
int
|
|
|
|
adosfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
|
|
|
int *name;
|
|
|
|
u_int namelen;
|
|
|
|
void *oldp;
|
|
|
|
size_t *oldlenp;
|
|
|
|
void *newp;
|
|
|
|
size_t newlen;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
return (EOPNOTSUPP);
|
1994-06-18 00:06:05 +04:00
|
|
|
}
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
/*
|
|
|
|
* vfs generic function call table
|
|
|
|
*/
|
1998-02-18 10:05:47 +03:00
|
|
|
|
2001-01-22 15:17:35 +03:00
|
|
|
extern const struct vnodeopv_desc adosfs_vnodeop_opv_desc;
|
1998-02-18 10:05:47 +03:00
|
|
|
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc *adosfs_vnodeopv_descs[] = {
|
1998-02-18 10:05:47 +03:00
|
|
|
&adosfs_vnodeop_opv_desc,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
struct vfsops adosfs_vfsops = {
|
|
|
|
MOUNT_ADOSFS,
|
|
|
|
adosfs_mount,
|
|
|
|
adosfs_start,
|
|
|
|
adosfs_unmount,
|
|
|
|
adosfs_root,
|
|
|
|
adosfs_quotactl,
|
|
|
|
adosfs_statfs,
|
|
|
|
adosfs_sync,
|
1994-06-18 00:06:05 +04:00
|
|
|
adosfs_vget,
|
1994-05-11 22:49:06 +04:00
|
|
|
adosfs_fhtovp,
|
|
|
|
adosfs_vptofh,
|
|
|
|
adosfs_init,
|
2001-09-15 20:12:54 +04:00
|
|
|
NULL,
|
2000-03-16 21:08:17 +03:00
|
|
|
adosfs_done,
|
1998-03-01 05:20:01 +03:00
|
|
|
adosfs_sysctl,
|
1998-02-18 10:05:47 +03:00
|
|
|
NULL, /* vfs_mountroot */
|
1999-02-27 02:44:43 +03:00
|
|
|
adosfs_checkexp,
|
1998-02-18 10:05:47 +03:00
|
|
|
adosfs_vnodeopv_descs,
|
|
|
|
};
|