1999-12-03 20:37:40 +00:00
|
|
|
/* $NetBSD: ntfs_vfsops.c,v 1.23 1999/11/15 19:38:14 jdolecek Exp $ */
|
1999-05-12 09:43:09 +00:00
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998, 1999 Semen Ustimenko
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1999-02-03 04:07:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1999-02-03 04:07:38 +00:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/malloc.h>
|
1999-12-03 20:37:40 +00:00
|
|
|
#include <sys/systm.h>
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2004-11-03 21:36:41 +00:00
|
|
|
#include <geom/geom.h>
|
|
|
|
#include <geom/geom_vfs.h>
|
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_extern.h>
|
|
|
|
|
|
|
|
/*#define NTFS_DEBUG 1*/
|
2001-05-26 11:57:45 +00:00
|
|
|
#include <fs/ntfs/ntfs.h>
|
|
|
|
#include <fs/ntfs/ntfs_inode.h>
|
|
|
|
#include <fs/ntfs/ntfs_subr.h>
|
|
|
|
#include <fs/ntfs/ntfs_vfsops.h>
|
|
|
|
#include <fs/ntfs/ntfs_ihash.h>
|
|
|
|
#include <fs/ntfs/ntfsmount.h>
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2005-02-10 12:09:49 +00:00
|
|
|
static MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
|
1999-02-19 12:31:02 +00:00
|
|
|
MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
|
|
|
|
MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
|
1999-02-03 04:07:38 +00:00
|
|
|
MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
|
2001-11-26 23:45:12 +00:00
|
|
|
|
|
|
|
struct sockaddr;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2002-03-19 22:20:14 +00:00
|
|
|
static int ntfs_mountfs(register struct vnode *, struct mount *,
|
2004-12-06 20:22:16 +00:00
|
|
|
struct thread *);
|
2005-02-10 12:09:49 +00:00
|
|
|
static int ntfs_calccfree(struct ntfsmount *ntmp, cn_t *cfreep);
|
2003-06-12 20:48:38 +00:00
|
|
|
|
|
|
|
static vfs_init_t ntfs_init;
|
|
|
|
static vfs_uninit_t ntfs_uninit;
|
|
|
|
static vfs_vget_t ntfs_vget;
|
|
|
|
static vfs_fhtovp_t ntfs_fhtovp;
|
2004-12-06 20:22:16 +00:00
|
|
|
static vfs_cmount_t ntfs_cmount;
|
|
|
|
static vfs_mount_t ntfs_mount;
|
2003-06-12 20:48:38 +00:00
|
|
|
static vfs_root_t ntfs_root;
|
|
|
|
static vfs_statfs_t ntfs_statfs;
|
|
|
|
static vfs_unmount_t ntfs_unmount;
|
|
|
|
static vfs_vptofh_t ntfs_vptofh;
|
1999-12-03 20:37:40 +00:00
|
|
|
|
2005-01-27 13:50:27 +00:00
|
|
|
static b_strategy_t ntfs_bufstrategy;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Buffer operations for NTFS vnodes.
|
|
|
|
* We punt on VOP_BMAP, so we need to do
|
|
|
|
* strategy on the file's vnode rather
|
|
|
|
* than the underlying device's
|
|
|
|
*/
|
|
|
|
static struct buf_ops ntfs_vnbufops = {
|
|
|
|
.bop_name = "NTFS",
|
|
|
|
.bop_strategy = ntfs_bufstrategy,
|
|
|
|
};
|
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
static int
|
1999-12-03 20:37:40 +00:00
|
|
|
ntfs_init (
|
|
|
|
struct vfsconf *vcp )
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
1999-02-19 12:31:02 +00:00
|
|
|
ntfs_nthashinit();
|
1999-12-03 20:37:40 +00:00
|
|
|
ntfs_toupper_init();
|
1999-02-03 04:07:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-04 01:29:17 +00:00
|
|
|
static int
|
|
|
|
ntfs_uninit (
|
|
|
|
struct vfsconf *vcp )
|
|
|
|
{
|
|
|
|
ntfs_toupper_destroy();
|
|
|
|
ntfs_nthashdestroy();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
static int
|
2004-12-06 20:22:16 +00:00
|
|
|
ntfs_cmount (
|
|
|
|
struct mntarg *ma,
|
|
|
|
void *data,
|
|
|
|
int flags,
|
|
|
|
struct thread *td )
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct ntfs_args args;
|
|
|
|
|
|
|
|
error = copyin(data, (caddr_t)&args, sizeof args);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN);
|
|
|
|
ma = mount_arg(ma, "export", &args.export, sizeof args.export);
|
|
|
|
ma = mount_argf(ma, "uid", "%d", args.uid);
|
|
|
|
ma = mount_argf(ma, "gid", "%d", args.gid);
|
|
|
|
ma = mount_argf(ma, "mode", "%d", args.mode);
|
|
|
|
ma = mount_argb(ma, args.flag & NTFS_MFLAG_CASEINS, "nocaseins");
|
|
|
|
ma = mount_argb(ma, args.flag & NTFS_MFLAG_ALLNAMES, "noallnames");
|
|
|
|
if (args.flag & NTFS_MFLAG_KICONV) {
|
|
|
|
ma = mount_argsu(ma, "cs_ntfs", args.cs_ntfs, 64);
|
|
|
|
ma = mount_argsu(ma, "cs_local", args.cs_local, 64);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = kernel_mount(ma, flags);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *ntfs_opts[] = {
|
|
|
|
"from", "export", "uid", "gid", "mode", "caseins", "allnames",
|
|
|
|
"kiconv", "cs_ntfs", "cs_local", NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
ntfs_mount (
|
1999-02-03 04:07:38 +00:00
|
|
|
struct mount *mp,
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td )
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
2004-12-06 20:22:16 +00:00
|
|
|
int err = 0, error;
|
2004-12-04 09:57:38 +00:00
|
|
|
struct vnode *devvp;
|
2004-07-30 22:08:52 +00:00
|
|
|
struct nameidata ndp;
|
2004-12-06 20:22:16 +00:00
|
|
|
char *from;
|
|
|
|
struct export_args export;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2004-12-06 20:22:16 +00:00
|
|
|
if (vfs_filteropt(mp->mnt_optnew, ntfs_opts))
|
|
|
|
return (EINVAL);
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2004-12-06 20:22:16 +00:00
|
|
|
from = vfs_getopts(mp->mnt_optnew, "from", &error);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If updating, check whether changing from read-only to
|
2004-12-13 16:21:48 +00:00
|
|
|
* read/write.
|
1999-02-03 04:07:38 +00:00
|
|
|
*/
|
|
|
|
if (mp->mnt_flag & MNT_UPDATE) {
|
2004-12-13 16:21:48 +00:00
|
|
|
error = vfs_copyopt(mp->mnt_optnew, "export",
|
|
|
|
&export, sizeof export);
|
|
|
|
if ((error == 0) && export.ex_flags != 0) {
|
1999-02-03 04:07:38 +00:00
|
|
|
/*
|
|
|
|
* Process export requests. Jumping to "success"
|
|
|
|
* will return the vfs_export() error code.
|
|
|
|
*/
|
2004-12-06 20:22:16 +00:00
|
|
|
err = vfs_export(mp, &export);
|
1999-02-03 04:07:38 +00:00
|
|
|
goto success;
|
|
|
|
}
|
1999-12-03 20:37:40 +00:00
|
|
|
|
|
|
|
printf("ntfs_mount(): MNT_UPDATE not supported\n");
|
|
|
|
err = EINVAL;
|
|
|
|
goto error_1;
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Not an update, or updating the name: look up the name
|
|
|
|
* and verify that it refers to a sensible block device.
|
|
|
|
*/
|
2004-12-06 20:22:16 +00:00
|
|
|
NDINIT(&ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, from, td);
|
2004-07-30 22:08:52 +00:00
|
|
|
err = namei(&ndp);
|
1999-02-03 04:07:38 +00:00
|
|
|
if (err) {
|
|
|
|
/* can't get devvp!*/
|
|
|
|
goto error_1;
|
|
|
|
}
|
2004-07-30 22:08:52 +00:00
|
|
|
NDFREE(&ndp, NDF_ONLY_PNBUF);
|
|
|
|
devvp = ndp.ni_vp;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2000-01-10 12:04:27 +00:00
|
|
|
if (!vn_isdisk(devvp, &err))
|
1999-02-03 04:07:38 +00:00
|
|
|
goto error_2;
|
|
|
|
if (mp->mnt_flag & MNT_UPDATE) {
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
********************
|
|
|
|
* UPDATE
|
|
|
|
********************
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (devvp != ntmp->um_devvp)
|
|
|
|
err = EINVAL; /* needs translation */
|
|
|
|
else
|
|
|
|
vrele(devvp);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
********************
|
|
|
|
* NEW MOUNT
|
|
|
|
********************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since this is a new mount, we want the names for
|
|
|
|
* the device and the mount point copied in. If an
|
2001-03-01 21:00:17 +00:00
|
|
|
* error occurs, the mountpoint is discarded by the
|
|
|
|
* upper level code. Note that vfs_mount() handles
|
|
|
|
* copying the mountpoint f_mntonname for us, so we
|
|
|
|
* don't have to do it here unless we want to set it
|
|
|
|
* to something other than "path" for some rason.
|
1999-02-03 04:07:38 +00:00
|
|
|
*/
|
|
|
|
/* Save "mounted from" info for mount point (NULL pad)*/
|
2004-12-06 20:22:16 +00:00
|
|
|
vfs_mountedfrom(mp, from);
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2004-12-06 20:22:16 +00:00
|
|
|
err = ntfs_mountfs(devvp, mp, td);
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
if (err) {
|
|
|
|
goto error_2;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto success;
|
|
|
|
|
|
|
|
|
|
|
|
error_2: /* error with devvp held*/
|
|
|
|
|
|
|
|
/* release devvp before failing*/
|
|
|
|
vrele(devvp);
|
|
|
|
|
|
|
|
error_1: /* no state to back out*/
|
2004-07-30 22:08:52 +00:00
|
|
|
/* XXX: missing NDFREE(&ndp, ...) */
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
success:
|
1999-12-03 20:37:40 +00:00
|
|
|
return(err);
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Common code for mount and mountroot
|
|
|
|
*/
|
|
|
|
int
|
2004-12-06 20:22:16 +00:00
|
|
|
ntfs_mountfs(devvp, mp, td)
|
1999-02-03 04:07:38 +00:00
|
|
|
register struct vnode *devvp;
|
|
|
|
struct mount *mp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
|
|
|
struct buf *bp;
|
|
|
|
struct ntfsmount *ntmp;
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *dev = devvp->v_rdev;
|
2004-12-06 20:22:16 +00:00
|
|
|
int error, ronly, i, v;
|
1999-02-03 04:07:38 +00:00
|
|
|
struct vnode *vp;
|
2004-11-03 21:36:41 +00:00
|
|
|
struct g_consumer *cp;
|
2004-12-06 20:22:16 +00:00
|
|
|
char *cs_ntfs, *cs_local;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
|
2001-11-27 00:18:33 +00:00
|
|
|
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
|
2004-11-03 21:36:41 +00:00
|
|
|
DROP_GIANT();
|
|
|
|
g_topology_lock();
|
2004-11-04 07:18:54 +00:00
|
|
|
error = g_vfs_open(devvp, &cp, "ntfs", ronly ? 0 : 1);
|
2004-11-03 21:36:41 +00:00
|
|
|
g_topology_unlock();
|
|
|
|
PICKUP_GIANT();
|
2001-11-27 00:18:33 +00:00
|
|
|
VOP_UNLOCK(devvp, 0, td);
|
1999-02-03 04:07:38 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
bp = NULL;
|
|
|
|
|
|
|
|
error = bread(devvp, BBLOCK, BBSIZE, NOCRED, &bp);
|
|
|
|
if (error)
|
|
|
|
goto out;
|
2003-02-19 05:47:46 +00:00
|
|
|
ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK | M_ZERO);
|
1999-02-03 04:07:38 +00:00
|
|
|
bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
|
2003-07-26 02:21:49 +00:00
|
|
|
/*
|
|
|
|
* We must not cache the boot block if its size is not exactly
|
|
|
|
* one cluster in order to avoid confusing the buffer cache when
|
|
|
|
* the boot file is read later by ntfs_readntvattr_plain(), which
|
|
|
|
* reads a cluster at a time.
|
|
|
|
*/
|
|
|
|
if (ntfs_cntob(1) != BBSIZE)
|
|
|
|
bp->b_flags |= B_NOCACHE;
|
1999-02-03 04:07:38 +00:00
|
|
|
brelse( bp );
|
|
|
|
bp = NULL;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
|
|
|
|
error = EINVAL;
|
1999-12-03 20:37:40 +00:00
|
|
|
dprintf(("ntfs_mountfs: invalid boot block\n"));
|
1999-04-20 21:06:44 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
|
|
|
int8_t cpr = ntmp->ntm_mftrecsz;
|
|
|
|
if( cpr > 0 )
|
|
|
|
ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
|
|
|
|
else
|
|
|
|
ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
|
|
|
|
}
|
1999-04-20 21:06:44 +00:00
|
|
|
dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
|
1999-02-03 04:07:38 +00:00
|
|
|
ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
|
1999-04-20 21:06:44 +00:00
|
|
|
ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
|
|
|
|
dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
|
|
|
|
(u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
ntmp->ntm_mountp = mp;
|
|
|
|
ntmp->ntm_devvp = devvp;
|
2004-12-06 20:22:16 +00:00
|
|
|
if (1 == vfs_scanopt(mp->mnt_optnew, "uid", "%d", &v))
|
|
|
|
ntmp->ntm_uid = v;
|
|
|
|
if (1 == vfs_scanopt(mp->mnt_optnew, "gid", "%d", &v))
|
|
|
|
ntmp->ntm_gid = v;
|
|
|
|
if (1 == vfs_scanopt(mp->mnt_optnew, "mode", "%d", &v))
|
|
|
|
ntmp->ntm_mode = v;
|
|
|
|
vfs_flagopt(mp->mnt_optnew,
|
|
|
|
"caseins", &ntmp->ntm_flag, NTFS_MFLAG_CASEINS);
|
|
|
|
vfs_flagopt(mp->mnt_optnew,
|
|
|
|
"allnames", &ntmp->ntm_flag, NTFS_MFLAG_ALLNAMES);
|
2004-11-03 21:36:41 +00:00
|
|
|
ntmp->ntm_cp = cp;
|
|
|
|
ntmp->ntm_bo = &devvp->v_bufobj;
|
2001-09-08 23:03:52 +00:00
|
|
|
|
2004-12-06 20:22:16 +00:00
|
|
|
cs_local = vfs_getopts(mp->mnt_optnew, "cs_local", &error);
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
cs_ntfs = vfs_getopts(mp->mnt_optnew, "cs_ntfs", &error);
|
|
|
|
if (error)
|
|
|
|
goto out;
|
2001-09-08 23:03:52 +00:00
|
|
|
/* Copy in the 8-bit to Unicode conversion table */
|
2003-09-26 20:26:25 +00:00
|
|
|
/* Initialize Unicode to 8-bit table from 8toU table */
|
2004-12-06 20:22:16 +00:00
|
|
|
ntfs_82u_init(ntmp, cs_local, cs_ntfs);
|
2004-12-12 12:02:34 +00:00
|
|
|
if (cs_local != NULL && cs_ntfs != NULL)
|
|
|
|
ntfs_u28_init(ntmp, NULL, cs_local, cs_ntfs);
|
|
|
|
else
|
|
|
|
ntfs_u28_init(ntmp, ntmp->ntm_82u, cs_local, cs_ntfs);
|
2001-09-08 23:03:52 +00:00
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
mp->mnt_data = (qaddr_t)ntmp;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
|
1999-02-03 04:07:38 +00:00
|
|
|
(ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
|
|
|
|
(ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
|
1999-04-20 21:06:44 +00:00
|
|
|
ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/*
|
|
|
|
* We read in some system nodes to do not allow
|
|
|
|
* reclaim them and to have everytime access to them.
|
|
|
|
*/
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
1999-04-20 21:06:44 +00:00
|
|
|
int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
|
|
|
|
for (i=0; i<3; i++) {
|
2002-03-17 01:25:47 +00:00
|
|
|
error = VFS_VGET(mp, pi[i], LK_EXCLUSIVE,
|
|
|
|
&(ntmp->ntm_sysvn[pi[i]]));
|
1999-04-20 21:06:44 +00:00
|
|
|
if(error)
|
|
|
|
goto out1;
|
2002-08-04 10:29:36 +00:00
|
|
|
ntmp->ntm_sysvn[pi[i]]->v_vflag |= VV_SYSTEM;
|
1999-04-20 21:06:44 +00:00
|
|
|
VREF(ntmp->ntm_sysvn[pi[i]]);
|
|
|
|
vput(ntmp->ntm_sysvn[pi[i]]);
|
|
|
|
}
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
/* read the Unicode lowercase --> uppercase translation table,
|
|
|
|
* if necessary */
|
|
|
|
if ((error = ntfs_toupper_use(mp, ntmp)))
|
1999-02-03 04:07:38 +00:00
|
|
|
goto out1;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/*
|
|
|
|
* Scan $BitMap and count free clusters
|
|
|
|
*/
|
|
|
|
error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
|
|
|
|
if(error)
|
|
|
|
goto out1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read and translate to internal format attribute
|
|
|
|
* definition file.
|
|
|
|
*/
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
|
|
|
int num,j;
|
|
|
|
struct attrdef ad;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/* Open $AttrDef */
|
2002-03-17 01:25:47 +00:00
|
|
|
error = VFS_VGET(mp, NTFS_ATTRDEFINO, LK_EXCLUSIVE, &vp );
|
1999-02-03 04:07:38 +00:00
|
|
|
if(error)
|
|
|
|
goto out1;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/* Count valid entries */
|
1999-02-03 04:07:38 +00:00
|
|
|
for(num=0;;num++) {
|
1999-02-19 12:31:02 +00:00
|
|
|
error = ntfs_readattr(ntmp, VTONT(vp),
|
1999-02-03 04:07:38 +00:00
|
|
|
NTFS_A_DATA, NULL,
|
|
|
|
num * sizeof(ad), sizeof(ad),
|
1999-12-03 20:37:40 +00:00
|
|
|
&ad, NULL);
|
1999-02-03 04:07:38 +00:00
|
|
|
if (error)
|
|
|
|
goto out1;
|
|
|
|
if (ad.ad_name[0] == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/* Alloc memory for attribute definitions */
|
1999-02-03 04:07:38 +00:00
|
|
|
MALLOC(ntmp->ntm_ad, struct ntvattrdef *,
|
|
|
|
num * sizeof(struct ntvattrdef),
|
2003-02-19 05:47:46 +00:00
|
|
|
M_NTFSMNT, M_WAITOK);
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
ntmp->ntm_adnum = num;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/* Read them and translate */
|
1999-02-03 04:07:38 +00:00
|
|
|
for(i=0;i<num;i++){
|
1999-02-19 12:31:02 +00:00
|
|
|
error = ntfs_readattr(ntmp, VTONT(vp),
|
1999-02-03 04:07:38 +00:00
|
|
|
NTFS_A_DATA, NULL,
|
|
|
|
i * sizeof(ad), sizeof(ad),
|
1999-12-03 20:37:40 +00:00
|
|
|
&ad, NULL);
|
1999-02-03 04:07:38 +00:00
|
|
|
if (error)
|
|
|
|
goto out1;
|
|
|
|
j = 0;
|
|
|
|
do {
|
|
|
|
ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
|
|
|
|
} while(ad.ad_name[j++]);
|
|
|
|
ntmp->ntm_ad[i].ad_namelen = j - 1;
|
|
|
|
ntmp->ntm_ad[i].ad_type = ad.ad_type;
|
|
|
|
}
|
1999-04-20 21:06:44 +00:00
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
vput(vp);
|
|
|
|
}
|
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
|
1999-02-03 04:07:38 +00:00
|
|
|
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
|
|
|
|
mp->mnt_maxsymlinklen = 0;
|
|
|
|
mp->mnt_flag |= MNT_LOCAL;
|
|
|
|
return (0);
|
1999-04-20 21:06:44 +00:00
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
out1:
|
|
|
|
for(i=0;i<NTFS_SYSNODESNUM;i++)
|
|
|
|
if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
|
1999-04-20 21:06:44 +00:00
|
|
|
|
2004-07-12 08:14:09 +00:00
|
|
|
if (vflush(mp, 0, 0, td))
|
1999-12-03 20:37:40 +00:00
|
|
|
dprintf(("ntfs_mountfs: vflush failed\n"));
|
1999-04-20 21:06:44 +00:00
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
out:
|
|
|
|
if (bp)
|
|
|
|
brelse(bp);
|
1999-12-03 20:37:40 +00:00
|
|
|
|
2004-11-04 07:18:54 +00:00
|
|
|
DROP_GIANT();
|
|
|
|
g_topology_lock();
|
2005-01-25 15:52:04 +00:00
|
|
|
g_vfs_close(cp, td);
|
2004-11-04 07:18:54 +00:00
|
|
|
g_topology_unlock();
|
|
|
|
PICKUP_GIANT();
|
1999-12-03 20:37:40 +00:00
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ntfs_unmount(
|
|
|
|
struct mount *mp,
|
|
|
|
int mntflags,
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td)
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
2002-10-13 16:13:11 +00:00
|
|
|
struct ntfsmount *ntmp;
|
2004-11-03 21:36:41 +00:00
|
|
|
int error, flags, i;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
dprintf(("ntfs_unmount: unmounting...\n"));
|
1999-02-03 04:07:38 +00:00
|
|
|
ntmp = VFSTONTFS(mp);
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
if(mntflags & MNT_FORCE)
|
|
|
|
flags |= FORCECLOSE;
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
dprintf(("ntfs_unmount: vflushing...\n"));
|
2004-07-12 08:14:09 +00:00
|
|
|
error = vflush(mp, 0, flags | SKIPSYSTEM, td);
|
1999-02-03 04:07:38 +00:00
|
|
|
if (error) {
|
|
|
|
printf("ntfs_unmount: vflush failed: %d\n",error);
|
|
|
|
return (error);
|
|
|
|
}
|
1999-04-20 21:06:44 +00:00
|
|
|
|
|
|
|
/* Check if only system vnodes are rest */
|
|
|
|
for(i=0;i<NTFS_SYSNODESNUM;i++)
|
|
|
|
if((ntmp->ntm_sysvn[i]) &&
|
2002-09-25 02:32:42 +00:00
|
|
|
(vrefcnt(ntmp->ntm_sysvn[i]) > 1)) return (EBUSY);
|
1999-04-20 21:06:44 +00:00
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
/* Dereference all system vnodes */
|
1999-02-19 12:31:02 +00:00
|
|
|
for(i=0;i<NTFS_SYSNODESNUM;i++)
|
|
|
|
if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
|
1999-04-20 21:06:44 +00:00
|
|
|
|
|
|
|
/* vflush system vnodes */
|
2004-07-12 08:14:09 +00:00
|
|
|
error = vflush(mp, 0, flags, td);
|
1999-02-19 12:31:02 +00:00
|
|
|
if (error)
|
1999-04-20 21:06:44 +00:00
|
|
|
printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2005-01-14 07:33:51 +00:00
|
|
|
vinvalbuf(ntmp->ntm_devvp, V_SAVE, td, 0, 0);
|
1999-12-03 20:37:40 +00:00
|
|
|
|
2004-11-03 21:36:41 +00:00
|
|
|
DROP_GIANT();
|
|
|
|
g_topology_lock();
|
2005-01-25 15:52:04 +00:00
|
|
|
g_vfs_close(ntmp->ntm_cp, td);
|
2004-11-03 21:36:41 +00:00
|
|
|
g_topology_unlock();
|
|
|
|
PICKUP_GIANT();
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
vrele(ntmp->ntm_devvp);
|
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
/* free the toupper table, if this has been last mounted ntfs volume */
|
|
|
|
ntfs_toupper_unuse();
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
dprintf(("ntfs_umount: freeing memory...\n"));
|
2001-09-08 23:03:52 +00:00
|
|
|
ntfs_u28_uninit(ntmp);
|
|
|
|
ntfs_82u_uninit(ntmp);
|
1999-02-03 04:07:38 +00:00
|
|
|
mp->mnt_data = (qaddr_t)0;
|
|
|
|
mp->mnt_flag &= ~MNT_LOCAL;
|
|
|
|
FREE(ntmp->ntm_ad, M_NTFSMNT);
|
|
|
|
FREE(ntmp, M_NTFSMNT);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ntfs_root(
|
|
|
|
struct mount *mp,
|
2004-07-12 08:14:09 +00:00
|
|
|
struct vnode **vpp,
|
|
|
|
struct thread *td )
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
|
|
|
struct vnode *nvp;
|
|
|
|
int error = 0;
|
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
dprintf(("ntfs_root(): sysvn: %p\n",
|
|
|
|
VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
|
2002-03-17 01:25:47 +00:00
|
|
|
error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, LK_EXCLUSIVE, &nvp);
|
1999-02-03 04:07:38 +00:00
|
|
|
if(error) {
|
|
|
|
printf("ntfs_root: VFS_VGET failed: %d\n",error);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
*vpp = nvp;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2005-02-10 12:09:49 +00:00
|
|
|
static int
|
1999-04-20 21:06:44 +00:00
|
|
|
ntfs_calccfree(
|
|
|
|
struct ntfsmount *ntmp,
|
|
|
|
cn_t *cfreep)
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
|
|
|
struct vnode *vp;
|
|
|
|
u_int8_t *tmp;
|
1999-04-20 21:06:44 +00:00
|
|
|
int j, error;
|
|
|
|
long cfree = 0;
|
|
|
|
size_t bmsize, i;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
bmsize = VTOF(vp)->f_size;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
MALLOC(tmp, u_int8_t *, bmsize, M_TEMP, M_WAITOK);
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
|
1999-12-03 20:37:40 +00:00
|
|
|
0, bmsize, tmp, NULL);
|
|
|
|
if (error)
|
|
|
|
goto out;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
for(i=0;i<bmsize;i++)
|
|
|
|
for(j=0;j<8;j++)
|
1999-04-20 21:06:44 +00:00
|
|
|
if(~tmp[i] & (1 << j)) cfree++;
|
|
|
|
*cfreep = cfree;
|
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
out:
|
|
|
|
FREE(tmp, M_TEMP);
|
|
|
|
return(error);
|
1999-04-20 21:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ntfs_statfs(
|
|
|
|
struct mount *mp,
|
|
|
|
struct statfs *sbp,
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td)
|
1999-04-20 21:06:44 +00:00
|
|
|
{
|
|
|
|
struct ntfsmount *ntmp = VFSTONTFS(mp);
|
|
|
|
u_int64_t mftsize,mftallocated;
|
|
|
|
|
|
|
|
dprintf(("ntfs_statfs():\n"));
|
|
|
|
|
|
|
|
mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
|
|
|
|
mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
|
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
|
|
|
sbp->f_bsize = ntmp->ntm_bps;
|
|
|
|
sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
|
|
|
|
sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
|
1999-04-20 21:06:44 +00:00
|
|
|
sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
|
1999-02-03 04:07:38 +00:00
|
|
|
sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
|
|
|
|
sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
|
|
|
|
sbp->f_ffree;
|
1999-02-19 12:31:02 +00:00
|
|
|
sbp->f_flags = mp->mnt_flag;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-05-12 09:43:09 +00:00
|
|
|
/*ARGSUSED*/
|
1999-02-03 04:07:38 +00:00
|
|
|
static int
|
|
|
|
ntfs_fhtovp(
|
1999-05-12 09:43:09 +00:00
|
|
|
struct mount *mp,
|
|
|
|
struct fid *fhp,
|
|
|
|
struct vnode **vpp)
|
1999-02-03 04:07:38 +00:00
|
|
|
{
|
1999-12-03 20:37:40 +00:00
|
|
|
struct vnode *nvp;
|
|
|
|
struct ntfid *ntfhp = (struct ntfid *)fhp;
|
|
|
|
int error;
|
|
|
|
|
2001-09-08 22:53:27 +00:00
|
|
|
ddprintf(("ntfs_fhtovp(): %d\n", ntfhp->ntfid_ino));
|
1999-12-03 20:37:40 +00:00
|
|
|
|
2002-03-17 01:25:47 +00:00
|
|
|
if ((error = VFS_VGET(mp, ntfhp->ntfid_ino, LK_EXCLUSIVE, &nvp)) != 0) {
|
1999-12-03 20:37:40 +00:00
|
|
|
*vpp = NULLVP;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
/* XXX as unlink/rmdir/mkdir/creat are not currently possible
|
|
|
|
* with NTFS, we don't need to check anything else for now */
|
|
|
|
*vpp = nvp;
|
2005-01-24 21:51:19 +00:00
|
|
|
vnode_create_vobject(nvp, VTOF(nvp)->f_size, curthread);
|
1999-12-03 20:37:40 +00:00
|
|
|
return (0);
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ntfs_vptofh(
|
|
|
|
struct vnode *vp,
|
|
|
|
struct fid *fhp)
|
|
|
|
{
|
1999-12-03 20:37:40 +00:00
|
|
|
register struct ntnode *ntp;
|
|
|
|
register struct ntfid *ntfhp;
|
|
|
|
|
2001-09-08 22:53:27 +00:00
|
|
|
ddprintf(("ntfs_fhtovp(): %p\n", vp));
|
1999-12-03 20:37:40 +00:00
|
|
|
|
|
|
|
ntp = VTONT(vp);
|
|
|
|
ntfhp = (struct ntfid *)fhp;
|
|
|
|
ntfhp->ntfid_len = sizeof(struct ntfid);
|
|
|
|
ntfhp->ntfid_ino = ntp->i_number;
|
|
|
|
/* ntfhp->ntfid_gen = ntp->i_gen; */
|
|
|
|
return (0);
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
int
|
|
|
|
ntfs_vgetex(
|
1999-02-03 04:07:38 +00:00
|
|
|
struct mount *mp,
|
|
|
|
ino_t ino,
|
1999-02-19 12:31:02 +00:00
|
|
|
u_int32_t attrtype,
|
|
|
|
char *attrname,
|
|
|
|
u_long lkflags,
|
|
|
|
u_long flags,
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td,
|
1999-02-03 04:07:38 +00:00
|
|
|
struct vnode **vpp)
|
|
|
|
{
|
1999-02-19 12:31:02 +00:00
|
|
|
int error;
|
1999-02-03 04:07:38 +00:00
|
|
|
register struct ntfsmount *ntmp;
|
|
|
|
struct ntnode *ip;
|
1999-02-19 12:31:02 +00:00
|
|
|
struct fnode *fp;
|
|
|
|
struct vnode *vp;
|
1999-12-03 20:37:40 +00:00
|
|
|
enum vtype f_type;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
|
|
|
|
ino, attrtype, attrname?attrname:"", (u_long)lkflags,
|
2005-01-27 13:50:27 +00:00
|
|
|
(u_long)flags));
|
1999-02-03 04:07:38 +00:00
|
|
|
|
|
|
|
ntmp = VFSTONTFS(mp);
|
1999-02-19 12:31:02 +00:00
|
|
|
*vpp = NULL;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
/* Get ntnode */
|
1999-04-20 21:06:44 +00:00
|
|
|
error = ntfs_ntlookup(ntmp, ino, &ip);
|
1999-02-19 12:31:02 +00:00
|
|
|
if (error) {
|
1999-02-03 04:07:38 +00:00
|
|
|
printf("ntfs_vget: ntfs_ntget failed\n");
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
/* It may be not initialized fully, so force load it */
|
|
|
|
if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
|
|
|
|
error = ntfs_loadntnode(ntmp, ip);
|
|
|
|
if(error) {
|
|
|
|
printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %d\n",
|
|
|
|
ip->i_number);
|
|
|
|
ntfs_ntput(ip);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
|
|
|
|
if (error) {
|
|
|
|
printf("ntfs_vget: ntfs_fget failed\n");
|
1999-04-20 21:06:44 +00:00
|
|
|
ntfs_ntput(ip);
|
1999-02-03 04:07:38 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-12-03 20:37:40 +00:00
|
|
|
f_type = VNON;
|
1999-04-20 21:06:44 +00:00
|
|
|
if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
|
|
|
|
if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
|
1999-12-03 20:37:40 +00:00
|
|
|
(fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
|
|
|
|
f_type = VDIR;
|
|
|
|
} else if (flags & VG_EXT) {
|
|
|
|
f_type = VNON;
|
|
|
|
fp->f_size = fp->f_allocated = 0;
|
1999-04-20 21:06:44 +00:00
|
|
|
} else {
|
1999-12-03 20:37:40 +00:00
|
|
|
f_type = VREG;
|
1999-04-20 21:06:44 +00:00
|
|
|
|
|
|
|
error = ntfs_filesize(ntmp, fp,
|
|
|
|
&fp->f_size, &fp->f_allocated);
|
|
|
|
if (error) {
|
|
|
|
ntfs_ntput(ip);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fp->f_flag |= FN_VALID;
|
|
|
|
}
|
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
if (FTOV(fp)) {
|
2001-11-27 00:18:33 +00:00
|
|
|
vget(FTOV(fp), lkflags, td);
|
1999-02-19 12:31:02 +00:00
|
|
|
*vpp = FTOV(fp);
|
1999-04-20 21:06:44 +00:00
|
|
|
ntfs_ntput(ip);
|
1999-02-19 12:31:02 +00:00
|
|
|
return (0);
|
|
|
|
}
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2004-12-01 23:16:38 +00:00
|
|
|
error = getnewvnode("ntfs", ntmp->ntm_mountp, &ntfs_vnodeops, &vp);
|
1999-02-03 04:07:38 +00:00
|
|
|
if(error) {
|
1999-02-19 12:31:02 +00:00
|
|
|
ntfs_frele(fp);
|
1999-04-20 21:06:44 +00:00
|
|
|
ntfs_ntput(ip);
|
1999-02-03 04:07:38 +00:00
|
|
|
return (error);
|
|
|
|
}
|
1999-02-19 12:31:02 +00:00
|
|
|
dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
|
1999-02-03 04:07:38 +00:00
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
fp->f_vp = vp;
|
|
|
|
vp->v_data = fp;
|
1999-12-03 20:37:40 +00:00
|
|
|
vp->v_type = f_type;
|
1999-02-03 04:07:38 +00:00
|
|
|
|
2005-01-27 13:50:27 +00:00
|
|
|
vp->v_bufobj.bo_ops = &ntfs_vnbufops;
|
|
|
|
vp->v_bufobj.bo_private = vp;
|
|
|
|
|
1999-02-19 12:31:02 +00:00
|
|
|
if (ino == NTFS_ROOTINO)
|
2002-08-04 10:29:36 +00:00
|
|
|
vp->v_vflag |= VV_ROOT;
|
1999-02-19 12:31:02 +00:00
|
|
|
|
1999-04-20 21:06:44 +00:00
|
|
|
ntfs_ntput(ip);
|
1999-02-19 12:31:02 +00:00
|
|
|
|
|
|
|
if (lkflags & LK_TYPE_MASK) {
|
2001-11-27 00:18:33 +00:00
|
|
|
error = vn_lock(vp, lkflags, td);
|
1999-02-19 12:31:02 +00:00
|
|
|
if (error) {
|
|
|
|
vput(vp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*vpp = vp;
|
1999-02-03 04:07:38 +00:00
|
|
|
return (0);
|
1999-02-19 12:31:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ntfs_vget(
|
|
|
|
struct mount *mp,
|
|
|
|
ino_t ino,
|
2002-03-17 01:25:47 +00:00
|
|
|
int lkflags,
|
1999-02-19 12:31:02 +00:00
|
|
|
struct vnode **vpp)
|
|
|
|
{
|
2002-03-17 01:25:47 +00:00
|
|
|
return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL, lkflags, 0,
|
|
|
|
curthread, vpp);
|
1999-02-03 04:07:38 +00:00
|
|
|
}
|
|
|
|
|
2005-01-27 13:50:27 +00:00
|
|
|
static void
|
|
|
|
ntfs_bufstrategy(struct bufobj *bo, struct buf *bp)
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
vp = bo->bo_private;
|
|
|
|
KASSERT(bo == &vp->v_bufobj, ("BO/VP mismatch: vp %p bo %p != %p",
|
|
|
|
vp, &vp->v_bufobj, bo));
|
|
|
|
rc = VOP_STRATEGY(vp, bp);
|
|
|
|
KASSERT(rc == 0, ("NTFS VOP_STRATEGY failed: bp=%p, "
|
|
|
|
"vp=%p, rc=%d", bp, vp, rc));
|
|
|
|
}
|
|
|
|
|
1999-02-03 04:07:38 +00:00
|
|
|
static struct vfsops ntfs_vfsops = {
|
2003-06-12 20:48:38 +00:00
|
|
|
.vfs_fhtovp = ntfs_fhtovp,
|
|
|
|
.vfs_init = ntfs_init,
|
2004-12-06 20:22:16 +00:00
|
|
|
.vfs_cmount = ntfs_cmount,
|
|
|
|
.vfs_mount = ntfs_mount,
|
2003-06-12 20:48:38 +00:00
|
|
|
.vfs_root = ntfs_root,
|
|
|
|
.vfs_statfs = ntfs_statfs,
|
|
|
|
.vfs_uninit = ntfs_uninit,
|
|
|
|
.vfs_unmount = ntfs_unmount,
|
|
|
|
.vfs_vget = ntfs_vget,
|
|
|
|
.vfs_vptofh = ntfs_vptofh,
|
1999-02-03 04:07:38 +00:00
|
|
|
};
|
|
|
|
VFS_SET(ntfs_vfsops, ntfs, 0);
|
2003-09-26 20:26:25 +00:00
|
|
|
MODULE_VERSION(ntfs, 1);
|