2 * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/kernel.h>
35 #include <sys/types.h>
37 #include <sys/vnode.h>
38 #include <sys/mount.h>
39 #include <sys/namei.h>
40 #include <sys/malloc.h>
43 #include <sys/dirent.h>
46 #include <vm/vm_param.h>
47 #include <vm/vm_page.h>
48 #include <vm/vm_object.h>
49 #include <vm/vm_pager.h>
50 #include <vm/vnode_pager.h>
51 #include <vm/vm_extern.h>
53 #include <sys/unistd.h> /* for pathconf(2) constants */
55 #include <fs/hpfs/hpfs.h>
56 #include <fs/hpfs/hpfsmount.h>
57 #include <fs/hpfs/hpfs_subr.h>
58 #include <fs/hpfs/hpfs_ioctl.h>
60 static int hpfs_de_uiomove(struct hpfsmount *, struct hpfsdirent *,
62 static vop_ioctl_t hpfs_ioctl;
63 static vop_read_t hpfs_read;
64 static vop_write_t hpfs_write;
65 static vop_getattr_t hpfs_getattr;
66 static vop_setattr_t hpfs_setattr;
67 static vop_inactive_t hpfs_inactive;
68 static vop_print_t hpfs_print;
69 static vop_reclaim_t hpfs_reclaim;
70 static vop_strategy_t hpfs_strategy;
71 static vop_access_t hpfs_access;
72 static vop_open_t hpfs_open;
73 static vop_close_t hpfs_close;
74 static vop_readdir_t hpfs_readdir;
75 static vop_cachedlookup_t hpfs_lookup;
76 static vop_create_t hpfs_create;
77 static vop_remove_t hpfs_remove;
78 static vop_bmap_t hpfs_bmap;
79 static vop_fsync_t hpfs_fsync;
80 static vop_pathconf_t hpfs_pathconf;
81 static vop_vptofh_t hpfs_vptofh;
85 struct vop_fsync_args /* {
93 * Flush our dirty buffers.
98 * Write out the on-disc version of the vnode.
100 return hpfs_update(VTOHP(ap->a_vp));
105 struct vop_ioctl_args /* {
110 struct ucred *a_cred;
114 register struct vnode *vp = ap->a_vp;
115 register struct hpfsnode *hp = VTOHP(vp);
118 printf("hpfs_ioctl(0x%x, 0x%lx, 0x%p, 0x%x): ",
119 hp->h_no, ap->a_command, ap->a_data, ap->a_fflag);
121 switch (ap->a_command) {
122 case HPFSIOCGEANUM: {
129 if (hp->h_fn.fn_ealen > 0) {
130 eap = (struct ea *)&(hp->h_fn.fn_int);
133 while (passed < hp->h_fn.fn_ealen) {
135 printf("EAname: %s\n", EA_NAME(eap));
138 passed += sizeof(struct ea) +
139 eap->ea_namelen + 1 + eap->ea_vallen;
140 eap = (struct ea *)((caddr_t)hp->h_fn.fn_int +
148 printf("%lu eas\n", eanum);
150 *(u_long *)ap->a_data = eanum;
159 printf("EA%ld\n", *(u_long *)ap->a_data);
162 if (hp->h_fn.fn_ealen > 0) {
163 eap = (struct ea *)&(hp->h_fn.fn_int);
167 while (passed < hp->h_fn.fn_ealen) {
168 printf("EAname: %s\n", EA_NAME(eap));
170 if (eanum == *(u_long *)ap->a_data) {
171 *(u_long *)ap->a_data =
172 eap->ea_namelen + 1 +
180 passed += sizeof(struct ea) +
181 eap->ea_namelen + 1 + eap->ea_vallen;
182 eap = (struct ea *)((caddr_t)hp->h_fn.fn_int +
194 struct hpfs_rdea *rdeap;
197 rdeap = (struct hpfs_rdea *)ap->a_data;
198 printf("EA%ld\n", rdeap->ea_no);
201 if (hp->h_fn.fn_ealen > 0) {
202 eap = (struct ea *)&(hp->h_fn.fn_int);
206 while (passed < hp->h_fn.fn_ealen) {
207 printf("EAname: %s\n", EA_NAME(eap));
209 if (eanum == rdeap->ea_no) {
210 rdeap->ea_sz = eap->ea_namelen + 1 +
212 copyout(EA_NAME(eap),rdeap->ea_data,
219 passed += sizeof(struct ea) +
220 eap->ea_namelen + 1 + eap->ea_vallen;
221 eap = (struct ea *)((caddr_t)hp->h_fn.fn_int +
238 * Map file offset to disk offset.
242 struct vop_bmap_args /* {
245 struct bufobj **a_bop;
251 register struct hpfsnode *hp = VTOHP(ap->a_vp);
255 if (ap->a_bop != NULL)
256 *ap->a_bop = &hp->h_devvp->v_bufobj;
257 if (ap->a_runb != NULL)
259 if (ap->a_bnp == NULL)
262 dprintf(("hpfs_bmap(0x%x, 0x%x): ",hp->h_no, ap->a_bn));
264 error = hpfs_hpbmap (hp, ap->a_bn, &blkno, ap->a_runp);
272 struct vop_read_args /* {
276 struct ucred *a_cred;
279 register struct vnode *vp = ap->a_vp;
280 register struct hpfsnode *hp = VTOHP(vp);
281 struct uio *uio = ap->a_uio;
283 u_int xfersz, toread;
290 resid = min (uio->uio_resid, hp->h_fn.fn_size - uio->uio_offset);
292 dprintf(("hpfs_read(0x%x, off: %d resid: %d, segflg: %d): [resid: 0x%x]\n",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid,uio->uio_segflg, resid));
295 lbn = uio->uio_offset >> DEV_BSHIFT;
296 off = uio->uio_offset & (DEV_BSIZE - 1);
297 dprintf(("hpfs_read: resid: 0x%x lbn: 0x%x off: 0x%x\n",
298 uio->uio_resid, lbn, off));
299 error = hpfs_hpbmap(hp, lbn, &bn, &runl);
303 toread = min(off + resid, min(DFLTPHYS, (runl+1)*DEV_BSIZE));
304 xfersz = (toread + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
305 dprintf(("hpfs_read: bn: 0x%x (0x%x) toread: 0x%x (0x%x)\n",
306 bn, runl, toread, xfersz));
311 error = bread(hp->h_devvp, bn, xfersz, NOCRED, &bp);
317 error = uiomove(bp->b_data + off, toread - off, uio);
325 dprintf(("hpfs_read: successful\n"));
331 struct vop_write_args /* {
335 struct ucred *a_cred;
338 register struct vnode *vp = ap->a_vp;
339 register struct hpfsnode *hp = VTOHP(vp);
340 struct uio *uio = ap->a_uio;
342 u_int xfersz, towrite;
348 dprintf(("hpfs_write(0x%x, off: %d resid: %d, segflg: %d):\n",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid,uio->uio_segflg));
350 if (ap->a_ioflag & IO_APPEND) {
351 dprintf(("hpfs_write: APPEND mode\n"));
352 uio->uio_offset = hp->h_fn.fn_size;
354 if (uio->uio_offset + uio->uio_resid > hp->h_fn.fn_size) {
355 error = hpfs_extend (hp, uio->uio_offset + uio->uio_resid);
357 printf("hpfs_write: hpfs_extend FAILED %d\n", error);
362 while (uio->uio_resid) {
363 lbn = uio->uio_offset >> DEV_BSHIFT;
364 off = uio->uio_offset & (DEV_BSIZE - 1);
365 dprintf(("hpfs_write: resid: 0x%x lbn: 0x%x off: 0x%x\n",
366 uio->uio_resid, lbn, off));
367 error = hpfs_hpbmap(hp, lbn, &bn, &runl);
371 towrite = min(off + uio->uio_resid, min(DFLTPHYS, (runl+1)*DEV_BSIZE));
372 xfersz = (towrite + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
373 dprintf(("hpfs_write: bn: 0x%x (0x%x) towrite: 0x%x (0x%x)\n",
374 bn, runl, towrite, xfersz));
376 if ((off == 0) && (towrite == xfersz)) {
377 bp = getblk(hp->h_devvp, bn, xfersz, 0, 0, 0);
380 error = bread(hp->h_devvp, bn, xfersz, NOCRED, &bp);
387 error = uiomove(bp->b_data + off, towrite - off, uio);
393 if (ap->a_ioflag & IO_SYNC)
399 dprintf(("hpfs_write: successful\n"));
404 * XXXXX do we need hpfsnode locking inside?
408 struct vop_getattr_args /* {
411 struct ucred *a_cred;
415 register struct vnode *vp = ap->a_vp;
416 register struct hpfsnode *hp = VTOHP(vp);
417 register struct vattr *vap = ap->a_vap;
420 dprintf(("hpfs_getattr(0x%x):\n", hp->h_no));
422 vap->va_fsid = dev2udev(hp->h_dev);
423 vap->va_fileid = hp->h_no;
424 vap->va_mode = hp->h_mode;
426 vap->va_uid = hp->h_uid;
427 vap->va_gid = hp->h_gid;
428 vap->va_rdev = NODEV;
429 vap->va_size = hp->h_fn.fn_size;
430 vap->va_bytes = ((hp->h_fn.fn_size + DEV_BSIZE-1) & ~(DEV_BSIZE-1)) +
433 if (!(hp->h_flag & H_PARVALID)) {
434 error = hpfs_validateparent(hp);
438 vap->va_atime = hpfstimetounix(hp->h_atime);
439 vap->va_mtime = hpfstimetounix(hp->h_mtime);
440 vap->va_ctime = hpfstimetounix(hp->h_ctime);
444 vap->va_blocksize = DEV_BSIZE;
445 vap->va_type = vp->v_type;
452 * XXXXX do we need hpfsnode locking inside?
456 struct vop_setattr_args /* {
459 struct ucred *a_cred;
463 struct vnode *vp = ap->a_vp;
464 struct hpfsnode *hp = VTOHP(vp);
465 struct vattr *vap = ap->a_vap;
466 struct ucred *cred = ap->a_cred;
467 struct thread *td = ap->a_td;
470 dprintf(("hpfs_setattr(0x%x):\n", hp->h_no));
473 * Check for unsettable attributes.
475 if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||
476 (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
477 (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
478 (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
479 dprintf(("hpfs_setattr: changing nonsettable attr\n"));
483 /* Can't change flags XXX Could be implemented */
484 if (vap->va_flags != VNOVAL) {
485 printf("hpfs_setattr: FLAGS CANNOT BE SET\n");
489 /* Can't change uid/gid XXX Could be implemented */
490 if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
491 printf("hpfs_setattr: UID/GID CANNOT BE SET\n");
495 /* Can't change mode XXX Could be implemented */
496 if (vap->va_mode != (mode_t)VNOVAL) {
497 printf("hpfs_setattr: MODE CANNOT BE SET\n");
502 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
503 if (vp->v_mount->mnt_flag & MNT_RDONLY)
505 if (vap->va_vaflags & VA_UTIMES_NULL) {
506 error = VOP_ACCESS(vp, VADMIN, cred, td);
508 error = VOP_ACCESS(vp, VWRITE, cred, td);
510 error = VOP_ACCESS(vp, VADMIN, cred, td);
511 if (vap->va_atime.tv_sec != VNOVAL)
512 hp->h_atime = vap->va_atime.tv_sec;
513 if (vap->va_mtime.tv_sec != VNOVAL)
514 hp->h_mtime = vap->va_mtime.tv_sec;
516 hp->h_flag |= H_PARCHANGE;
519 if (vap->va_size != VNOVAL) {
520 switch (vp->v_type) {
524 if (vp->v_mount->mnt_flag & MNT_RDONLY)
528 printf("hpfs_setattr: WRONG v_type\n");
532 if (vap->va_size < hp->h_fn.fn_size) {
533 error = vtruncbuf(vp, cred, td, vap->va_size, DEV_BSIZE);
536 error = hpfs_truncate(hp, vap->va_size);
540 } else if (vap->va_size > hp->h_fn.fn_size) {
541 vnode_pager_setsize(vp, vap->va_size);
542 error = hpfs_extend(hp, vap->va_size);
552 * Last reference to a node. If necessary, write or delete it.
556 struct vop_inactive_args /* {
560 register struct vnode *vp = ap->a_vp;
561 register struct hpfsnode *hp = VTOHP(vp);
564 dprintf(("hpfs_inactive(0x%x): \n", hp->h_no));
566 if (hp->h_flag & H_CHANGE) {
567 dprintf(("hpfs_inactive: node changed, update\n"));
568 error = hpfs_update (hp);
573 if (hp->h_flag & H_PARCHANGE) {
574 dprintf(("hpfs_inactive: parent node changed, update\n"));
575 error = hpfs_updateparent (hp);
580 if (prtactive && vrefcnt(vp) != 0)
581 vprint("hpfs_inactive: pushing active", vp);
583 if (hp->h_flag & H_INVAL) {
584 vrecycle(vp, ap->a_td);
592 * Reclaim an inode so that it can be used for other purposes.
596 struct vop_reclaim_args /* {
600 register struct vnode *vp = ap->a_vp;
601 register struct hpfsnode *hp = VTOHP(vp);
603 dprintf(("hpfs_reclaim(0x%x0): \n", hp->h_no));
606 * Destroy the vm object and flush associated pages.
608 vnode_destroy_vobject(vp);
612 mtx_destroy(&hp->h_interlock);
623 struct vop_print_args /* {
627 register struct vnode *vp = ap->a_vp;
628 register struct hpfsnode *hp = VTOHP(vp);
630 printf("\tino 0x%x\n", hp->h_no);
635 * Calculate the logical to physical mapping if not done already,
636 * then call the device strategy routine.
638 * In order to be able to swap to a file, the hpfs_hpbmap operation may not
639 * deadlock on memory. See hpfs_bmap() for details. XXXXXXX (not impl)
643 struct vop_strategy_args /* {
647 register struct buf *bp = ap->a_bp;
648 register struct vnode *vp = ap->a_vp;
649 register struct hpfsnode *hp = VTOHP(ap->a_vp);
654 dprintf(("hpfs_strategy(): \n"));
656 if (vp->v_type == VBLK || vp->v_type == VCHR)
657 panic("hpfs_strategy: spec");
658 if (bp->b_blkno == bp->b_lblkno) {
659 error = hpfs_hpbmap (hp, bp->b_lblkno, &blkno, NULL);
662 printf("hpfs_strategy: hpfs_bpbmap FAILED %d\n", error);
664 bp->b_ioflags |= BIO_ERROR;
668 if ((long)bp->b_blkno == -1)
671 if ((long)bp->b_blkno == -1) {
675 bp->b_iooffset = dbtob(bp->b_blkno);
676 bo = hp->h_hpmp->hpm_bo;
682 * XXXXX do we need hpfsnode locking inside?
686 struct vop_access_args /* {
689 struct ucred *a_cred;
693 struct vnode *vp = ap->a_vp;
694 struct hpfsnode *hp = VTOHP(vp);
695 mode_t mode = ap->a_mode;
697 dprintf(("hpfs_access(0x%x):\n", hp->h_no));
700 * Disallow write attempts on read-only filesystems;
701 * unless the file is a socket, fifo, or a block or
702 * character device resident on the filesystem.
705 switch ((int)vp->v_type) {
709 if (vp->v_mount->mnt_flag & MNT_RDONLY)
715 return (vaccess(vp->v_type, hp->h_mode, hp->h_uid, hp->h_gid,
716 ap->a_mode, ap->a_cred, NULL));
727 struct vop_open_args /* {
730 struct ucred *a_cred;
735 register struct vnode *vp = ap->a_vp;
736 register struct hpfsnode *hp = VTOHP(vp);
738 printf("hpfs_open(0x%x):\n",hp->h_no);
742 * Files marked append-only must be opened for appending.
751 * Update the times on the inode.
756 struct vop_close_args /* {
759 struct ucred *a_cred;
764 register struct vnode *vp = ap->a_vp;
765 register struct hpfsnode *hp = VTOHP(vp);
767 printf("hpfs_close: %d\n",hp->h_no);
775 struct hpfsmount *hpmp,
776 struct hpfsdirent *dep,
782 dprintf(("[no: 0x%x, size: %d, name: %2d:%.*s, flag: 0x%x] ",
783 dep->de_fnode, dep->de_size, dep->de_namelen,
784 dep->de_namelen, dep->de_name, dep->de_flag));
786 /*strncpy(cde.d_name, dep->de_name, dep->de_namelen);*/
787 for (i=0; i<dep->de_namelen; i++)
788 cde.d_name[i] = hpfs_d2u(hpmp, dep->de_name[i]);
790 cde.d_name[dep->de_namelen] = '\0';
791 cde.d_namlen = dep->de_namelen;
792 cde.d_fileno = dep->de_fnode;
793 cde.d_type = (dep->de_flag & DE_DIR) ? DT_DIR : DT_REG;
794 cde.d_reclen = sizeof(struct dirent);
796 error = uiomove((char *)&cde, sizeof(struct dirent), uio);
800 dprintf(("[0x%x] ", uio->uio_resid));
805 static struct dirent hpfs_de_dot =
806 { 0, sizeof(struct dirent), DT_DIR, 1, "." };
807 static struct dirent hpfs_de_dotdot =
808 { 0, sizeof(struct dirent), DT_DIR, 2, ".." };
811 struct vop_readdir_args /* {
814 struct ucred *a_cred;
819 register struct vnode *vp = ap->a_vp;
820 register struct hpfsnode *hp = VTOHP(vp);
821 struct hpfsmount *hpmp = hp->h_hpmp;
822 struct uio *uio = ap->a_uio;
823 int ncookies = 0, i, num, cnum;
828 struct hpfsdirent *dep;
833 dprintf(("hpfs_readdir(0x%x, 0x%x, 0x%x): ",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid));
835 off = uio->uio_offset;
837 if( uio->uio_offset < sizeof(struct dirent) ) {
838 dprintf((". faked, "));
839 hpfs_de_dot.d_fileno = hp->h_no;
840 error = uiomove((char *)&hpfs_de_dot,sizeof(struct dirent),uio);
848 if( uio->uio_offset < 2 * sizeof(struct dirent) ) {
849 dprintf((".. faked, "));
850 hpfs_de_dotdot.d_fileno = hp->h_fn.fn_parent;
852 error = uiomove((char *)&hpfs_de_dotdot, sizeof(struct dirent),
861 num = uio->uio_offset / sizeof(struct dirent) - 2;
864 lsn = ((alleaf_t *)hp->h_fn.fn_abd)->al_lsn;
870 dprintf(("[dive 0x%x] ", lsn));
871 error = bread(hp->h_devvp, lsn, D_BSIZE, NOCRED, &bp);
877 dp = (struct dirblk *) bp->b_data;
878 if (dp->d_magic != D_MAGIC) {
879 printf("hpfs_readdir: MAGIC DOESN'T MATCH\n");
887 dprintf(("[restore 0x%x] ", olsn));
889 while(!(dep->de_flag & DE_END) ) {
890 if((dep->de_flag & DE_DOWN) &&
891 (olsn == DE_DOWNLSN(dep)))
893 dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
896 if((dep->de_flag & DE_DOWN) && (olsn == DE_DOWNLSN(dep))) {
897 if (dep->de_flag & DE_END)
900 if (!(dep->de_flag & DE_SPECIAL)) {
902 if (uio->uio_resid < sizeof(struct dirent)) {
904 dprintf(("[resid] "));
908 error = hpfs_de_uiomove(hpmp, dep, uio);
915 if (uio->uio_resid < sizeof(struct dirent)) {
917 dprintf(("[resid] "));
924 dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
926 printf("hpfs_readdir: ERROR! oLSN not found\n");
934 while(!(dep->de_flag & DE_END)) {
935 if(dep->de_flag & DE_DOWN) {
936 lsn = DE_DOWNLSN(dep);
942 if (!(dep->de_flag & DE_SPECIAL)) {
944 if (uio->uio_resid < sizeof(struct dirent)) {
946 dprintf(("[resid] "));
950 error = hpfs_de_uiomove(hpmp, dep, uio);
957 if (uio->uio_resid < sizeof(struct dirent)) {
959 dprintf(("[resid] "));
966 dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen);
969 if(dep->de_flag & DE_DOWN) {
970 dprintf(("[enddive] "));
971 lsn = DE_DOWNLSN(dep);
984 dprintf(("[level %d] ", level));
987 goto dive; /* undive really */
995 dprintf(("[readdone]\n"));
996 if (!error && ap->a_ncookies != NULL) {
997 struct dirent* dpStart;
1002 dprintf(("%d cookies, ",ncookies));
1003 if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
1004 panic("hpfs_readdir: unexpected uio from NFS server");
1005 dpStart = (struct dirent *)
1006 ((caddr_t)uio->uio_iov->iov_base -
1007 (uio->uio_offset - off));
1008 MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
1010 for (dp = dpStart, cookiep = cookies, i=0;
1012 dp = (struct dirent *)((caddr_t) dp + dp->d_reclen), i++) {
1013 off += dp->d_reclen;
1014 *cookiep++ = (u_int) off;
1016 *ap->a_ncookies = ncookies;
1017 *ap->a_cookies = cookies;
1025 struct vop_cachedlookup_args /* {
1026 struct vnode *a_dvp;
1027 struct vnode **a_vpp;
1028 struct componentname *a_cnp;
1031 register struct vnode *dvp = ap->a_dvp;
1032 register struct hpfsnode *dhp = VTOHP(dvp);
1033 struct hpfsmount *hpmp = dhp->h_hpmp;
1034 struct componentname *cnp = ap->a_cnp;
1035 struct ucred *cred = cnp->cn_cred;
1037 int nameiop = cnp->cn_nameiop;
1038 int flags = cnp->cn_flags;
1039 dprintf(("hpfs_lookup(0x%x, %s, %ld):\n",
1040 dhp->h_no, cnp->cn_nameptr, cnp->cn_namelen));
1042 if (nameiop != CREATE && nameiop != DELETE && nameiop != LOOKUP) {
1043 printf("hpfs_lookup: LOOKUP, DELETE and CREATE are only supported\n");
1044 return (EOPNOTSUPP);
1047 error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_thread);
1051 if( (cnp->cn_namelen == 1) &&
1052 !strncmp(cnp->cn_nameptr,".",1) ) {
1053 dprintf(("hpfs_lookup(0x%x,...): . faked\n",dhp->h_no));
1059 } else if( (cnp->cn_namelen == 2) &&
1060 !strncmp(cnp->cn_nameptr,"..",2) && (flags & ISDOTDOT) ) {
1061 dprintf(("hpfs_lookup(0x%x,...): .. faked (0x%x)\n",
1062 dhp->h_no, dhp->h_fn.fn_parent));
1064 if (VFS_VGET(hpmp->hpm_mp, dhp->h_fn.fn_parent,
1065 LK_NOWAIT | LK_EXCLUSIVE, ap->a_vpp)) {
1066 VOP_UNLOCK(dvp,0,cnp->cn_thread);
1067 error = VFS_VGET(hpmp->hpm_mp,
1068 dhp->h_fn.fn_parent, LK_EXCLUSIVE, ap->a_vpp);
1069 vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY, cnp->cn_thread);
1076 struct hpfsdirent *dep;
1077 struct hpfsnode *hp;
1079 error = hpfs_genlookupbyname(dhp,
1080 cnp->cn_nameptr, cnp->cn_namelen, &bp, &dep);
1082 if ((error == ENOENT) && (flags & ISLASTCN) &&
1083 (nameiop == CREATE || nameiop == RENAME)) {
1084 cnp->cn_flags |= SAVENAME;
1085 return (EJUSTRETURN);
1091 dprintf(("hpfs_lookup: fnode: 0x%x, CPID: 0x%x\n",
1092 dep->de_fnode, dep->de_cpid));
1094 if (nameiop == DELETE && (flags & ISLASTCN)) {
1095 error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_thread);
1102 if (dhp->h_no == dep->de_fnode) {
1109 error = VFS_VGET(hpmp->hpm_mp, dep->de_fnode, LK_EXCLUSIVE,
1112 printf("hpfs_lookup: VFS_VGET FAILED %d\n", error);
1117 hp = VTOHP(*ap->a_vpp);
1119 hp->h_mtime = dep->de_mtime;
1120 hp->h_ctime = dep->de_ctime;
1121 hp->h_atime = dep->de_atime;
1122 bcopy(dep->de_name, hp->h_name, dep->de_namelen);
1123 hp->h_name[dep->de_namelen] = '\0';
1124 hp->h_namelen = dep->de_namelen;
1125 hp->h_flag |= H_PARVALID;
1129 if ((flags & MAKEENTRY) &&
1130 (!(flags & ISLASTCN) ||
1131 (nameiop != DELETE && nameiop != CREATE)))
1132 cache_enter(dvp, *ap->a_vpp, cnp);
1139 struct vop_remove_args /* {
1140 struct vnode *a_dvp;
1142 struct componentname *a_cnp;
1147 dprintf(("hpfs_remove(0x%x, %s, %ld): \n", VTOHP(ap->a_vp)->h_no,
1148 ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen));
1150 if (ap->a_vp->v_type == VDIR)
1153 error = hpfs_removefnode (ap->a_dvp, ap->a_vp, ap->a_cnp);
1159 struct vop_create_args /* {
1160 struct vnode *a_dvp;
1161 struct vnode **a_vpp;
1162 struct componentname *a_cnp;
1163 struct vattr *a_vap;
1168 dprintf(("hpfs_create(0x%x, %s, %ld): \n", VTOHP(ap->a_dvp)->h_no,
1169 ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen));
1171 if (!(ap->a_cnp->cn_flags & HASBUF))
1172 panic ("hpfs_create: no name\n");
1174 error = hpfs_makefnode (ap->a_dvp, ap->a_vpp, ap->a_cnp, ap->a_vap);
1180 * Return POSIX pathconf information applicable to NTFS filesystem
1184 struct vop_pathconf_args /* {
1187 register_t *a_retval;
1190 switch (ap->a_name) {
1195 *ap->a_retval = HPFS_MAXFILENAME;
1198 *ap->a_retval = PATH_MAX;
1200 case _PC_CHOWN_RESTRICTED:
1214 struct vop_vptofh_args /* {
1219 register struct hpfsnode *hpp;
1220 register struct hpfid *hpfhp;
1222 hpp = VTOHP(ap->a_vp);
1223 hpfhp = (struct hpfid *)ap->a_fhp;
1224 hpfhp->hpfid_len = sizeof(struct hpfid);
1225 hpfhp->hpfid_ino = hpp->h_no;
1226 /* hpfhp->hpfid_gen = hpp->h_gen; */
1232 * Global vfs data structures
1234 struct vop_vector hpfs_vnodeops = {
1235 .vop_default = &default_vnodeops,
1237 .vop_access = hpfs_access,
1238 .vop_bmap = hpfs_bmap,
1239 .vop_cachedlookup = hpfs_lookup,
1240 .vop_close = hpfs_close,
1241 .vop_create = hpfs_create,
1242 .vop_fsync = hpfs_fsync,
1243 .vop_getattr = hpfs_getattr,
1244 .vop_inactive = hpfs_inactive,
1245 .vop_ioctl = hpfs_ioctl,
1246 .vop_lookup = vfs_cache_lookup,
1247 .vop_open = hpfs_open,
1248 .vop_pathconf = hpfs_pathconf,
1249 .vop_print = hpfs_print,
1250 .vop_read = hpfs_read,
1251 .vop_readdir = hpfs_readdir,
1252 .vop_reclaim = hpfs_reclaim,
1253 .vop_remove = hpfs_remove,
1254 .vop_setattr = hpfs_setattr,
1255 .vop_strategy = hpfs_strategy,
1256 .vop_write = hpfs_write,
1257 .vop_vptofh = hpfs_vptofh,