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.29 2005/08/02 13:03:55 joerg Exp $
33 #include <sys/param.h>
34 #include <sys/systm.h>
37 #include <sys/nlookup.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>
49 #include <machine/inttypes.h>
52 #include <vm/vm_param.h>
53 #if defined(__NetBSD__)
54 #include <vm/vm_prot.h>
56 #include <vm/vm_page.h>
57 #include <vm/vm_object.h>
58 #include <vm/vm_extern.h>
59 #include <vm/vm_zone.h>
61 #if defined(__NetBSD__)
62 #include <miscfs/specfs/specdev.h>
65 /*#define NTFS_DEBUG 1*/
67 #include "ntfs_inode.h"
68 #include "ntfs_subr.h"
69 #include "ntfs_vfsops.h"
70 #include "ntfs_ihash.h"
71 #include "ntfsmount.h"
73 extern struct vnodeopv_entry_desc ntfs_vnodeop_entries[];
75 #if defined(__DragonFly__)
76 MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
77 MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
78 MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
79 MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
82 static int ntfs_root (struct mount *, struct vnode **);
83 static int ntfs_statfs (struct mount *, struct statfs *,
85 static int ntfs_unmount (struct mount *, int, struct thread *);
86 static int ntfs_vget (struct mount *mp, ino_t ino,
88 static int ntfs_mountfs (struct vnode *, struct mount *,
89 struct ntfs_args *, struct thread *);
90 static int ntfs_vptofh (struct vnode *, struct fid *);
91 static int ntfs_fhtovp (struct mount *, struct fid *,
94 #if !defined (__DragonFly__)
95 static int ntfs_quotactl (struct mount *, int, uid_t, caddr_t,
97 static int ntfs_start (struct mount *, int, struct thread *);
98 static int ntfs_sync (struct mount *, int, struct ucred *,
102 #if defined(__DragonFly__)
104 static int ntfs_mount (struct mount *, char *, caddr_t, struct thread *);
105 static int ntfs_init (struct vfsconf *);
106 static int ntfs_checkexp (struct mount *, struct sockaddr *,
107 int *, struct ucred **);
108 #elif defined(__NetBSD__)
109 static int ntfs_mount (struct mount *, const char *, void *,
110 struct nameidata *, struct thread *);
111 static void ntfs_init (void);
112 static int ntfs_mountroot (void);
113 static int ntfs_sysctl (int *, u_int, void *, size_t *, void *,
114 size_t, struct thread *);
115 static int ntfs_checkexp (struct mount *, struct mbuf *,
116 int *, struct ucred **);
120 * Verify a remote client has export rights and return these rights via.
121 * exflagsp and credanonp.
124 ntfs_checkexp(struct mount *mp,
125 #if defined(__DragonFly__)
126 struct sockaddr *nam,
127 #else /* defined(__NetBSD__) */
130 int *exflagsp, struct ucred **credanonp)
133 struct ntfsmount *ntm = VFSTONTFS(mp);
136 * Get the export permission structure for this <mp, client> tuple.
138 np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
142 *exflagsp = np->netc_exflags;
143 *credanonp = &np->netc_anon;
147 #if defined(__NetBSD__)
150 ntfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
151 size_t newlen, struct thread *td)
160 struct vnode *rootvp;
161 struct thread *td = curthread; /* XXX */
162 struct ntfs_args args;
166 if (root_device->dv_class != DV_DISK)
170 * Get vnodes for rootdev.
172 if (bdevvp(rootdev, &rootvp))
173 panic("ntfs_mountroot: can't setup rootvp");
175 if ((error = vfs_rootmountalloc(MOUNT_NTFS, "root_device", &mp))) {
185 if ((error = ntfs_mountfs(rootvp, mp, &args, td)) != 0) {
186 mp->mnt_op->vfs_refcount--;
192 mountlist_insert(mp, MNTINS_LAST);
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,
229 struct ntfs_args args;
230 struct nlookupdata nd;
231 struct vnode *rootvp;
236 * Use NULL path to flag a root mount
241 * Mounting root file system
245 /* Get vnode for root device*/
246 if( bdevvp( rootdev, &rootvp))
247 panic("ffs_mountroot: can't setup bdevvp for root");
250 * FS specific handling
252 mp->mnt_flag |= MNT_RDONLY; /* XXX globally applicable?*/
257 if( ( error = ntfs_mountfs(rootvp, mp, &args, td)) != 0) {
258 /* fs specific cleanup (if any)*/
262 goto dostatfs; /* success*/
269 * Mounting non-root file system or updating a file system
273 /* copy in user arguments*/
274 error = copyin(data, (caddr_t)&args, sizeof (struct ntfs_args));
276 goto error_1; /* can't get arguments*/
279 * If updating, check whether changing from read-only to
280 * read/write; if there is no device name, that's all we do.
282 if (mp->mnt_flag & MNT_UPDATE) {
283 /* if not updating name...*/
284 if (args.fspec == 0) {
286 * Process export requests. Jumping to "success"
287 * will return the vfs_export() error code.
289 struct ntfsmount *ntm = VFSTONTFS(mp);
290 error = vfs_export(mp, &ntm->ntm_export, &args.export);
294 printf("ntfs_mount(): MNT_UPDATE not supported\n");
300 * Not an update, or updating the name: look up the name
301 * and verify that it refers to a sensible block device.
304 error = nlookup_init(&nd, args.fspec, UIO_USERSPACE, NLC_FOLLOW);
306 error = nlookup(&nd);
308 error = cache_vref(nd.nl_ncp, nd.nl_cred, &devvp);
313 #if defined(__DragonFly__)
314 if (!vn_isdisk(devvp, &error))
317 if (devvp->v_type != VBLK) {
321 if (umajor(devvp->v_udev) >= nblkdev) {
326 if (mp->mnt_flag & MNT_UPDATE) {
334 if (devvp != ntmp->um_devvp)
335 error = EINVAL; /* needs translation */
339 * Update device name only on success
342 /* Save "mounted from" info for mount point (NULL pad)*/
343 copyinstr( args.fspec,
344 mp->mnt_stat.f_mntfromname,
347 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
357 /* Save "mounted from" info for mount point (NULL pad)*/
358 copyinstr( args.fspec, /* device name*/
359 mp->mnt_stat.f_mntfromname, /* save area*/
360 MNAMELEN - 1, /* max size*/
361 &size); /* real size*/
362 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
364 error = ntfs_mountfs(devvp, mp, &args, td);
374 * Initialize FS stat information in mount struct; uses
375 * mp->mnt_stat.f_mntfromname.
377 * This code is common to root and non-root mounts
379 (void)VFS_STATFS(mp, &mp->mnt_stat, td);
384 error_2: /* error with devvp held*/
386 /* release devvp before failing*/
389 error_1: /* no state to back out*/
396 * Common code for mount and mountroot
399 ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp,
403 struct ntfsmount *ntmp;
405 int error, ronly, ncount, i;
409 KKASSERT(td->td_proc);
410 cred = td->td_proc->p_ucred;
413 * Disallow multiple mounts of the same device.
414 * Disallow mounting of a device that is currently in use
415 * (except for root, which might share swap device for miniroot).
416 * Flush out any old buffers remaining from a previous use.
418 error = vfs_mountedon(devvp);
421 ncount = count_udev(devvp->v_udev);
422 #if defined(__DragonFly__)
428 #if defined(__DragonFly__)
429 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
430 error = vinvalbuf(devvp, V_SAVE, td, 0, 0);
431 VOP__UNLOCK(devvp, 0, td);
433 error = vinvalbuf(devvp, V_SAVE, td, 0, 0);
438 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
439 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
440 error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, NULL, td);
441 VOP__UNLOCK(devvp, 0, td);
448 error = bread(devvp, BBLOCK, BBSIZE, &bp);
451 ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK );
452 bzero( ntmp, sizeof *ntmp );
453 bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
457 if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
459 dprintf(("ntfs_mountfs: invalid boot block\n"));
464 int8_t cpr = ntmp->ntm_mftrecsz;
466 ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
468 ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
470 dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
471 ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
472 ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
473 dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
474 (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
476 ntmp->ntm_mountp = mp;
478 ntmp->ntm_devvp = devvp;
479 ntmp->ntm_uid = argsp->uid;
480 ntmp->ntm_gid = argsp->gid;
481 ntmp->ntm_mode = argsp->mode;
482 ntmp->ntm_flag = argsp->flag;
484 /* Copy in the 8-bit to Unicode conversion table */
485 if (argsp->flag & NTFSMNT_U2WTABLE) {
486 ntfs_82u_init(ntmp, argsp->u2w);
488 ntfs_82u_init(ntmp, NULL);
491 /* Initialize Unicode to 8-bit table from 8toU table */
492 ntfs_u28_init(ntmp, ntmp->ntm_82u);
494 mp->mnt_data = (qaddr_t)ntmp;
496 dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
497 (ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
498 (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
499 ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
501 vfs_add_vnodeops(mp, &mp->mnt_vn_norm_ops, ntfs_vnodeop_entries);
504 * We read in some system nodes to do not allow
505 * reclaim them and to have everytime access to them.
508 int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
509 for (i=0; i<3; i++) {
510 error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]]));
513 ntmp->ntm_sysvn[pi[i]]->v_flag |= VSYSTEM;
514 vref(ntmp->ntm_sysvn[pi[i]]);
515 vput(ntmp->ntm_sysvn[pi[i]]);
519 /* read the Unicode lowercase --> uppercase translation table,
521 if ((error = ntfs_toupper_use(mp, ntmp)))
525 * Scan $BitMap and count free clusters
527 error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
532 * Read and translate to internal format attribute
540 error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
544 /* Count valid entries */
546 error = ntfs_readattr(ntmp, VTONT(vp),
548 num * sizeof(ad), sizeof(ad),
552 if (ad.ad_name[0] == 0)
556 /* Alloc memory for attribute definitions */
557 MALLOC(ntmp->ntm_ad, struct ntvattrdef *,
558 num * sizeof(struct ntvattrdef),
559 M_NTFSMNT, M_WAITOK);
561 ntmp->ntm_adnum = num;
563 /* Read them and translate */
565 error = ntfs_readattr(ntmp, VTONT(vp),
567 i * sizeof(ad), sizeof(ad),
573 ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
574 } while(ad.ad_name[j++]);
575 ntmp->ntm_ad[i].ad_namelen = j - 1;
576 ntmp->ntm_ad[i].ad_type = ad.ad_type;
582 #if defined(__DragonFly__)
583 mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
584 mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
586 mp->mnt_stat.f_fsid.val[0] = dev;
587 mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
589 mp->mnt_maxsymlinklen = 0;
590 mp->mnt_flag |= MNT_LOCAL;
591 dev->si_mountpoint = mp;
596 for(i=0;i<NTFS_SYSNODESNUM;i++)
597 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
599 if (vflush(mp, 0, 0))
600 dprintf(("ntfs_mountfs: vflush failed\n"));
603 dev->si_mountpoint = NULL;
607 #if defined __NetBSD__
608 /* lock the device vnode before calling VOP_CLOSE() */
609 VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
610 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, td);
611 VOP__UNLOCK(devvp, 0, td);
613 (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, td);
619 #if !defined(__DragonFly__)
621 ntfs_start(struct mount *mp, int flags, struct thread *td)
628 ntfs_unmount(struct mount *mp, int mntflags, struct thread *td)
630 struct ntfsmount *ntmp;
631 int error, ronly = 0, flags, i;
633 dprintf(("ntfs_unmount: unmounting...\n"));
634 ntmp = VFSTONTFS(mp);
637 if(mntflags & MNT_FORCE)
640 dprintf(("ntfs_unmount: vflushing...\n"));
641 error = vflush(mp, 0, flags | SKIPSYSTEM);
643 printf("ntfs_unmount: vflush failed: %d\n",error);
647 /* Check if only system vnodes are rest */
648 for(i=0;i<NTFS_SYSNODESNUM;i++)
649 if((ntmp->ntm_sysvn[i]) &&
650 (ntmp->ntm_sysvn[i]->v_usecount > 1)) return (EBUSY);
652 /* Dereference all system vnodes */
653 for(i=0;i<NTFS_SYSNODESNUM;i++)
654 if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
656 /* vflush system vnodes */
657 error = vflush(mp, 0, flags);
659 printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
661 /* Check if the type of device node isn't VBAD before
662 * touching v_specinfo. If the device vnode is revoked, the
663 * field is NULL and touching it causes null pointer derefercence.
665 if (ntmp->ntm_devvp->v_type != VBAD)
666 ntmp->ntm_devvp->v_rdev->si_mountpoint = NULL;
668 vinvalbuf(ntmp->ntm_devvp, V_SAVE, td, 0, 0);
670 #if defined(__NetBSD__)
671 /* lock the device vnode before calling VOP_CLOSE() */
672 VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY);
673 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, td);
674 VOP__UNLOCK(ntmp->ntm_devvp, 0, td);
676 error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE, td);
679 vrele(ntmp->ntm_devvp);
681 /* free the toupper table, if this has been last mounted ntfs volume */
682 ntfs_toupper_unuse();
684 dprintf(("ntfs_umount: freeing memory...\n"));
685 ntfs_u28_uninit(ntmp);
686 ntfs_82u_uninit(ntmp);
687 mp->mnt_data = (qaddr_t)0;
688 mp->mnt_flag &= ~MNT_LOCAL;
689 FREE(ntmp->ntm_ad, M_NTFSMNT);
690 FREE(ntmp, M_NTFSMNT);
695 ntfs_root(struct mount *mp, struct vnode **vpp)
700 dprintf(("ntfs_root(): sysvn: %p\n",
701 VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
702 error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp);
704 printf("ntfs_root: VFS_VGET failed: %d\n",error);
712 #if !defined(__DragonFly__)
714 ntfs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
717 printf("\nntfs_quotactl():\n");
723 ntfs_calccfree(struct ntfsmount *ntmp, cn_t *cfreep)
731 vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
733 bmsize = VTOF(vp)->f_size;
735 MALLOC(tmp, u_int8_t *, bmsize, M_TEMP, M_WAITOK);
737 error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
738 0, bmsize, tmp, NULL);
742 for(i=0;i<bmsize;i++)
744 if(~tmp[i] & (1 << j)) cfree++;
753 ntfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
755 struct ntfsmount *ntmp = VFSTONTFS(mp);
756 u_int64_t mftsize,mftallocated;
758 dprintf(("ntfs_statfs():\n"));
760 mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
761 mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
763 #if defined(__DragonFly__)
764 sbp->f_type = mp->mnt_vfc->vfc_typenum;
765 #elif defined(__NetBSD__)
768 sbp->f_type = MOUNT_NTFS;
770 sbp->f_bsize = ntmp->ntm_bps;
771 sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
772 sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
773 sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
774 sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
775 sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
777 if (sbp != &mp->mnt_stat) {
778 bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
779 (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
781 sbp->f_flags = mp->mnt_flag;
783 strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
789 #if !defined(__DragonFly__)
791 ntfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td)
793 /*dprintf(("ntfs_sync():\n"));*/
800 ntfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
803 struct ntfid *ntfhp = (struct ntfid *)fhp;
806 ddprintf(("ntfs_fhtovp(): %d\n", ntfhp->ntfid_ino));
808 if ((error = VFS_VGET(mp, ntfhp->ntfid_ino, &nvp)) != 0) {
812 /* XXX as unlink/rmdir/mkdir/creat are not currently possible
813 * with NTFS, we don't need to check anything else for now */
820 ntfs_vptofh(struct vnode *vp, struct fid *fhp)
825 ddprintf(("ntfs_fhtovp(): %p\n", vp));
828 ntfhp = (struct ntfid *)fhp;
829 ntfhp->ntfid_len = sizeof(struct ntfid);
830 ntfhp->ntfid_ino = ntp->i_number;
831 /* ntfhp->ntfid_gen = ntp->i_gen; */
836 ntfs_vgetex(struct mount *mp, ino_t ino, u_int32_t attrtype, char *attrname,
837 u_long lkflags, u_long flags, struct thread *td,
841 struct ntfsmount *ntmp;
847 dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
848 ino, attrtype, attrname?attrname:"", (u_long)lkflags,
851 ntmp = VFSTONTFS(mp);
855 error = ntfs_ntlookup(ntmp, ino, &ip);
857 printf("ntfs_vget: ntfs_ntget failed\n");
861 /* It may be not initialized fully, so force load it */
862 if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
863 error = ntfs_loadntnode(ntmp, ip);
865 printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %"PRId64"\n",
872 error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
874 printf("ntfs_vget: ntfs_fget failed\n");
880 if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
881 if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
882 (fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
884 } else if (flags & VG_EXT) {
886 fp->f_size = fp->f_allocated = 0;
890 error = ntfs_filesize(ntmp, fp,
891 &fp->f_size, &fp->f_allocated);
898 fp->f_flag |= FN_VALID;
902 VGET(FTOV(fp), lkflags, td);
908 error = getnewvnode(VT_NTFS, ntmp->ntm_mountp, &vp, VLKTIMEOUT, 0);
914 dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
920 if (ino == NTFS_ROOTINO)
925 KKASSERT(lkflags & LK_TYPE_MASK);
926 KKASSERT((lkflags & LK_INTERLOCK) == 0);
927 /* XXX leave vnode locked exclusively from getnewvnode */
934 ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
936 return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
937 LK_EXCLUSIVE | LK_RETRY, 0, curthread, vpp);
940 #if defined(__DragonFly__)
941 static struct vfsops ntfs_vfsops = {
942 .vfs_mount = ntfs_mount,
943 .vfs_unmount = ntfs_unmount,
944 .vfs_root = ntfs_root,
945 .vfs_statfs = ntfs_statfs,
946 .vfs_sync = vfs_stdsync,
947 .vfs_vget = ntfs_vget,
948 .vfs_fhtovp = ntfs_fhtovp,
949 .vfs_checkexp = ntfs_checkexp,
950 .vfs_vptofh = ntfs_vptofh,
951 .vfs_init = ntfs_init,
952 .vfs_uninit = ntfs_nthash_uninit /* see ntfs_ihash.c */
954 VFS_SET(ntfs_vfsops, ntfs, 0);
955 #elif defined(__NetBSD__)
956 extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
958 struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
959 &ntfs_vnodeop_opv_desc,
963 struct vfsops ntfs_vfsops = {
981 #else /* !NetBSD && !FreeBSD */
982 static struct vfsops ntfs_vfsops = {
995 VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);