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>
34 #include <sys/namei.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>
49 #include <vm/vm_param.h>
50 #if defined(__NetBSD__)
51 #include <vm/vm_prot.h>
53 #include <vm/vm_page.h>
54 #include <vm/vm_object.h>
55 #include <vm/vm_extern.h>
56 #include <vm/vm_zone.h>
58 #if defined(__NetBSD__)
59 #include <miscfs/specfs/specdev.h>
62 /*#define NTFS_DEBUG 1*/
63 #include <ntfs/ntfs.h>
64 #include <ntfs/ntfs_inode.h>
65 #include <ntfs/ntfs_subr.h>
66 #include <ntfs/ntfs_vfsops.h>
67 #include <ntfs/ntfs_ihash.h>
68 #include <ntfs/ntfsmount.h>
70 #if defined(__FreeBSD__)
71 MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
72 MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
73 MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
74 MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
77 static int ntfs_root __P((struct mount *, struct vnode **));
78 static int ntfs_statfs __P((struct mount *, struct statfs *,
80 static int ntfs_unmount __P((struct mount *, int, struct proc *));
81 static int ntfs_vget __P((struct mount *mp, ino_t ino,
83 static int ntfs_mountfs __P((register struct vnode *, struct mount *,
84 struct ntfs_args *, struct proc *));
85 static int ntfs_vptofh __P((struct vnode *, struct fid *));
86 static int ntfs_fhtovp __P((struct mount *, struct fid *,
89 #if !defined (__FreeBSD__)
90 static int ntfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
92 static int ntfs_start __P((struct mount *, int, struct proc *));
93 static int ntfs_sync __P((struct mount *, int, struct ucred *,
97 #if defined(__FreeBSD__)
99 static int ntfs_mount __P((struct mount *, char *, caddr_t,
100 struct nameidata *, struct proc *));
101 static int ntfs_init __P((struct vfsconf *));
102 static int ntfs_checkexp __P((struct mount *, struct sockaddr *,
103 int *, struct ucred **));
104 #elif defined(__NetBSD__)
105 static int ntfs_mount __P((struct mount *, const char *, void *,
106 struct nameidata *, struct proc *));
107 static void ntfs_init __P((void));
108 static int ntfs_mountroot __P((void));
109 static int ntfs_sysctl __P((int *, u_int, void *, size_t *, void *,
110 size_t, struct proc *));
111 static int ntfs_checkexp __P((struct mount *, struct mbuf *,
112 int *, struct ucred **));
116 * Verify a remote client has export rights and return these rights via.
117 * exflagsp and credanonp.
120 ntfs_checkexp(mp, nam, exflagsp, credanonp)
121 #if defined(__FreeBSD__)
122 register struct mount *mp;
123 struct sockaddr *nam;
125 struct ucred **credanonp;
126 #else /* defined(__NetBSD__) */
127 register struct mount *mp;
130 struct ucred **credanonp;
133 register struct netcred *np;
134 register struct ntfsmount *ntm = VFSTONTFS(mp);
137 * Get the export permission structure for this <mp, client> tuple.
139 np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
143 *exflagsp = np->netc_exflags;
144 *credanonp = &np->netc_anon;
148 #if defined(__NetBSD__)
151 ntfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
167 extern struct vnode *rootvp;
168 struct proc *p = curproc; /* XXX */
170 struct ntfs_args args;
172 if (root_device->dv_class != DV_DISK)
176 * Get vnodes for rootdev.
178 if (bdevvp(rootdev, &rootvp))
179 panic("ntfs_mountroot: can't setup rootvp");
181 if ((error = vfs_rootmountalloc(MOUNT_NTFS, "root_device", &mp))) {
191 if ((error = ntfs_mountfs(rootvp, mp, &args, p)) != 0) {
192 mp->mnt_op->vfs_refcount--;
199 simple_lock(&mountlist_slock);
200 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
201 simple_unlock(&mountlist_slock);
202 (void)ntfs_statfs(mp, &mp->mnt_stat, p);
214 #elif defined(__FreeBSD__)
218 struct vfsconf *vcp )
230 #if defined(__FreeBSD__)
237 struct nameidata *ndp,
243 struct ntfs_args args;
247 * Use NULL path to flag a root mount
252 * Mounting root file system
256 /* Get vnode for root device*/
257 if( bdevvp( rootdev, &rootvp))
258 panic("ffs_mountroot: can't setup bdevvp for root");
261 * FS specific handling
263 mp->mnt_flag |= MNT_RDONLY; /* XXX globally applicable?*/
268 if( ( err = ntfs_mountfs(rootvp, mp, &args, p)) != 0) {
269 /* fs specific cleanup (if any)*/
273 goto dostatfs; /* success*/
280 * Mounting non-root file system or updating a file system
284 /* copy in user arguments*/
285 err = copyin(data, (caddr_t)&args, sizeof (struct ntfs_args));
287 goto error_1; /* can't get arguments*/
290 * If updating, check whether changing from read-only to
291 * read/write; if there is no device name, that's all we do.
293 if (mp->mnt_flag & MNT_UPDATE) {
294 /* if not updating name...*/
295 if (args.fspec == 0) {
297 * Process export requests. Jumping to "success"
298 * will return the vfs_export() error code.
300 struct ntfsmount *ntm = VFSTONTFS(mp);
301 err = vfs_export(mp, &ntm->ntm_export, &args.export);
305 printf("ntfs_mount(): MNT_UPDATE not supported\n");
311 * Not an update, or updating the name: look up the name
312 * and verify that it refers to a sensible block device.
314 NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
317 /* can't get devvp!*/
320 NDFREE(ndp, NDF_ONLY_PNBUF);
323 #if defined(__FreeBSD__)
324 if (!vn_isdisk(devvp, &err))
327 if (devvp->v_type != VBLK) {
331 if (major(devvp->v_rdev) >= nblkdev) {
336 if (mp->mnt_flag & MNT_UPDATE) {
344 if (devvp != ntmp->um_devvp)
345 err = EINVAL; /* needs translation */
349 * Update device name only on success
352 /* Save "mounted from" info for mount point (NULL pad)*/
353 copyinstr( args.fspec,
354 mp->mnt_stat.f_mntfromname,
357 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
368 * Since this is a new mount, we want the names for
369 * the device and the mount point copied in. If an
370 * error occurs, the mountpoint is discarded by the
373 /* Save "last mounted on" info for mount point (NULL pad)*/
374 copyinstr( path, /* mount point*/
375 mp->mnt_stat.f_mntonname, /* save area*/
376 MNAMELEN - 1, /* max size*/
377 &size); /* real size*/
378 bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
380 /* Save "mounted from" info for mount point (NULL pad)*/
381 copyinstr( args.fspec, /* device name*/
382 mp->mnt_stat.f_mntfromname, /* save area*/
383 MNAMELEN - 1, /* max size*/
384 &size); /* real size*/
385 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
387 err = ntfs_mountfs(devvp, mp, &args, p);
397 * Initialize FS stat information in mount struct; uses both
398 * mp->mnt_stat.f_mntonname and mp->mnt_stat.f_mntfromname
400 * This code is common to root and non-root mounts
402 (void)VFS_STATFS(mp, &mp->mnt_stat, p);
407 error_2: /* error with devvp held*/
409 /* release devvp before failing*/
412 error_1: /* no state to back out*/
419 * Common code for mount and mountroot
422 ntfs_mountfs(devvp, mp, argsp, p)
423 register struct vnode *devvp;
425 struct ntfs_args *argsp;
429 struct ntfsmount *ntmp;
430 dev_t dev = devvp->v_rdev;
431 int error, ronly, ncount, i;
435 * Disallow multiple mounts of the same device.
436 * Disallow mounting of a device that is currently in use
437 * (except for root, which might share swap device for miniroot).
438 * Flush out any old buffers remaining from a previous use.
440 error = vfs_mountedon(devvp);
443 ncount = vcount(devvp);
444 #if defined(__FreeBSD__)
448 if (ncount > 1 && devvp != rootvp)
450 #if defined(__FreeBSD__)
451 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
452 error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
453 VOP__UNLOCK(devvp, 0, p);
455 error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
460 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
461 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
462 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
463 VOP__UNLOCK(devvp, 0, p);
469 error = bread(devvp, BBLOCK, BBSIZE, NOCRED, &bp);
472 ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK );
473 bzero( ntmp, sizeof *ntmp );
474 bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
478 if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
480 dprintf(("ntfs_mountfs: invalid boot block\n"));
485 int8_t cpr = ntmp->ntm_mftrecsz;
487 ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
489 ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
491 dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
492 ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
493 ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
494 dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
495 (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
497 ntmp->ntm_mountp = mp;
499 ntmp->ntm_devvp = devvp;
500 ntmp->ntm_uid = argsp->uid;
501 ntmp->ntm_gid = argsp->gid;
502 ntmp->ntm_mode = argsp->mode;
503 ntmp->ntm_flag = argsp->flag;
505 /* Copy in the 8-bit to Unicode conversion table */
506 if (argsp->flag & NTFSMNT_U2WTABLE) {
507 ntfs_82u_init(ntmp, argsp->u2w);
509 ntfs_82u_init(ntmp, NULL);
512 /* Initialize Unicode to 8-bit table from 8toU table */
513 ntfs_u28_init(ntmp, ntmp->ntm_82u);
515 mp->mnt_data = (qaddr_t)ntmp;
517 dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
518 (ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
519 (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
520 ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
523 * We read in some system nodes to do not allow
524 * reclaim them and to have everytime access to them.
527 int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
528 for (i=0; i<3; i++) {
529 error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]]));
532 ntmp->ntm_sysvn[pi[i]]->v_flag |= VSYSTEM;
533 VREF(ntmp->ntm_sysvn[pi[i]]);
534 vput(ntmp->ntm_sysvn[pi[i]]);
538 /* read the Unicode lowercase --> uppercase translation table,
540 if ((error = ntfs_toupper_use(mp, ntmp)))
544 * Scan $BitMap and count free clusters
546 error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
551 * Read and translate to internal format attribute
559 error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
563 /* Count valid entries */
565 error = ntfs_readattr(ntmp, VTONT(vp),
567 num * sizeof(ad), sizeof(ad),
571 if (ad.ad_name[0] == 0)
575 /* Alloc memory for attribute definitions */
576 MALLOC(ntmp->ntm_ad, struct ntvattrdef *,
577 num * sizeof(struct ntvattrdef),
578 M_NTFSMNT, M_WAITOK);
580 ntmp->ntm_adnum = num;
582 /* Read them and translate */
584 error = ntfs_readattr(ntmp, VTONT(vp),
586 i * sizeof(ad), sizeof(ad),
592 ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
593 } while(ad.ad_name[j++]);
594 ntmp->ntm_ad[i].ad_namelen = j - 1;
595 ntmp->ntm_ad[i].ad_type = ad.ad_type;
601 #if defined(__FreeBSD__)
602 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
603 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
605 mp->mnt_stat.f_fsid.val[0] = dev;
606 mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
608 mp->mnt_maxsymlinklen = 0;
609 mp->mnt_flag |= MNT_LOCAL;
610 devvp->v_specmountpoint = mp;
614 for(i=0;i<NTFS_SYSNODESNUM;i++)
615 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
617 if (vflush(mp, 0, 0))
618 dprintf(("ntfs_mountfs: vflush failed\n"));
621 devvp->v_specmountpoint = NULL;
625 #if defined __NetBSD__
626 /* lock the device vnode before calling VOP_CLOSE() */
627 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
628 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
629 VOP__UNLOCK(devvp, 0, p);
631 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
637 #if !defined(__FreeBSD__)
654 register struct ntfsmount *ntmp;
655 int error, ronly = 0, flags, i;
657 dprintf(("ntfs_unmount: unmounting...\n"));
658 ntmp = VFSTONTFS(mp);
661 if(mntflags & MNT_FORCE)
664 dprintf(("ntfs_unmount: vflushing...\n"));
665 error = vflush(mp, 0, flags | SKIPSYSTEM);
667 printf("ntfs_unmount: vflush failed: %d\n",error);
671 /* Check if only system vnodes are rest */
672 for(i=0;i<NTFS_SYSNODESNUM;i++)
673 if((ntmp->ntm_sysvn[i]) &&
674 (ntmp->ntm_sysvn[i]->v_usecount > 1)) return (EBUSY);
676 /* Dereference all system vnodes */
677 for(i=0;i<NTFS_SYSNODESNUM;i++)
678 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
680 /* vflush system vnodes */
681 error = vflush(mp, 0, flags);
683 printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
685 /* Check if the type of device node isn't VBAD before
686 * touching v_specinfo. If the device vnode is revoked, the
687 * field is NULL and touching it causes null pointer derefercence.
689 if (ntmp->ntm_devvp->v_type != VBAD)
690 ntmp->ntm_devvp->v_specmountpoint = NULL;
692 vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0);
694 #if defined(__NetBSD__)
695 /* lock the device vnode before calling VOP_CLOSE() */
696 VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY);
697 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
699 VOP__UNLOCK(ntmp->ntm_devvp, 0, p);
701 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
705 vrele(ntmp->ntm_devvp);
707 /* free the toupper table, if this has been last mounted ntfs volume */
708 ntfs_toupper_unuse();
710 dprintf(("ntfs_umount: freeing memory...\n"));
711 ntfs_u28_uninit(ntmp);
712 ntfs_82u_uninit(ntmp);
713 mp->mnt_data = (qaddr_t)0;
714 mp->mnt_flag &= ~MNT_LOCAL;
715 FREE(ntmp->ntm_ad, M_NTFSMNT);
716 FREE(ntmp, M_NTFSMNT);
728 dprintf(("ntfs_root(): sysvn: %p\n",
729 VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
730 error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp);
732 printf("ntfs_root: VFS_VGET failed: %d\n",error);
740 #if !defined(__FreeBSD__)
749 printf("\nntfs_quotactl():\n");
756 struct ntfsmount *ntmp,
765 vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
767 bmsize = VTOF(vp)->f_size;
769 MALLOC(tmp, u_int8_t *, bmsize, M_TEMP, M_WAITOK);
771 error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
772 0, bmsize, tmp, NULL);
776 for(i=0;i<bmsize;i++)
778 if(~tmp[i] & (1 << j)) cfree++;
792 struct ntfsmount *ntmp = VFSTONTFS(mp);
793 u_int64_t mftsize,mftallocated;
795 dprintf(("ntfs_statfs():\n"));
797 mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
798 mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
800 #if defined(__FreeBSD__)
801 sbp->f_type = mp->mnt_vfc->vfc_typenum;
802 #elif defined(__NetBSD__)
805 sbp->f_type = MOUNT_NTFS;
807 sbp->f_bsize = ntmp->ntm_bps;
808 sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
809 sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
810 sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
811 sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
812 sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
814 if (sbp != &mp->mnt_stat) {
815 bcopy((caddr_t)mp->mnt_stat.f_mntonname,
816 (caddr_t)&sbp->f_mntonname[0], MNAMELEN);
817 bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
818 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
820 sbp->f_flags = mp->mnt_flag;
822 strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
828 #if !defined(__FreeBSD__)
836 /*dprintf(("ntfs_sync():\n"));*/
849 struct ntfid *ntfhp = (struct ntfid *)fhp;
852 ddprintf(("ntfs_fhtovp(): %d\n", ntfhp->ntfid_ino));
854 if ((error = VFS_VGET(mp, ntfhp->ntfid_ino, &nvp)) != 0) {
858 /* XXX as unlink/rmdir/mkdir/creat are not currently possible
859 * with NTFS, we don't need to check anything else for now */
870 register struct ntnode *ntp;
871 register struct ntfid *ntfhp;
873 ddprintf(("ntfs_fhtovp(): %p\n", vp));
876 ntfhp = (struct ntfid *)fhp;
877 ntfhp->ntfid_len = sizeof(struct ntfid);
878 ntfhp->ntfid_ino = ntp->i_number;
879 /* ntfhp->ntfid_gen = ntp->i_gen; */
895 register struct ntfsmount *ntmp;
901 dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
902 ino, attrtype, attrname?attrname:"", (u_long)lkflags,
905 ntmp = VFSTONTFS(mp);
909 error = ntfs_ntlookup(ntmp, ino, &ip);
911 printf("ntfs_vget: ntfs_ntget failed\n");
915 /* It may be not initialized fully, so force load it */
916 if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
917 error = ntfs_loadntnode(ntmp, ip);
919 printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %d\n",
926 error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
928 printf("ntfs_vget: ntfs_fget failed\n");
934 if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
935 if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
936 (fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
938 } else if (flags & VG_EXT) {
940 fp->f_size = fp->f_allocated = 0;
944 error = ntfs_filesize(ntmp, fp,
945 &fp->f_size, &fp->f_allocated);
952 fp->f_flag |= FN_VALID;
956 VGET(FTOV(fp), lkflags, p);
962 error = getnewvnode(VT_NTFS, ntmp->ntm_mountp, ntfs_vnodeop_p, &vp);
968 dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
971 lockinit(&fp->f_lock, PINOD, "fnode", VLKTIMEOUT, 0);
977 if (ino == NTFS_ROOTINO)
982 if (lkflags & LK_TYPE_MASK) {
983 error = VN_LOCK(vp, lkflags, p);
1001 return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
1002 LK_EXCLUSIVE | LK_RETRY, 0, curproc, vpp);
1005 #if defined(__FreeBSD__)
1006 static struct vfsops ntfs_vfsops = {
1022 VFS_SET(ntfs_vfsops, ntfs, 0);
1023 #elif defined(__NetBSD__)
1024 extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
1026 struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
1027 &ntfs_vnodeop_opv_desc,
1031 struct vfsops ntfs_vfsops = {
1047 ntfs_vnodeopv_descs,
1049 #else /* !NetBSD && !FreeBSD */
1050 static struct vfsops ntfs_vfsops = {
1063 VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);