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.18 2004/08/13 17:51:12 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*/
65 #include "ntfs_inode.h"
66 #include "ntfs_subr.h"
67 #include "ntfs_vfsops.h"
68 #include "ntfs_ihash.h"
69 #include "ntfsmount.h"
71 #if defined(__DragonFly__)
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 (struct mount *, struct vnode **);
79 static int ntfs_statfs (struct mount *, struct statfs *,
81 static int ntfs_unmount (struct mount *, int, struct thread *);
82 static int ntfs_vget (struct mount *mp, ino_t ino,
84 static int ntfs_mountfs (struct vnode *, struct mount *,
85 struct ntfs_args *, struct thread *);
86 static int ntfs_vptofh (struct vnode *, struct fid *);
87 static int ntfs_fhtovp (struct mount *, struct fid *,
90 #if !defined (__DragonFly__)
91 static int ntfs_quotactl (struct mount *, int, uid_t, caddr_t,
93 static int ntfs_start (struct mount *, int, struct thread *);
94 static int ntfs_sync (struct mount *, int, struct ucred *,
98 #if defined(__DragonFly__)
100 static int ntfs_mount (struct mount *, char *, caddr_t,
101 struct nameidata *, struct thread *);
102 static int ntfs_init (struct vfsconf *);
103 static int ntfs_checkexp (struct mount *, struct sockaddr *,
104 int *, struct ucred **);
105 #elif defined(__NetBSD__)
106 static int ntfs_mount (struct mount *, const char *, void *,
107 struct nameidata *, struct thread *);
108 static void ntfs_init (void);
109 static int ntfs_mountroot (void);
110 static int ntfs_sysctl (int *, u_int, void *, size_t *, void *,
111 size_t, struct thread *);
112 static int ntfs_checkexp (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(struct mount *mp,
122 #if defined(__DragonFly__)
123 struct sockaddr *nam,
124 #else /* defined(__NetBSD__) */
127 int *exflagsp, struct ucred **credanonp)
130 struct ntfsmount *ntm = VFSTONTFS(mp);
133 * Get the export permission structure for this <mp, client> tuple.
135 np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
139 *exflagsp = np->netc_exflags;
140 *credanonp = &np->netc_anon;
144 #if defined(__NetBSD__)
147 ntfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
148 size_t newlen, struct thread *td)
157 extern struct vnode *rootvp;
158 struct thread *td = curthread; /* XXX */
159 struct ntfs_args args;
163 if (root_device->dv_class != DV_DISK)
167 * Get vnodes for rootdev.
169 if (bdevvp(rootdev, &rootvp))
170 panic("ntfs_mountroot: can't setup rootvp");
172 if ((error = vfs_rootmountalloc(MOUNT_NTFS, "root_device", &mp))) {
182 if ((error = ntfs_mountfs(rootvp, mp, &args, td)) != 0) {
183 mp->mnt_op->vfs_refcount--;
190 lwkt_gettoken(&ilock, &mountlist_token);
191 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
192 lwkt_reltoken(&ilock);
193 (void)ntfs_statfs(mp, &mp->mnt_stat, td);
205 #elif defined(__DragonFly__)
208 ntfs_init(struct vfsconf *vcp)
218 ntfs_mount(struct mount *mp,
219 #if defined(__DragonFly__)
220 char *path, caddr_t data,
222 const char *path, void *data,
224 struct nameidata *ndp, struct thread *td)
229 struct ntfs_args args;
233 * Use NULL path to flag a root mount
238 * Mounting root file system
242 /* Get vnode for root device*/
243 if( bdevvp( rootdev, &rootvp))
244 panic("ffs_mountroot: can't setup bdevvp for root");
247 * FS specific handling
249 mp->mnt_flag |= MNT_RDONLY; /* XXX globally applicable?*/
254 if( ( err = ntfs_mountfs(rootvp, mp, &args, td)) != 0) {
255 /* fs specific cleanup (if any)*/
259 goto dostatfs; /* success*/
266 * Mounting non-root file system or updating a file system
270 /* copy in user arguments*/
271 err = copyin(data, (caddr_t)&args, sizeof (struct ntfs_args));
273 goto error_1; /* can't get arguments*/
276 * If updating, check whether changing from read-only to
277 * read/write; if there is no device name, that's all we do.
279 if (mp->mnt_flag & MNT_UPDATE) {
280 /* if not updating name...*/
281 if (args.fspec == 0) {
283 * Process export requests. Jumping to "success"
284 * will return the vfs_export() error code.
286 struct ntfsmount *ntm = VFSTONTFS(mp);
287 err = vfs_export(mp, &ntm->ntm_export, &args.export);
291 printf("ntfs_mount(): MNT_UPDATE not supported\n");
297 * Not an update, or updating the name: look up the name
298 * and verify that it refers to a sensible block device.
300 NDINIT(ndp, NAMEI_LOOKUP, CNP_FOLLOW, UIO_USERSPACE, args.fspec, td);
303 /* can't get devvp!*/
306 NDFREE(ndp, NDF_ONLY_PNBUF);
309 #if defined(__DragonFly__)
310 if (!vn_isdisk(devvp, &err))
313 if (devvp->v_type != VBLK) {
317 if (umajor(devvp->v_udev) >= nblkdev) {
322 if (mp->mnt_flag & MNT_UPDATE) {
330 if (devvp != ntmp->um_devvp)
331 err = EINVAL; /* needs translation */
335 * Update device name only on success
338 /* Save "mounted from" info for mount point (NULL pad)*/
339 copyinstr( args.fspec,
340 mp->mnt_stat.f_mntfromname,
343 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
354 * Since this is a new mount, we want the names for
355 * the device and the mount point copied in. If an
356 * error occurs, the mountpoint is discarded by the
359 /* Save "last mounted on" info for mount point (NULL pad)*/
360 copyinstr( path, /* mount point*/
361 mp->mnt_stat.f_mntonname, /* save area*/
362 MNAMELEN - 1, /* max size*/
363 &size); /* real size*/
364 bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
366 /* Save "mounted from" info for mount point (NULL pad)*/
367 copyinstr( args.fspec, /* device name*/
368 mp->mnt_stat.f_mntfromname, /* save area*/
369 MNAMELEN - 1, /* max size*/
370 &size); /* real size*/
371 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
373 err = ntfs_mountfs(devvp, mp, &args, td);
383 * Initialize FS stat information in mount struct; uses both
384 * mp->mnt_stat.f_mntonname and mp->mnt_stat.f_mntfromname
386 * This code is common to root and non-root mounts
388 (void)VFS_STATFS(mp, &mp->mnt_stat, td);
393 error_2: /* error with devvp held*/
395 /* release devvp before failing*/
398 error_1: /* no state to back out*/
405 * Common code for mount and mountroot
408 ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp,
412 struct ntfsmount *ntmp;
414 int error, ronly, ncount, i;
418 KKASSERT(td->td_proc);
419 cred = td->td_proc->p_ucred;
422 * Disallow multiple mounts of the same device.
423 * Disallow mounting of a device that is currently in use
424 * (except for root, which might share swap device for miniroot).
425 * Flush out any old buffers remaining from a previous use.
427 error = vfs_mountedon(devvp);
430 ncount = count_udev(devvp->v_udev);
431 #if defined(__DragonFly__)
435 if (ncount > 1 && devvp != rootvp)
437 #if defined(__DragonFly__)
438 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
439 error = vinvalbuf(devvp, V_SAVE, td, 0, 0);
440 VOP__UNLOCK(devvp, 0, td);
442 error = vinvalbuf(devvp, V_SAVE, td, 0, 0);
447 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
448 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
449 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td);
450 VOP__UNLOCK(devvp, 0, td);
457 error = bread(devvp, BBLOCK, BBSIZE, &bp);
460 ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK );
461 bzero( ntmp, sizeof *ntmp );
462 bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
466 if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
468 dprintf(("ntfs_mountfs: invalid boot block\n"));
473 int8_t cpr = ntmp->ntm_mftrecsz;
475 ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
477 ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
479 dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
480 ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
481 ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
482 dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
483 (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
485 ntmp->ntm_mountp = mp;
487 ntmp->ntm_devvp = devvp;
488 ntmp->ntm_uid = argsp->uid;
489 ntmp->ntm_gid = argsp->gid;
490 ntmp->ntm_mode = argsp->mode;
491 ntmp->ntm_flag = argsp->flag;
493 /* Copy in the 8-bit to Unicode conversion table */
494 if (argsp->flag & NTFSMNT_U2WTABLE) {
495 ntfs_82u_init(ntmp, argsp->u2w);
497 ntfs_82u_init(ntmp, NULL);
500 /* Initialize Unicode to 8-bit table from 8toU table */
501 ntfs_u28_init(ntmp, ntmp->ntm_82u);
503 mp->mnt_data = (qaddr_t)ntmp;
505 dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
506 (ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
507 (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
508 ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
511 * We read in some system nodes to do not allow
512 * reclaim them and to have everytime access to them.
515 int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
516 for (i=0; i<3; i++) {
517 error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]]));
520 ntmp->ntm_sysvn[pi[i]]->v_flag |= VSYSTEM;
521 vref(ntmp->ntm_sysvn[pi[i]]);
522 vput(ntmp->ntm_sysvn[pi[i]]);
526 /* read the Unicode lowercase --> uppercase translation table,
528 if ((error = ntfs_toupper_use(mp, ntmp)))
532 * Scan $BitMap and count free clusters
534 error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
539 * Read and translate to internal format attribute
547 error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
551 /* Count valid entries */
553 error = ntfs_readattr(ntmp, VTONT(vp),
555 num * sizeof(ad), sizeof(ad),
559 if (ad.ad_name[0] == 0)
563 /* Alloc memory for attribute definitions */
564 MALLOC(ntmp->ntm_ad, struct ntvattrdef *,
565 num * sizeof(struct ntvattrdef),
566 M_NTFSMNT, M_WAITOK);
568 ntmp->ntm_adnum = num;
570 /* Read them and translate */
572 error = ntfs_readattr(ntmp, VTONT(vp),
574 i * sizeof(ad), sizeof(ad),
580 ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
581 } while(ad.ad_name[j++]);
582 ntmp->ntm_ad[i].ad_namelen = j - 1;
583 ntmp->ntm_ad[i].ad_type = ad.ad_type;
589 #if defined(__DragonFly__)
590 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
591 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
593 mp->mnt_stat.f_fsid.val[0] = dev;
594 mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
596 mp->mnt_maxsymlinklen = 0;
597 mp->mnt_flag |= MNT_LOCAL;
598 dev->si_mountpoint = mp;
602 for(i=0;i<NTFS_SYSNODESNUM;i++)
603 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
605 if (vflush(mp, 0, 0))
606 dprintf(("ntfs_mountfs: vflush failed\n"));
609 dev->si_mountpoint = NULL;
613 #if defined __NetBSD__
614 /* lock the device vnode before calling VOP_CLOSE() */
615 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
616 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, td);
617 VOP__UNLOCK(devvp, 0, td);
619 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, td);
625 #if !defined(__DragonFly__)
627 ntfs_start(struct mount *mp, int flags, struct thread *td)
634 ntfs_unmount(struct mount *mp, int mntflags, struct thread *td)
636 struct ntfsmount *ntmp;
637 int error, ronly = 0, flags, i;
639 dprintf(("ntfs_unmount: unmounting...\n"));
640 ntmp = VFSTONTFS(mp);
643 if(mntflags & MNT_FORCE)
646 dprintf(("ntfs_unmount: vflushing...\n"));
647 error = vflush(mp, 0, flags | SKIPSYSTEM);
649 printf("ntfs_unmount: vflush failed: %d\n",error);
653 /* Check if only system vnodes are rest */
654 for(i=0;i<NTFS_SYSNODESNUM;i++)
655 if((ntmp->ntm_sysvn[i]) &&
656 (ntmp->ntm_sysvn[i]->v_usecount > 1)) return (EBUSY);
658 /* Dereference all system vnodes */
659 for(i=0;i<NTFS_SYSNODESNUM;i++)
660 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
662 /* vflush system vnodes */
663 error = vflush(mp, 0, flags);
665 printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
667 /* Check if the type of device node isn't VBAD before
668 * touching v_specinfo. If the device vnode is revoked, the
669 * field is NULL and touching it causes null pointer derefercence.
671 if (ntmp->ntm_devvp->v_type != VBAD)
672 ntmp->ntm_devvp->v_rdev->si_mountpoint = NULL;
674 vinvalbuf(ntmp->ntm_devvp, V_SAVE, td, 0, 0);
676 #if defined(__NetBSD__)
677 /* lock the device vnode before calling VOP_CLOSE() */
678 VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY);
679 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, td);
680 VOP__UNLOCK(ntmp->ntm_devvp, 0, td);
682 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, td);
685 vrele(ntmp->ntm_devvp);
687 /* free the toupper table, if this has been last mounted ntfs volume */
688 ntfs_toupper_unuse();
690 dprintf(("ntfs_umount: freeing memory...\n"));
691 ntfs_u28_uninit(ntmp);
692 ntfs_82u_uninit(ntmp);
693 mp->mnt_data = (qaddr_t)0;
694 mp->mnt_flag &= ~MNT_LOCAL;
695 FREE(ntmp->ntm_ad, M_NTFSMNT);
696 FREE(ntmp, M_NTFSMNT);
701 ntfs_root(struct mount *mp, struct vnode **vpp)
706 dprintf(("ntfs_root(): sysvn: %p\n",
707 VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
708 error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp);
710 printf("ntfs_root: VFS_VGET failed: %d\n",error);
718 #if !defined(__DragonFly__)
720 ntfs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
723 printf("\nntfs_quotactl():\n");
729 ntfs_calccfree(struct ntfsmount *ntmp, cn_t *cfreep)
737 vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
739 bmsize = VTOF(vp)->f_size;
741 MALLOC(tmp, u_int8_t *, bmsize, M_TEMP, M_WAITOK);
743 error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
744 0, bmsize, tmp, NULL);
748 for(i=0;i<bmsize;i++)
750 if(~tmp[i] & (1 << j)) cfree++;
759 ntfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
761 struct ntfsmount *ntmp = VFSTONTFS(mp);
762 u_int64_t mftsize,mftallocated;
764 dprintf(("ntfs_statfs():\n"));
766 mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
767 mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
769 #if defined(__DragonFly__)
770 sbp->f_type = mp->mnt_vfc->vfc_typenum;
771 #elif defined(__NetBSD__)
774 sbp->f_type = MOUNT_NTFS;
776 sbp->f_bsize = ntmp->ntm_bps;
777 sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
778 sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
779 sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
780 sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
781 sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
783 if (sbp != &mp->mnt_stat) {
784 bcopy((caddr_t)mp->mnt_stat.f_mntonname,
785 (caddr_t)&sbp->f_mntonname[0], MNAMELEN);
786 bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
787 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
789 sbp->f_flags = mp->mnt_flag;
791 strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
797 #if !defined(__DragonFly__)
799 ntfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td)
801 /*dprintf(("ntfs_sync():\n"));*/
808 ntfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
811 struct ntfid *ntfhp = (struct ntfid *)fhp;
814 ddprintf(("ntfs_fhtovp(): %d\n", ntfhp->ntfid_ino));
816 if ((error = VFS_VGET(mp, ntfhp->ntfid_ino, &nvp)) != 0) {
820 /* XXX as unlink/rmdir/mkdir/creat are not currently possible
821 * with NTFS, we don't need to check anything else for now */
828 ntfs_vptofh(struct vnode *vp, struct fid *fhp)
833 ddprintf(("ntfs_fhtovp(): %p\n", vp));
836 ntfhp = (struct ntfid *)fhp;
837 ntfhp->ntfid_len = sizeof(struct ntfid);
838 ntfhp->ntfid_ino = ntp->i_number;
839 /* ntfhp->ntfid_gen = ntp->i_gen; */
844 ntfs_vgetex(struct mount *mp, ino_t ino, u_int32_t attrtype, char *attrname,
845 u_long lkflags, u_long flags, struct thread *td,
849 struct ntfsmount *ntmp;
855 dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
856 ino, attrtype, attrname?attrname:"", (u_long)lkflags,
859 ntmp = VFSTONTFS(mp);
863 error = ntfs_ntlookup(ntmp, ino, &ip);
865 printf("ntfs_vget: ntfs_ntget failed\n");
869 /* It may be not initialized fully, so force load it */
870 if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
871 error = ntfs_loadntnode(ntmp, ip);
873 printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %d\n",
880 error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
882 printf("ntfs_vget: ntfs_fget failed\n");
888 if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
889 if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
890 (fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
892 } else if (flags & VG_EXT) {
894 fp->f_size = fp->f_allocated = 0;
898 error = ntfs_filesize(ntmp, fp,
899 &fp->f_size, &fp->f_allocated);
906 fp->f_flag |= FN_VALID;
910 VGET(FTOV(fp), lkflags, td);
916 error = getnewvnode(VT_NTFS, ntmp->ntm_mountp, ntfs_vnode_vops, &vp);
922 dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
925 lockinit(&fp->f_lock, 0, "fnode", VLKTIMEOUT, 0);
931 if (ino == NTFS_ROOTINO)
936 if (lkflags & LK_TYPE_MASK) {
937 KKASSERT((lkflags & LK_INTERLOCK) == 0);
938 error = VN_LOCK(vp, lkflags, td);
951 ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
953 return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
954 LK_EXCLUSIVE | LK_RETRY, 0, curthread, vpp);
957 #if defined(__DragonFly__)
958 static struct vfsops ntfs_vfsops = {
971 ntfs_nthash_uninit, /* see ntfs_ihash.c */
974 VFS_SET(ntfs_vfsops, ntfs, 0);
975 #elif defined(__NetBSD__)
976 extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
978 struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
979 &ntfs_vnodeop_opv_desc,
983 struct vfsops ntfs_vfsops = {
1001 #else /* !NetBSD && !FreeBSD */
1002 static struct vfsops ntfs_vfsops = {
1015 VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);