1 /* $NetBSD: ntfs_vfsops.c,v 1.23 1999/11/15 19:38:14 jdolecek Exp $ */
4 * Copyright (c) 1998, 1999 Semen Ustimenko
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * $FreeBSD: src/sys/ntfs/ntfs_vfsops.c,v 1.20.2.5 2001/12/25 01:44:45 dillon Exp $
32 #include <sys/param.h>
33 #include <sys/systm.h>
36 #include <sys/nlookup.h>
37 #include <sys/kernel.h>
38 #include <sys/vnode.h>
39 #include <sys/mount.h>
41 #include <sys/fcntl.h>
42 #include <sys/malloc.h>
43 #include <sys/systm.h>
44 #if defined(__NetBSD__)
45 #include <sys/device.h>
48 #include <machine/inttypes.h>
51 #include <vm/vm_param.h>
52 #if defined(__NetBSD__)
53 #include <vm/vm_prot.h>
55 #include <vm/vm_page.h>
56 #include <vm/vm_object.h>
57 #include <vm/vm_extern.h>
58 #include <vm/vm_zone.h>
60 #if defined(__NetBSD__)
61 #include <miscfs/specfs/specdev.h>
66 /*#define NTFS_DEBUG 1*/
68 #include "ntfs_inode.h"
69 #include "ntfs_subr.h"
70 #include "ntfs_vfsops.h"
71 #include "ntfs_ihash.h"
72 #include "ntfsmount.h"
74 extern struct vop_ops ntfs_vnode_vops;
76 #if defined(__DragonFly__)
77 MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
78 MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
79 MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
80 MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
83 struct iconv_functions *ntfs_iconv = NULL;
85 static int ntfs_root (struct mount *, struct vnode **);
86 static int ntfs_statfs (struct mount *, struct statfs *, struct ucred *cred);
87 static int ntfs_unmount (struct mount *, int);
88 static int ntfs_vget (struct mount *mp, struct vnode *dvp,
89 ino_t ino, struct vnode **vpp);
90 static int ntfs_mountfs (struct vnode *, struct mount *,
91 struct ntfs_args *, struct ucred *);
92 static int ntfs_vptofh (struct vnode *, struct fid *);
93 static int ntfs_fhtovp (struct mount *, struct vnode *rootvp,
94 struct fid *, struct vnode **);
96 #if !defined (__DragonFly__)
97 static int ntfs_quotactl (struct mount *, int, uid_t, caddr_t,
99 static int ntfs_start (struct mount *, int, struct thread *);
100 static int ntfs_sync (struct mount *, int, struct ucred *,
104 #if defined(__DragonFly__)
106 static int ntfs_mount (struct mount *, char *, caddr_t, struct ucred *);
107 static int ntfs_init (struct vfsconf *);
108 static int ntfs_checkexp (struct mount *, struct sockaddr *,
109 int *, struct ucred **);
110 #elif defined(__NetBSD__)
111 static int ntfs_mount (struct mount *, const char *, void *,
112 struct nameidata *, struct thread *);
113 static void ntfs_init (void);
114 static int ntfs_mountroot (void);
115 static int ntfs_sysctl (int *, u_int, void *, size_t *, void *,
116 size_t, struct thread *);
117 static int ntfs_checkexp (struct mount *, struct mbuf *,
118 int *, struct ucred **);
122 * Verify a remote client has export rights and return these rights via.
123 * exflagsp and credanonp.
126 ntfs_checkexp(struct mount *mp,
127 #if defined(__DragonFly__)
128 struct sockaddr *nam,
129 #else /* defined(__NetBSD__) */
132 int *exflagsp, struct ucred **credanonp)
135 struct ntfsmount *ntm = VFSTONTFS(mp);
138 * Get the export permission structure for this <mp, client> tuple.
140 np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
144 *exflagsp = np->netc_exflags;
145 *credanonp = &np->netc_anon;
149 #if defined(__NetBSD__)
152 ntfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
153 size_t newlen, struct thread *td)
162 struct vnode *rootvp;
163 struct thread *td = curthread; /* XXX */
164 struct ntfs_args args;
167 if (root_device->dv_class != DV_DISK)
171 * Get vnodes for rootdev.
173 if (bdevvp(rootdev, &rootvp))
174 panic("ntfs_mountroot: can't setup rootvp");
176 if ((error = vfs_rootmountalloc(MOUNT_NTFS, "root_device", &mp))) {
186 if ((error = ntfs_mountfs(rootvp, mp, &args, proc0.p_ucred)) != 0) {
187 mp->mnt_op->vfs_refcount--;
193 mountlist_insert(mp, MNTINS_LAST);
194 (void)ntfs_statfs(mp, &mp->mnt_stat, proc0.p_ucred);
206 #elif defined(__DragonFly__)
209 ntfs_init(struct vfsconf *vcp)
219 ntfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
224 struct ntfs_args args;
225 struct nlookupdata nd;
226 struct vnode *rootvp;
231 * Use NULL path to flag a root mount
236 * Mounting root file system
240 /* Get vnode for root device*/
241 if( bdevvp( rootdev, &rootvp))
242 panic("ffs_mountroot: can't setup bdevvp for root");
245 * FS specific handling
247 mp->mnt_flag |= MNT_RDONLY; /* XXX globally applicable?*/
252 if( ( error = ntfs_mountfs(rootvp, mp, &args, cred)) != 0) {
253 /* fs specific cleanup (if any)*/
257 goto dostatfs; /* success*/
264 * Mounting non-root file system or updating a file system
268 /* copy in user arguments*/
269 error = copyin(data, (caddr_t)&args, sizeof (struct ntfs_args));
271 goto error_1; /* can't get arguments*/
274 * If updating, check whether changing from read-only to
275 * read/write; if there is no device name, that's all we do.
277 if (mp->mnt_flag & MNT_UPDATE) {
278 /* if not updating name...*/
279 if (args.fspec == 0) {
281 * Process export requests. Jumping to "success"
282 * will return the vfs_export() error code.
284 struct ntfsmount *ntm = VFSTONTFS(mp);
285 error = vfs_export(mp, &ntm->ntm_export, &args.export);
289 kprintf("ntfs_mount(): MNT_UPDATE not supported\n");
295 * Not an update, or updating the name: look up the name
296 * and verify that it refers to a sensible block device.
299 error = nlookup_init(&nd, args.fspec, UIO_USERSPACE, NLC_FOLLOW);
301 error = nlookup(&nd);
303 error = cache_vref(&nd.nl_nch, nd.nl_cred, &devvp);
308 #if defined(__DragonFly__)
309 if (!vn_isdisk(devvp, &error))
312 if (devvp->v_type != VBLK) {
316 if (devvp->v_umajor >= nblkdev) {
321 if (mp->mnt_flag & MNT_UPDATE) {
329 if (devvp != ntmp->um_devvp)
330 error = EINVAL; /* needs translation */
334 * Update device name only on success
337 /* Save "mounted from" info for mount point (NULL pad)*/
338 copyinstr( args.fspec,
339 mp->mnt_stat.f_mntfromname,
342 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
352 /* Save "mounted from" info for mount point (NULL pad)*/
353 copyinstr( args.fspec, /* device name*/
354 mp->mnt_stat.f_mntfromname, /* save area*/
355 MNAMELEN - 1, /* max size*/
356 &size); /* real size*/
357 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
359 error = ntfs_mountfs(devvp, mp, &args, cred);
369 * Initialize FS stat information in mount struct; uses
370 * mp->mnt_stat.f_mntfromname.
372 * This code is common to root and non-root mounts
374 (void)VFS_STATFS(mp, &mp->mnt_stat, cred);
379 error_2: /* error with devvp held*/
381 /* release devvp before failing*/
384 error_1: /* no state to back out*/
391 * Common code for mount and mountroot
394 ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp,
398 struct ntfsmount *ntmp;
400 int error, ronly, ncount, i;
402 char cs_local[ICONV_CSNMAXLEN];
403 char cs_ntfs[ICONV_CSNMAXLEN];
406 * Disallow multiple mounts of the same device.
407 * Disallow mounting of a device that is currently in use
408 * (except for root, which might share swap device for miniroot).
409 * Flush out any old buffers remaining from a previous use.
411 error = vfs_mountedon(devvp);
414 ncount = vcount(devvp);
415 #if defined(__DragonFly__)
421 #if defined(__DragonFly__)
422 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY);
423 error = vinvalbuf(devvp, V_SAVE, 0, 0);
424 VOP__UNLOCK(devvp, 0);
426 error = vinvalbuf(devvp, V_SAVE, 0, 0);
431 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
432 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY);
433 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, NULL);
434 VOP__UNLOCK(devvp, 0);
441 error = bread(devvp, BBLOCK, BBSIZE, &bp);
444 ntmp = kmalloc(sizeof *ntmp, M_NTFSMNT, M_WAITOK | M_ZERO);
445 bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
449 if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
451 dprintf(("ntfs_mountfs: invalid boot block\n"));
456 int8_t cpr = ntmp->ntm_mftrecsz;
458 ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
460 ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
462 dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
463 ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
464 ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
465 dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
466 (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
468 ntmp->ntm_mountp = mp;
470 ntmp->ntm_devvp = devvp;
471 ntmp->ntm_uid = argsp->uid;
472 ntmp->ntm_gid = argsp->gid;
473 ntmp->ntm_mode = argsp->mode;
474 ntmp->ntm_flag = argsp->flag;
476 if (argsp->flag & NTFS_MFLAG_KICONV && ntfs_iconv) {
477 bcopy(argsp->cs_local, cs_local, sizeof(cs_local));
478 bcopy(argsp->cs_ntfs, cs_ntfs, sizeof(cs_ntfs));
479 ntfs_82u_init(ntmp, cs_local, cs_ntfs);
480 ntfs_u28_init(ntmp, NULL, cs_local, cs_ntfs);
482 ntfs_82u_init(ntmp, NULL, NULL);
483 ntfs_u28_init(ntmp, ntmp->ntm_82u, NULL, NULL);
486 mp->mnt_data = (qaddr_t)ntmp;
488 dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
489 (ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
490 (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
491 ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
493 vfs_add_vnodeops(mp, &ntfs_vnode_vops, &mp->mnt_vn_norm_ops);
496 * We read in some system nodes to do not allow
497 * reclaim them and to have everytime access to them.
500 int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
501 for (i=0; i<3; i++) {
502 error = VFS_VGET(mp, NULL,
503 pi[i], &(ntmp->ntm_sysvn[pi[i]]));
506 vsetflags(ntmp->ntm_sysvn[pi[i]], VSYSTEM);
507 vref(ntmp->ntm_sysvn[pi[i]]);
508 vput(ntmp->ntm_sysvn[pi[i]]);
512 /* read the Unicode lowercase --> uppercase translation table,
514 if ((error = ntfs_toupper_use(mp, ntmp)))
518 * Scan $BitMap and count free clusters
520 error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
525 * Read and translate to internal format attribute
533 error = VFS_VGET(mp, NULL, NTFS_ATTRDEFINO, &vp);
537 /* Count valid entries */
539 error = ntfs_readattr(ntmp, VTONT(vp),
541 num * sizeof(ad), sizeof(ad),
545 if (ad.ad_name[0] == 0)
549 /* Alloc memory for attribute definitions */
550 ntmp->ntm_ad = kmalloc(num * sizeof(struct ntvattrdef),
551 M_NTFSMNT, M_WAITOK);
553 ntmp->ntm_adnum = num;
555 /* Read them and translate */
557 error = ntfs_readattr(ntmp, VTONT(vp),
559 i * sizeof(ad), sizeof(ad),
565 ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
566 } while(ad.ad_name[j++]);
567 ntmp->ntm_ad[i].ad_namelen = j - 1;
568 ntmp->ntm_ad[i].ad_type = ad.ad_type;
574 #if defined(__DragonFly__)
575 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
576 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
578 mp->mnt_stat.f_fsid.val[0] = dev;
579 mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
581 mp->mnt_maxsymlinklen = 0;
582 mp->mnt_flag |= MNT_LOCAL;
583 dev->si_mountpoint = mp;
588 for(i=0;i<NTFS_SYSNODESNUM;i++)
589 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
591 if (vflush(mp, 0, 0))
592 dprintf(("ntfs_mountfs: vflush failed\n"));
595 dev->si_mountpoint = NULL;
599 #if defined __NetBSD__
600 /* lock the device vnode before calling VOP_CLOSE() */
601 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY);
602 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE);
603 VOP__UNLOCK(devvp, 0);
605 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE);
611 #if !defined(__DragonFly__)
613 ntfs_start(struct mount *mp, int flags, struct thread *td)
620 ntfs_unmount(struct mount *mp, int mntflags)
622 struct ntfsmount *ntmp;
623 int error, ronly, flags, i;
625 dprintf(("ntfs_unmount: unmounting...\n"));
626 ntmp = VFSTONTFS(mp);
628 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
630 if(mntflags & MNT_FORCE)
633 dprintf(("ntfs_unmount: vflushing...\n"));
634 error = vflush(mp, 0, flags | SKIPSYSTEM);
636 kprintf("ntfs_unmount: vflush failed: %d\n",error);
640 /* Check if only system vnodes are left */
641 for(i=0;i<NTFS_SYSNODESNUM;i++)
642 if((ntmp->ntm_sysvn[i]) &&
643 (ntmp->ntm_sysvn[i]->v_sysref.refcnt > 1)) return (EBUSY);
645 /* Dereference all system vnodes */
646 for(i=0;i<NTFS_SYSNODESNUM;i++)
647 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
649 /* vflush system vnodes */
650 error = vflush(mp, 0, flags);
652 kprintf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
654 /* Check if the type of device node isn't VBAD before
655 * touching v_cdevinfo. If the device vnode is revoked, the
656 * field is NULL and touching it causes null pointer derefercence.
658 if (ntmp->ntm_devvp->v_type != VBAD)
659 ntmp->ntm_devvp->v_rdev->si_mountpoint = NULL;
661 vinvalbuf(ntmp->ntm_devvp, V_SAVE, 0, 0);
663 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE);
665 vrele(ntmp->ntm_devvp);
667 /* free the toupper table, if this has been last mounted ntfs volume */
668 ntfs_toupper_unuse();
670 dprintf(("ntfs_umount: freeing memory...\n"));
671 ntfs_u28_uninit(ntmp);
672 ntfs_82u_uninit(ntmp);
673 mp->mnt_data = (qaddr_t)0;
674 mp->mnt_flag &= ~MNT_LOCAL;
675 kfree(ntmp->ntm_ad, M_NTFSMNT);
676 kfree(ntmp, M_NTFSMNT);
681 ntfs_root(struct mount *mp, struct vnode **vpp)
686 dprintf(("ntfs_root(): sysvn: %p\n",
687 VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
688 error = VFS_VGET(mp, NULL, (ino_t)NTFS_ROOTINO, &nvp);
690 kprintf("ntfs_root: VFS_VGET failed: %d\n",error);
698 #if !defined(__DragonFly__)
700 ntfs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
703 kprintf("\nntfs_quotactl():\n");
709 ntfs_calccfree(struct ntfsmount *ntmp, cn_t *cfreep)
717 vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
719 bmsize = VTOF(vp)->f_size;
721 tmp = kmalloc(bmsize, M_TEMP, M_WAITOK);
723 error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
724 0, bmsize, tmp, NULL);
728 for(i=0;i<bmsize;i++)
730 if(~tmp[i] & (1 << j)) cfree++;
739 ntfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred)
741 struct ntfsmount *ntmp = VFSTONTFS(mp);
742 u_int64_t mftsize,mftallocated;
744 dprintf(("ntfs_statfs():\n"));
746 mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
747 mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
749 #if defined(__DragonFly__)
750 sbp->f_type = mp->mnt_vfc->vfc_typenum;
751 #elif defined(__NetBSD__)
754 sbp->f_type = MOUNT_NTFS;
756 sbp->f_bsize = ntmp->ntm_bps;
757 sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
758 sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
759 sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
760 sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
761 sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
763 if (sbp != &mp->mnt_stat) {
764 bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
765 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
767 sbp->f_flags = mp->mnt_flag;
769 strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
775 #if !defined(__DragonFly__)
777 ntfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td)
779 /*dprintf(("ntfs_sync():\n"));*/
786 ntfs_fhtovp(struct mount *mp, struct vnode *rootvp,
787 struct fid *fhp, struct vnode **vpp)
790 struct ntfid *ntfhp = (struct ntfid *)fhp;
793 ddprintf(("ntfs_fhtovp(): %d\n", ntfhp->ntfid_ino));
795 if ((error = VFS_VGET(mp, NULL, ntfhp->ntfid_ino, &nvp)) != 0) {
799 /* XXX as unlink/rmdir/mkdir/creat are not currently possible
800 * with NTFS, we don't need to check anything else for now */
807 ntfs_vptofh(struct vnode *vp, struct fid *fhp)
812 ddprintf(("ntfs_fhtovp(): %p\n", vp));
815 ntfhp = (struct ntfid *)fhp;
816 ntfhp->ntfid_len = sizeof(struct ntfid);
817 ntfhp->ntfid_ino = ntp->i_number;
818 /* ntfhp->ntfid_gen = ntp->i_gen; */
823 ntfs_vgetex(struct mount *mp, ino_t ino, u_int32_t attrtype, char *attrname,
824 u_long lkflags, u_long flags, struct thread *td,
828 struct ntfsmount *ntmp;
834 dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
835 ino, attrtype, attrname?attrname:"", (u_long)lkflags,
838 ntmp = VFSTONTFS(mp);
842 error = ntfs_ntlookup(ntmp, ino, &ip);
844 kprintf("ntfs_vget: ntfs_ntget failed\n");
848 /* It may be not initialized fully, so force load it */
849 if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
850 error = ntfs_loadntnode(ntmp, ip);
852 kprintf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %"PRId64"\n",
859 error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
861 kprintf("ntfs_vget: ntfs_fget failed\n");
867 if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
868 if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
869 (fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
871 } else if (flags & VG_EXT) {
873 fp->f_size = fp->f_allocated = 0;
877 error = ntfs_filesize(ntmp, fp,
878 &fp->f_size, &fp->f_allocated);
885 fp->f_flag |= FN_VALID;
889 VGET(FTOV(fp), lkflags);
895 error = getnewvnode(VT_NTFS, ntmp->ntm_mountp, &vp, VLKTIMEOUT, 0);
901 dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
907 if (ino == NTFS_ROOTINO)
908 vsetflags(vp, VROOT);
911 * Normal files use the buffer cache
914 vinitvmio(vp, fp->f_size, PAGE_SIZE, -1);
918 KKASSERT(lkflags & LK_TYPE_MASK);
919 /* XXX leave vnode locked exclusively from getnewvnode */
926 ntfs_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp)
928 return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
929 LK_EXCLUSIVE | LK_RETRY, 0, curthread, vpp);
932 #if defined(__DragonFly__)
933 static struct vfsops ntfs_vfsops = {
934 .vfs_mount = ntfs_mount,
935 .vfs_unmount = ntfs_unmount,
936 .vfs_root = ntfs_root,
937 .vfs_statfs = ntfs_statfs,
938 .vfs_sync = vfs_stdsync,
939 .vfs_vget = ntfs_vget,
940 .vfs_fhtovp = ntfs_fhtovp,
941 .vfs_checkexp = ntfs_checkexp,
942 .vfs_vptofh = ntfs_vptofh,
943 .vfs_init = ntfs_init,
944 .vfs_uninit = ntfs_nthash_uninit /* see ntfs_ihash.c */
946 VFS_SET(ntfs_vfsops, ntfs, 0);
947 MODULE_VERSION(ntfs, 1);
948 #elif defined(__NetBSD__)
949 extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
951 struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
952 &ntfs_vnodeop_opv_desc,
956 struct vfsops ntfs_vfsops = {
974 #else /* !NetBSD && !FreeBSD */
975 static struct vfsops ntfs_vfsops = {
988 VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);