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 $
29 * $DragonFly: src/sys/vfs/ntfs/ntfs_vfsops.c,v 1.3 2003/06/25 03:56:07 dillon Exp $
33 #include <sys/param.h>
34 #include <sys/systm.h>
37 #include <sys/namei.h>
38 #include <sys/kernel.h>
39 #include <sys/vnode.h>
40 #include <sys/mount.h>
42 #include <sys/fcntl.h>
43 #include <sys/malloc.h>
44 #include <sys/systm.h>
45 #if defined(__NetBSD__)
46 #include <sys/device.h>
50 #include <vm/vm_param.h>
51 #if defined(__NetBSD__)
52 #include <vm/vm_prot.h>
54 #include <vm/vm_page.h>
55 #include <vm/vm_object.h>
56 #include <vm/vm_extern.h>
57 #include <vm/vm_zone.h>
59 #if defined(__NetBSD__)
60 #include <miscfs/specfs/specdev.h>
63 /*#define NTFS_DEBUG 1*/
64 #include <ntfs/ntfs.h>
65 #include <ntfs/ntfs_inode.h>
66 #include <ntfs/ntfs_subr.h>
67 #include <ntfs/ntfs_vfsops.h>
68 #include <ntfs/ntfs_ihash.h>
69 #include <ntfs/ntfsmount.h>
71 #if defined(__FreeBSD__)
72 MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
73 MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
74 MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
75 MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
78 static int ntfs_root __P((struct mount *, struct vnode **));
79 static int ntfs_statfs __P((struct mount *, struct statfs *,
81 static int ntfs_unmount __P((struct mount *, int, struct thread *));
82 static int ntfs_vget __P((struct mount *mp, ino_t ino,
84 static int ntfs_mountfs __P((register struct vnode *, struct mount *,
85 struct ntfs_args *, struct thread *));
86 static int ntfs_vptofh __P((struct vnode *, struct fid *));
87 static int ntfs_fhtovp __P((struct mount *, struct fid *,
90 #if !defined (__FreeBSD__)
91 static int ntfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
93 static int ntfs_start __P((struct mount *, int, struct thread *));
94 static int ntfs_sync __P((struct mount *, int, struct ucred *,
98 #if defined(__FreeBSD__)
100 static int ntfs_mount __P((struct mount *, char *, caddr_t,
101 struct nameidata *, struct thread *));
102 static int ntfs_init __P((struct vfsconf *));
103 static int ntfs_checkexp __P((struct mount *, struct sockaddr *,
104 int *, struct ucred **));
105 #elif defined(__NetBSD__)
106 static int ntfs_mount __P((struct mount *, const char *, void *,
107 struct nameidata *, struct thread *));
108 static void ntfs_init __P((void));
109 static int ntfs_mountroot __P((void));
110 static int ntfs_sysctl __P((int *, u_int, void *, size_t *, void *,
111 size_t, struct thread *));
112 static int ntfs_checkexp __P((struct mount *, struct mbuf *,
113 int *, struct ucred **));
117 * Verify a remote client has export rights and return these rights via.
118 * exflagsp and credanonp.
121 ntfs_checkexp(mp, nam, exflagsp, credanonp)
122 #if defined(__FreeBSD__)
123 register struct mount *mp;
124 struct sockaddr *nam;
126 struct ucred **credanonp;
127 #else /* defined(__NetBSD__) */
128 register struct mount *mp;
131 struct ucred **credanonp;
134 register struct netcred *np;
135 register 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(name, namelen, oldp, oldlenp, newp, newlen, td)
168 extern struct vnode *rootvp;
169 struct thread *td = curthread; /* XXX */
171 struct ntfs_args args;
173 if (root_device->dv_class != DV_DISK)
177 * Get vnodes for rootdev.
179 if (bdevvp(rootdev, &rootvp))
180 panic("ntfs_mountroot: can't setup rootvp");
182 if ((error = vfs_rootmountalloc(MOUNT_NTFS, "root_device", &mp))) {
192 if ((error = ntfs_mountfs(rootvp, mp, &args, td)) != 0) {
193 mp->mnt_op->vfs_refcount--;
200 simple_lock(&mountlist_slock);
201 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
202 simple_unlock(&mountlist_slock);
203 (void)ntfs_statfs(mp, &mp->mnt_stat, td);
215 #elif defined(__FreeBSD__)
219 struct vfsconf *vcp )
231 #if defined(__FreeBSD__)
238 struct nameidata *ndp,
244 struct ntfs_args args;
248 * Use NULL path to flag a root mount
253 * Mounting root file system
257 /* Get vnode for root device*/
258 if( bdevvp( rootdev, &rootvp))
259 panic("ffs_mountroot: can't setup bdevvp for root");
262 * FS specific handling
264 mp->mnt_flag |= MNT_RDONLY; /* XXX globally applicable?*/
269 if( ( err = ntfs_mountfs(rootvp, mp, &args, td)) != 0) {
270 /* fs specific cleanup (if any)*/
274 goto dostatfs; /* success*/
281 * Mounting non-root file system or updating a file system
285 /* copy in user arguments*/
286 err = copyin(data, (caddr_t)&args, sizeof (struct ntfs_args));
288 goto error_1; /* can't get arguments*/
291 * If updating, check whether changing from read-only to
292 * read/write; if there is no device name, that's all we do.
294 if (mp->mnt_flag & MNT_UPDATE) {
295 /* if not updating name...*/
296 if (args.fspec == 0) {
298 * Process export requests. Jumping to "success"
299 * will return the vfs_export() error code.
301 struct ntfsmount *ntm = VFSTONTFS(mp);
302 err = vfs_export(mp, &ntm->ntm_export, &args.export);
306 printf("ntfs_mount(): MNT_UPDATE not supported\n");
312 * Not an update, or updating the name: look up the name
313 * and verify that it refers to a sensible block device.
315 NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td);
318 /* can't get devvp!*/
321 NDFREE(ndp, NDF_ONLY_PNBUF);
324 #if defined(__FreeBSD__)
325 if (!vn_isdisk(devvp, &err))
328 if (devvp->v_type != VBLK) {
332 if (major(devvp->v_rdev) >= nblkdev) {
337 if (mp->mnt_flag & MNT_UPDATE) {
345 if (devvp != ntmp->um_devvp)
346 err = EINVAL; /* needs translation */
350 * Update device name only on success
353 /* Save "mounted from" info for mount point (NULL pad)*/
354 copyinstr( args.fspec,
355 mp->mnt_stat.f_mntfromname,
358 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
369 * Since this is a new mount, we want the names for
370 * the device and the mount point copied in. If an
371 * error occurs, the mountpoint is discarded by the
374 /* Save "last mounted on" info for mount point (NULL pad)*/
375 copyinstr( path, /* mount point*/
376 mp->mnt_stat.f_mntonname, /* save area*/
377 MNAMELEN - 1, /* max size*/
378 &size); /* real size*/
379 bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
381 /* Save "mounted from" info for mount point (NULL pad)*/
382 copyinstr( args.fspec, /* device name*/
383 mp->mnt_stat.f_mntfromname, /* save area*/
384 MNAMELEN - 1, /* max size*/
385 &size); /* real size*/
386 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
388 err = ntfs_mountfs(devvp, mp, &args, td);
398 * Initialize FS stat information in mount struct; uses both
399 * mp->mnt_stat.f_mntonname and mp->mnt_stat.f_mntfromname
401 * This code is common to root and non-root mounts
403 (void)VFS_STATFS(mp, &mp->mnt_stat, td);
408 error_2: /* error with devvp held*/
410 /* release devvp before failing*/
413 error_1: /* no state to back out*/
420 * Common code for mount and mountroot
423 ntfs_mountfs(devvp, mp, argsp, td)
424 register struct vnode *devvp;
426 struct ntfs_args *argsp;
430 struct ntfsmount *ntmp;
431 dev_t dev = devvp->v_rdev;
432 int error, ronly, ncount, i;
436 KKASSERT(td->td_proc);
437 cred = td->td_proc->p_ucred;
440 * Disallow multiple mounts of the same device.
441 * Disallow mounting of a device that is currently in use
442 * (except for root, which might share swap device for miniroot).
443 * Flush out any old buffers remaining from a previous use.
445 error = vfs_mountedon(devvp);
448 ncount = vcount(devvp);
449 #if defined(__FreeBSD__)
453 if (ncount > 1 && devvp != rootvp)
455 #if defined(__FreeBSD__)
456 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
457 error = vinvalbuf(devvp, V_SAVE, cred, td, 0, 0);
458 VOP__UNLOCK(devvp, 0, td);
460 error = vinvalbuf(devvp, V_SAVE, cred, td, 0, 0);
465 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
466 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
467 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td);
468 VOP__UNLOCK(devvp, 0, td);
474 error = bread(devvp, BBLOCK, BBSIZE, NOCRED, &bp);
477 ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK );
478 bzero( ntmp, sizeof *ntmp );
479 bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
483 if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
485 dprintf(("ntfs_mountfs: invalid boot block\n"));
490 int8_t cpr = ntmp->ntm_mftrecsz;
492 ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
494 ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
496 dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
497 ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
498 ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
499 dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
500 (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
502 ntmp->ntm_mountp = mp;
504 ntmp->ntm_devvp = devvp;
505 ntmp->ntm_uid = argsp->uid;
506 ntmp->ntm_gid = argsp->gid;
507 ntmp->ntm_mode = argsp->mode;
508 ntmp->ntm_flag = argsp->flag;
510 /* Copy in the 8-bit to Unicode conversion table */
511 if (argsp->flag & NTFSMNT_U2WTABLE) {
512 ntfs_82u_init(ntmp, argsp->u2w);
514 ntfs_82u_init(ntmp, NULL);
517 /* Initialize Unicode to 8-bit table from 8toU table */
518 ntfs_u28_init(ntmp, ntmp->ntm_82u);
520 mp->mnt_data = (qaddr_t)ntmp;
522 dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
523 (ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
524 (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
525 ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
528 * We read in some system nodes to do not allow
529 * reclaim them and to have everytime access to them.
532 int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
533 for (i=0; i<3; i++) {
534 error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]]));
537 ntmp->ntm_sysvn[pi[i]]->v_flag |= VSYSTEM;
538 VREF(ntmp->ntm_sysvn[pi[i]]);
539 vput(ntmp->ntm_sysvn[pi[i]]);
543 /* read the Unicode lowercase --> uppercase translation table,
545 if ((error = ntfs_toupper_use(mp, ntmp)))
549 * Scan $BitMap and count free clusters
551 error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
556 * Read and translate to internal format attribute
564 error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
568 /* Count valid entries */
570 error = ntfs_readattr(ntmp, VTONT(vp),
572 num * sizeof(ad), sizeof(ad),
576 if (ad.ad_name[0] == 0)
580 /* Alloc memory for attribute definitions */
581 MALLOC(ntmp->ntm_ad, struct ntvattrdef *,
582 num * sizeof(struct ntvattrdef),
583 M_NTFSMNT, M_WAITOK);
585 ntmp->ntm_adnum = num;
587 /* Read them and translate */
589 error = ntfs_readattr(ntmp, VTONT(vp),
591 i * sizeof(ad), sizeof(ad),
597 ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
598 } while(ad.ad_name[j++]);
599 ntmp->ntm_ad[i].ad_namelen = j - 1;
600 ntmp->ntm_ad[i].ad_type = ad.ad_type;
606 #if defined(__FreeBSD__)
607 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
608 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
610 mp->mnt_stat.f_fsid.val[0] = dev;
611 mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
613 mp->mnt_maxsymlinklen = 0;
614 mp->mnt_flag |= MNT_LOCAL;
615 devvp->v_specmountpoint = mp;
619 for(i=0;i<NTFS_SYSNODESNUM;i++)
620 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
622 if (vflush(mp, 0, 0))
623 dprintf(("ntfs_mountfs: vflush failed\n"));
626 devvp->v_specmountpoint = NULL;
630 #if defined __NetBSD__
631 /* lock the device vnode before calling VOP_CLOSE() */
632 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
633 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td);
634 VOP__UNLOCK(devvp, 0, td);
636 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td);
642 #if !defined(__FreeBSD__)
659 register struct ntfsmount *ntmp;
660 int error, ronly = 0, flags, i;
662 dprintf(("ntfs_unmount: unmounting...\n"));
663 ntmp = VFSTONTFS(mp);
666 if(mntflags & MNT_FORCE)
669 dprintf(("ntfs_unmount: vflushing...\n"));
670 error = vflush(mp, 0, flags | SKIPSYSTEM);
672 printf("ntfs_unmount: vflush failed: %d\n",error);
676 /* Check if only system vnodes are rest */
677 for(i=0;i<NTFS_SYSNODESNUM;i++)
678 if((ntmp->ntm_sysvn[i]) &&
679 (ntmp->ntm_sysvn[i]->v_usecount > 1)) return (EBUSY);
681 /* Dereference all system vnodes */
682 for(i=0;i<NTFS_SYSNODESNUM;i++)
683 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
685 /* vflush system vnodes */
686 error = vflush(mp, 0, flags);
688 printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
690 /* Check if the type of device node isn't VBAD before
691 * touching v_specinfo. If the device vnode is revoked, the
692 * field is NULL and touching it causes null pointer derefercence.
694 if (ntmp->ntm_devvp->v_type != VBAD)
695 ntmp->ntm_devvp->v_specmountpoint = NULL;
697 vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, td, 0, 0);
699 #if defined(__NetBSD__)
700 /* lock the device vnode before calling VOP_CLOSE() */
701 VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY);
702 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
704 VOP__UNLOCK(ntmp->ntm_devvp, 0, td);
706 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
710 vrele(ntmp->ntm_devvp);
712 /* free the toupper table, if this has been last mounted ntfs volume */
713 ntfs_toupper_unuse();
715 dprintf(("ntfs_umount: freeing memory...\n"));
716 ntfs_u28_uninit(ntmp);
717 ntfs_82u_uninit(ntmp);
718 mp->mnt_data = (qaddr_t)0;
719 mp->mnt_flag &= ~MNT_LOCAL;
720 FREE(ntmp->ntm_ad, M_NTFSMNT);
721 FREE(ntmp, M_NTFSMNT);
733 dprintf(("ntfs_root(): sysvn: %p\n",
734 VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
735 error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp);
737 printf("ntfs_root: VFS_VGET failed: %d\n",error);
745 #if !defined(__FreeBSD__)
754 printf("\nntfs_quotactl():\n");
761 struct ntfsmount *ntmp,
770 vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
772 bmsize = VTOF(vp)->f_size;
774 MALLOC(tmp, u_int8_t *, bmsize, M_TEMP, M_WAITOK);
776 error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
777 0, bmsize, tmp, NULL);
781 for(i=0;i<bmsize;i++)
783 if(~tmp[i] & (1 << j)) cfree++;
797 struct ntfsmount *ntmp = VFSTONTFS(mp);
798 u_int64_t mftsize,mftallocated;
800 dprintf(("ntfs_statfs():\n"));
802 mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
803 mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
805 #if defined(__FreeBSD__)
806 sbp->f_type = mp->mnt_vfc->vfc_typenum;
807 #elif defined(__NetBSD__)
810 sbp->f_type = MOUNT_NTFS;
812 sbp->f_bsize = ntmp->ntm_bps;
813 sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
814 sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
815 sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
816 sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
817 sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
819 if (sbp != &mp->mnt_stat) {
820 bcopy((caddr_t)mp->mnt_stat.f_mntonname,
821 (caddr_t)&sbp->f_mntonname[0], MNAMELEN);
822 bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
823 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
825 sbp->f_flags = mp->mnt_flag;
827 strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
833 #if !defined(__FreeBSD__)
841 /*dprintf(("ntfs_sync():\n"));*/
854 struct ntfid *ntfhp = (struct ntfid *)fhp;
857 ddprintf(("ntfs_fhtovp(): %d\n", ntfhp->ntfid_ino));
859 if ((error = VFS_VGET(mp, ntfhp->ntfid_ino, &nvp)) != 0) {
863 /* XXX as unlink/rmdir/mkdir/creat are not currently possible
864 * with NTFS, we don't need to check anything else for now */
875 register struct ntnode *ntp;
876 register struct ntfid *ntfhp;
878 ddprintf(("ntfs_fhtovp(): %p\n", vp));
881 ntfhp = (struct ntfid *)fhp;
882 ntfhp->ntfid_len = sizeof(struct ntfid);
883 ntfhp->ntfid_ino = ntp->i_number;
884 /* ntfhp->ntfid_gen = ntp->i_gen; */
900 register struct ntfsmount *ntmp;
906 dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
907 ino, attrtype, attrname?attrname:"", (u_long)lkflags,
910 ntmp = VFSTONTFS(mp);
914 error = ntfs_ntlookup(ntmp, ino, &ip);
916 printf("ntfs_vget: ntfs_ntget failed\n");
920 /* It may be not initialized fully, so force load it */
921 if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
922 error = ntfs_loadntnode(ntmp, ip);
924 printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %d\n",
931 error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
933 printf("ntfs_vget: ntfs_fget failed\n");
939 if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
940 if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
941 (fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
943 } else if (flags & VG_EXT) {
945 fp->f_size = fp->f_allocated = 0;
949 error = ntfs_filesize(ntmp, fp,
950 &fp->f_size, &fp->f_allocated);
957 fp->f_flag |= FN_VALID;
961 VGET(FTOV(fp), lkflags, td);
967 error = getnewvnode(VT_NTFS, ntmp->ntm_mountp, ntfs_vnodeop_p, &vp);
973 dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
976 lockinit(&fp->f_lock, PINOD, "fnode", VLKTIMEOUT, 0);
982 if (ino == NTFS_ROOTINO)
987 if (lkflags & LK_TYPE_MASK) {
988 error = VN_LOCK(vp, lkflags, td);
1006 return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
1007 LK_EXCLUSIVE | LK_RETRY, 0, curthread, vpp);
1010 #if defined(__FreeBSD__)
1011 static struct vfsops ntfs_vfsops = {
1027 VFS_SET(ntfs_vfsops, ntfs, 0);
1028 #elif defined(__NetBSD__)
1029 extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
1031 struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
1032 &ntfs_vnodeop_opv_desc,
1036 struct vfsops ntfs_vfsops = {
1052 ntfs_vnodeopv_descs,
1054 #else /* !NetBSD && !FreeBSD */
1055 static struct vfsops ntfs_vfsops = {
1068 VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);