1 /*- 2 * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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. 13 * 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 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: src/sys/fs/hpfs/hpfs_vnops.c,v 1.2.2.2 2002/01/15 18:35:09 semenu Exp $ 27 * $DragonFly: src/sys/vfs/hpfs/hpfs_vnops.c,v 1.17 2004/08/28 19:02:14 dillon Exp $ 28 */ 29 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 #include <sys/kernel.h> 33 #include <sys/proc.h> 34 #include <sys/time.h> 35 #include <sys/types.h> 36 #include <sys/stat.h> 37 #include <sys/vnode.h> 38 #include <sys/mount.h> 39 #include <sys/namei.h> 40 #include <sys/malloc.h> 41 #include <sys/buf.h> 42 #include <sys/dirent.h> 43 44 #include <vm/vm.h> 45 #include <vm/vm_param.h> 46 #if !defined(__DragonFly__) 47 #include <vm/vm_prot.h> 48 #endif 49 #include <vm/vm_page.h> 50 #include <vm/vm_object.h> 51 #include <vm/vm_pager.h> 52 #include <vm/vm_zone.h> 53 #if defined(__DragonFly__) 54 #include <vm/vnode_pager.h> 55 #endif 56 #include <vm/vm_extern.h> 57 #include <sys/buf2.h> 58 59 #if !defined(__DragonFly__) 60 #include <miscfs/specfs/specdev.h> 61 #include <miscfs/genfs/genfs.h> 62 #endif 63 64 #include <sys/unistd.h> /* for pathconf(2) constants */ 65 66 #include "hpfs.h" 67 #include "hpfsmount.h" 68 #include "hpfs_subr.h" 69 #include "hpfs_ioctl.h" 70 71 static int hpfs_de_uiomove (struct hpfsmount *, struct hpfsdirent *, 72 struct uio *); 73 static int hpfs_ioctl (struct vop_ioctl_args *ap); 74 static int hpfs_read (struct vop_read_args *); 75 static int hpfs_write (struct vop_write_args *ap); 76 static int hpfs_getattr (struct vop_getattr_args *ap); 77 static int hpfs_setattr (struct vop_setattr_args *ap); 78 static int hpfs_inactive (struct vop_inactive_args *ap); 79 static int hpfs_print (struct vop_print_args *ap); 80 static int hpfs_reclaim (struct vop_reclaim_args *ap); 81 static int hpfs_strategy (struct vop_strategy_args *ap); 82 static int hpfs_access (struct vop_access_args *ap); 83 static int hpfs_open (struct vop_open_args *ap); 84 static int hpfs_close (struct vop_close_args *ap); 85 static int hpfs_readdir (struct vop_readdir_args *ap); 86 static int hpfs_lookup (struct vop_lookup_args *ap); 87 static int hpfs_create (struct vop_create_args *); 88 static int hpfs_remove (struct vop_remove_args *); 89 static int hpfs_bmap (struct vop_bmap_args *ap); 90 #if defined(__DragonFly__) 91 static int hpfs_getpages (struct vop_getpages_args *ap); 92 static int hpfs_putpages (struct vop_putpages_args *); 93 static int hpfs_fsync (struct vop_fsync_args *ap); 94 #endif 95 static int hpfs_pathconf (struct vop_pathconf_args *ap); 96 97 #if defined(__DragonFly__) 98 int 99 hpfs_getpages(struct vop_getpages_args *ap) 100 { 101 return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count, 102 ap->a_reqpage); 103 } 104 105 int 106 hpfs_putpages(struct vop_putpages_args *ap) 107 { 108 return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count, 109 ap->a_sync, ap->a_rtvals); 110 } 111 112 /* 113 * hpfs_fsync(struct vnode *a_vp, struct ucred *a_cred, int a_waitfor, 114 * struct proc *a_td) 115 */ 116 static int 117 hpfs_fsync(struct vop_fsync_args *ap) 118 { 119 struct vnode *vp = ap->a_vp; 120 int s; 121 struct buf *bp, *nbp; 122 123 /* 124 * Flush all dirty buffers associated with a vnode. 125 */ 126 loop: 127 s = splbio(); 128 for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { 129 nbp = TAILQ_NEXT(bp, b_vnbufs); 130 if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) 131 continue; 132 if ((bp->b_flags & B_DELWRI) == 0) 133 panic("hpfs_fsync: not dirty"); 134 bremfree(bp); 135 splx(s); 136 (void) bwrite(bp); 137 goto loop; 138 } 139 while (vp->v_numoutput) { 140 vp->v_flag |= VBWAIT; 141 (void) tsleep((caddr_t)&vp->v_numoutput, 0, "hpfsn", 0); 142 } 143 #ifdef DIAGNOSTIC 144 if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) { 145 vprint("hpfs_fsync: dirty", vp); 146 goto loop; 147 } 148 #endif 149 splx(s); 150 151 /* 152 * Write out the on-disc version of the vnode. 153 */ 154 return hpfs_update(VTOHP(vp)); 155 } 156 157 #endif 158 159 /* 160 * hpfs_ioctl(struct vnode *a_vp, u_long a_command, caddr_t a_data, 161 * int a_fflag, struct ucred *a_cred, struct proc *a_td) 162 */ 163 static int 164 hpfs_ioctl(struct vop_ioctl_args *ap) 165 { 166 struct vnode *vp = ap->a_vp; 167 struct hpfsnode *hp = VTOHP(vp); 168 int error; 169 170 printf("hpfs_ioctl(0x%x, 0x%lx, 0x%p, 0x%x): ", 171 hp->h_no, ap->a_command, ap->a_data, ap->a_fflag); 172 173 switch (ap->a_command) { 174 case HPFSIOCGEANUM: { 175 u_long eanum; 176 u_long passed; 177 struct ea *eap; 178 179 eanum = 0; 180 181 if (hp->h_fn.fn_ealen > 0) { 182 eap = (struct ea *)&(hp->h_fn.fn_int); 183 passed = 0; 184 185 while (passed < hp->h_fn.fn_ealen) { 186 187 printf("EAname: %s\n", EA_NAME(eap)); 188 189 eanum++; 190 passed += sizeof(struct ea) + 191 eap->ea_namelen + 1 + eap->ea_vallen; 192 eap = (struct ea *)((caddr_t)hp->h_fn.fn_int + 193 passed); 194 } 195 error = 0; 196 } else { 197 error = ENOENT; 198 } 199 200 printf("%lu eas\n", eanum); 201 202 *(u_long *)ap->a_data = eanum; 203 204 break; 205 } 206 case HPFSIOCGEASZ: { 207 u_long eanum; 208 u_long passed; 209 struct ea *eap; 210 211 printf("EA%ld\n", *(u_long *)ap->a_data); 212 213 eanum = 0; 214 if (hp->h_fn.fn_ealen > 0) { 215 eap = (struct ea *)&(hp->h_fn.fn_int); 216 passed = 0; 217 218 error = ENOENT; 219 while (passed < hp->h_fn.fn_ealen) { 220 printf("EAname: %s\n", EA_NAME(eap)); 221 222 if (eanum == *(u_long *)ap->a_data) { 223 *(u_long *)ap->a_data = 224 eap->ea_namelen + 1 + 225 eap->ea_vallen; 226 227 error = 0; 228 break; 229 } 230 231 eanum++; 232 passed += sizeof(struct ea) + 233 eap->ea_namelen + 1 + eap->ea_vallen; 234 eap = (struct ea *)((caddr_t)hp->h_fn.fn_int + 235 passed); 236 } 237 } else { 238 error = ENOENT; 239 } 240 241 break; 242 } 243 case HPFSIOCRDEA: { 244 u_long eanum; 245 u_long passed; 246 struct hpfs_rdea *rdeap; 247 struct ea *eap; 248 249 rdeap = (struct hpfs_rdea *)ap->a_data; 250 printf("EA%ld\n", rdeap->ea_no); 251 252 eanum = 0; 253 if (hp->h_fn.fn_ealen > 0) { 254 eap = (struct ea *)&(hp->h_fn.fn_int); 255 passed = 0; 256 257 error = ENOENT; 258 while (passed < hp->h_fn.fn_ealen) { 259 printf("EAname: %s\n", EA_NAME(eap)); 260 261 if (eanum == rdeap->ea_no) { 262 rdeap->ea_sz = eap->ea_namelen + 1 + 263 eap->ea_vallen; 264 copyout(EA_NAME(eap),rdeap->ea_data, 265 rdeap->ea_sz); 266 error = 0; 267 break; 268 } 269 270 eanum++; 271 passed += sizeof(struct ea) + 272 eap->ea_namelen + 1 + eap->ea_vallen; 273 eap = (struct ea *)((caddr_t)hp->h_fn.fn_int + 274 passed); 275 } 276 } else { 277 error = ENOENT; 278 } 279 280 break; 281 } 282 default: 283 error = EOPNOTSUPP; 284 break; 285 } 286 return (error); 287 } 288 289 /* 290 * Map file offset to disk offset. 291 * 292 * hpfs_bmap(struct vnode *a_vp, daddr_t a_bn, struct vnode **a_vpp, 293 * daddr_t *a_bnp, int *a_runp, int *a_runb) 294 */ 295 int 296 hpfs_bmap(struct vop_bmap_args *ap) 297 { 298 struct hpfsnode *hp = VTOHP(ap->a_vp); 299 int error; 300 301 if (ap->a_vpp != NULL) 302 *ap->a_vpp = hp->h_devvp; 303 #if defined(__DragonFly__) 304 if (ap->a_runb != NULL) 305 *ap->a_runb = 0; 306 #endif 307 if (ap->a_bnp == NULL) 308 return (0); 309 310 dprintf(("hpfs_bmap(0x%x, 0x%x): ",hp->h_no, ap->a_bn)); 311 312 error = hpfs_hpbmap (hp, ap->a_bn, ap->a_bnp, ap->a_runp); 313 314 return (error); 315 } 316 317 /* 318 * hpfs_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, 319 * struct ucred *a_cred) 320 */ 321 static int 322 hpfs_read(struct vop_read_args *ap) 323 { 324 struct vnode *vp = ap->a_vp; 325 struct hpfsnode *hp = VTOHP(vp); 326 struct uio *uio = ap->a_uio; 327 struct buf *bp; 328 u_int xfersz, toread; 329 u_int off; 330 daddr_t lbn, bn; 331 int resid; 332 int runl; 333 int error = 0; 334 335 resid = min (uio->uio_resid, hp->h_fn.fn_size - uio->uio_offset); 336 337 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)); 338 339 while (resid) { 340 lbn = uio->uio_offset >> DEV_BSHIFT; 341 off = uio->uio_offset & (DEV_BSIZE - 1); 342 dprintf(("hpfs_read: resid: 0x%x lbn: 0x%x off: 0x%x\n", 343 uio->uio_resid, lbn, off)); 344 error = hpfs_hpbmap(hp, lbn, &bn, &runl); 345 if (error) 346 return (error); 347 348 toread = min(off + resid, min(DFLTPHYS, (runl+1)*DEV_BSIZE)); 349 xfersz = (toread + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); 350 dprintf(("hpfs_read: bn: 0x%x (0x%x) toread: 0x%x (0x%x)\n", 351 bn, runl, toread, xfersz)); 352 353 if (toread == 0) 354 break; 355 356 error = bread(hp->h_devvp, bn, xfersz, &bp); 357 if (error) { 358 brelse(bp); 359 break; 360 } 361 362 error = uiomove(bp->b_data + off, toread - off, uio); 363 if(error) { 364 brelse(bp); 365 break; 366 } 367 brelse(bp); 368 resid -= toread; 369 } 370 dprintf(("hpfs_read: successful\n")); 371 return (error); 372 } 373 374 /* 375 * hpfs_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, 376 * struct ucred *a_cred) 377 */ 378 static int 379 hpfs_write(struct vop_write_args *ap) 380 { 381 struct vnode *vp = ap->a_vp; 382 struct hpfsnode *hp = VTOHP(vp); 383 struct uio *uio = ap->a_uio; 384 struct buf *bp; 385 u_int xfersz, towrite; 386 u_int off; 387 daddr_t lbn, bn; 388 int runl; 389 int error = 0; 390 391 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)); 392 393 if (ap->a_ioflag & IO_APPEND) { 394 dprintf(("hpfs_write: APPEND mode\n")); 395 uio->uio_offset = hp->h_fn.fn_size; 396 } 397 if (uio->uio_offset + uio->uio_resid > hp->h_fn.fn_size) { 398 error = hpfs_extend (hp, uio->uio_offset + uio->uio_resid); 399 if (error) { 400 printf("hpfs_write: hpfs_extend FAILED %d\n", error); 401 return (error); 402 } 403 } 404 405 while (uio->uio_resid) { 406 lbn = uio->uio_offset >> DEV_BSHIFT; 407 off = uio->uio_offset & (DEV_BSIZE - 1); 408 dprintf(("hpfs_write: resid: 0x%x lbn: 0x%x off: 0x%x\n", 409 uio->uio_resid, lbn, off)); 410 error = hpfs_hpbmap(hp, lbn, &bn, &runl); 411 if (error) 412 return (error); 413 414 towrite = min(off + uio->uio_resid, min(DFLTPHYS, (runl+1)*DEV_BSIZE)); 415 xfersz = (towrite + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); 416 dprintf(("hpfs_write: bn: 0x%x (0x%x) towrite: 0x%x (0x%x)\n", 417 bn, runl, towrite, xfersz)); 418 419 if ((off == 0) && (towrite == xfersz)) { 420 bp = getblk(hp->h_devvp, bn, xfersz, 0, 0); 421 clrbuf(bp); 422 } else { 423 error = bread(hp->h_devvp, bn, xfersz, &bp); 424 if (error) { 425 brelse(bp); 426 return (error); 427 } 428 } 429 430 error = uiomove(bp->b_data + off, towrite - off, uio); 431 if(error) { 432 brelse(bp); 433 return (error); 434 } 435 436 if (ap->a_ioflag & IO_SYNC) 437 bwrite(bp); 438 else 439 bawrite(bp); 440 } 441 442 dprintf(("hpfs_write: successful\n")); 443 return (0); 444 } 445 446 /* 447 * XXXXX do we need hpfsnode locking inside? 448 * 449 * hpfs_getattr(struct vnode *a_vp, struct vattr *a_vap, struct ucred *a_cred, 450 * struct proc *a_td) 451 */ 452 static int 453 hpfs_getattr(struct vop_getattr_args *ap) 454 { 455 struct vnode *vp = ap->a_vp; 456 struct hpfsnode *hp = VTOHP(vp); 457 struct vattr *vap = ap->a_vap; 458 int error; 459 460 dprintf(("hpfs_getattr(0x%x):\n", hp->h_no)); 461 462 #if defined(__DragonFly__) 463 vap->va_fsid = dev2udev(hp->h_dev); 464 #else /* defined(__NetBSD__) */ 465 vap->va_fsid = ip->i_dev; 466 #endif 467 vap->va_fileid = hp->h_no; 468 vap->va_mode = hp->h_mode; 469 vap->va_nlink = 1; 470 vap->va_uid = hp->h_uid; 471 vap->va_gid = hp->h_gid; 472 vap->va_rdev = 0; /* XXX UNODEV ? */ 473 vap->va_size = hp->h_fn.fn_size; 474 vap->va_bytes = ((hp->h_fn.fn_size + DEV_BSIZE-1) & ~(DEV_BSIZE-1)) + 475 DEV_BSIZE; 476 477 if (!(hp->h_flag & H_PARVALID)) { 478 error = hpfs_validateparent(hp); 479 if (error) 480 return (error); 481 } 482 vap->va_atime = hpfstimetounix(hp->h_atime); 483 vap->va_mtime = hpfstimetounix(hp->h_mtime); 484 vap->va_ctime = hpfstimetounix(hp->h_ctime); 485 486 vap->va_flags = 0; 487 vap->va_gen = 0; 488 vap->va_blocksize = DEV_BSIZE; 489 vap->va_type = vp->v_type; 490 vap->va_filerev = 0; 491 492 return (0); 493 } 494 495 /* 496 * XXXXX do we need hpfsnode locking inside? 497 * 498 * hpfs_setattr(struct vnode *a_vp, struct vattr *a_vap, struct ucred *a_cred, 499 * struct thread *a_td) 500 */ 501 static int 502 hpfs_setattr(struct vop_setattr_args *ap) 503 { 504 struct vnode *vp = ap->a_vp; 505 struct hpfsnode *hp = VTOHP(vp); 506 struct vattr *vap = ap->a_vap; 507 struct ucred *cred = ap->a_cred; 508 struct thread *td = ap->a_td; 509 int error; 510 511 dprintf(("hpfs_setattr(0x%x):\n", hp->h_no)); 512 513 /* 514 * Check for unsettable attributes. 515 */ 516 if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) || 517 (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) || 518 (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) || 519 (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) { 520 dprintf(("hpfs_setattr: changing nonsettable attr\n")); 521 return (EINVAL); 522 } 523 524 /* Can't change flags XXX Could be implemented */ 525 if (vap->va_flags != VNOVAL) { 526 printf("hpfs_setattr: FLAGS CANNOT BE SET\n"); 527 return (EINVAL); 528 } 529 530 /* Can't change uid/gid XXX Could be implemented */ 531 if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { 532 printf("hpfs_setattr: UID/GID CANNOT BE SET\n"); 533 return (EINVAL); 534 } 535 536 /* Can't change mode XXX Could be implemented */ 537 if (vap->va_mode != (mode_t)VNOVAL) { 538 printf("hpfs_setattr: MODE CANNOT BE SET\n"); 539 return (EINVAL); 540 } 541 542 /* Update times */ 543 if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { 544 if (vp->v_mount->mnt_flag & MNT_RDONLY) 545 return (EROFS); 546 if (cred->cr_uid != hp->h_uid && 547 (error = suser_cred(cred, PRISON_ROOT)) && 548 ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || 549 (error = VOP_ACCESS(vp, VWRITE, cred, td)))) 550 return (error); 551 if (vap->va_atime.tv_sec != VNOVAL) 552 hp->h_atime = vap->va_atime.tv_sec; 553 if (vap->va_mtime.tv_sec != VNOVAL) 554 hp->h_mtime = vap->va_mtime.tv_sec; 555 556 hp->h_flag |= H_PARCHANGE; 557 } 558 559 if (vap->va_size != VNOVAL) { 560 switch (vp->v_type) { 561 case VDIR: 562 return (EISDIR); 563 case VREG: 564 if (vp->v_mount->mnt_flag & MNT_RDONLY) 565 return (EROFS); 566 break; 567 default: 568 printf("hpfs_setattr: WRONG v_type\n"); 569 return (EINVAL); 570 } 571 572 if (vap->va_size < hp->h_fn.fn_size) { 573 #if defined(__DragonFly__) 574 error = vtruncbuf(vp, td, vap->va_size, DEV_BSIZE); 575 if (error) 576 return (error); 577 #else /* defined(__NetBSD__) */ 578 #error Need alternation for vtruncbuf() 579 #endif 580 error = hpfs_truncate(hp, vap->va_size); 581 if (error) 582 return (error); 583 584 } else if (vap->va_size > hp->h_fn.fn_size) { 585 #if defined(__DragonFly__) 586 vnode_pager_setsize(vp, vap->va_size); 587 #endif 588 error = hpfs_extend(hp, vap->va_size); 589 if (error) 590 return (error); 591 } 592 } 593 594 return (0); 595 } 596 597 /* 598 * Last reference to an node. If necessary, write or delete it. 599 * 600 * hpfs_inactive(struct vnode *a_vp) 601 */ 602 int 603 hpfs_inactive(struct vop_inactive_args *ap) 604 { 605 struct vnode *vp = ap->a_vp; 606 struct hpfsnode *hp = VTOHP(vp); 607 int error; 608 609 dprintf(("hpfs_inactive(0x%x): \n", hp->h_no)); 610 611 if (hp->h_flag & H_CHANGE) { 612 dprintf(("hpfs_inactive: node changed, update\n")); 613 error = hpfs_update (hp); 614 if (error) 615 return (error); 616 } 617 618 if (hp->h_flag & H_PARCHANGE) { 619 dprintf(("hpfs_inactive: parent node changed, update\n")); 620 error = hpfs_updateparent (hp); 621 if (error) 622 return (error); 623 } 624 625 if (prtactive && vp->v_usecount != 0) 626 vprint("hpfs_inactive: pushing active", vp); 627 628 if (hp->h_flag & H_INVAL) { 629 VOP__UNLOCK(vp,0,ap->a_td); 630 #if defined(__DragonFly__) 631 vrecycle(vp, NULL, ap->a_td); 632 #else /* defined(__NetBSD__) */ 633 vgone(vp); 634 #endif 635 return (0); 636 } 637 638 VOP__UNLOCK(vp,0,ap->a_td); 639 return (0); 640 } 641 642 /* 643 * Reclaim an inode so that it can be used for other purposes. 644 * 645 * hpfs_reclaim(struct vnode *a_vp) 646 */ 647 int 648 hpfs_reclaim(struct vop_reclaim_args *ap) 649 { 650 struct vnode *vp = ap->a_vp; 651 struct hpfsnode *hp = VTOHP(vp); 652 653 dprintf(("hpfs_reclaim(0x%x0): \n", hp->h_no)); 654 655 hpfs_hphashrem(hp); 656 657 /* Purge old data structures associated with the inode. */ 658 cache_purge(vp); 659 if (hp->h_devvp) { 660 vrele(hp->h_devvp); 661 hp->h_devvp = NULL; 662 } 663 664 vp->v_data = NULL; 665 666 FREE(hp, M_HPFSNO); 667 668 return (0); 669 } 670 671 /* 672 * hpfs_print(struct vnode *a_vp) 673 */ 674 static int 675 hpfs_print(struct vop_print_args *ap) 676 { 677 struct vnode *vp = ap->a_vp; 678 struct hpfsnode *hp = VTOHP(vp); 679 680 printf("tag VT_HPFS, ino 0x%x",hp->h_no); 681 lockmgr_printinfo(&vp->v_lock); 682 printf("\n"); 683 return (0); 684 } 685 686 /* 687 * Calculate the logical to physical mapping if not done already, 688 * then call the device strategy routine. 689 * 690 * In order to be able to swap to a file, the VOP_BMAP operation may not 691 * deadlock on memory. See hpfs_bmap() for details. XXXXXXX (not impl) 692 * 693 * hpfs_strategy(struct buf *a_bp) 694 */ 695 int 696 hpfs_strategy(struct vop_strategy_args *ap) 697 { 698 struct buf *bp = ap->a_bp; 699 struct vnode *vp = ap->a_vp; 700 struct vnode *nvp; 701 int error; 702 703 dprintf(("hpfs_strategy(): \n")); 704 705 if (vp->v_type == VBLK || vp->v_type == VCHR) 706 panic("hpfs_strategy: spec"); 707 if (bp->b_blkno == bp->b_lblkno) { 708 error = VOP_BMAP(vp, bp->b_lblkno, &nvp, &bp->b_blkno, NULL, NULL); 709 if (error) { 710 printf("hpfs_strategy: VOP_BMAP FAILED %d\n", error); 711 bp->b_error = error; 712 bp->b_flags |= B_ERROR; 713 biodone(bp); 714 return (error); 715 } 716 if ((long)bp->b_blkno == -1) 717 vfs_bio_clrbuf(bp); 718 } 719 if ((long)bp->b_blkno == -1) { 720 biodone(bp); 721 return (0); 722 } 723 bp->b_dev = nvp->v_rdev; 724 VOP_STRATEGY(nvp, bp); 725 return (0); 726 } 727 728 /* 729 * XXXXX do we need hpfsnode locking inside? 730 * 731 * hpfs_access(struct vnode *a_vp, int a_mode, struct ucred *a_cred, 732 * struct proc *a_td) 733 */ 734 int 735 hpfs_access(struct vop_access_args *ap) 736 { 737 struct vnode *vp = ap->a_vp; 738 struct hpfsnode *hp = VTOHP(vp); 739 struct ucred *cred = ap->a_cred; 740 mode_t mask, mode = ap->a_mode; 741 gid_t *gp; 742 int i; 743 744 dprintf(("hpfs_access(0x%x):\n", hp->h_no)); 745 746 /* 747 * Disallow write attempts on read-only file systems; 748 * unless the file is a socket, fifo, or a block or 749 * character device resident on the file system. 750 */ 751 if (mode & VWRITE) { 752 switch ((int)vp->v_type) { 753 case VDIR: 754 case VLNK: 755 case VREG: 756 if (vp->v_mount->mnt_flag & MNT_RDONLY) 757 return (EROFS); 758 break; 759 } 760 } 761 762 /* Otherwise, user id 0 always gets access. */ 763 if (cred->cr_uid == 0) 764 return (0); 765 766 mask = 0; 767 768 /* Otherwise, check the owner. */ 769 if (cred->cr_uid == hp->h_uid) { 770 if (mode & VEXEC) 771 mask |= S_IXUSR; 772 if (mode & VREAD) 773 mask |= S_IRUSR; 774 if (mode & VWRITE) 775 mask |= S_IWUSR; 776 return ((hp->h_mode & mask) == mask ? 0 : EACCES); 777 } 778 779 /* Otherwise, check the groups. */ 780 for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++) 781 if (hp->h_gid == *gp) { 782 if (mode & VEXEC) 783 mask |= S_IXGRP; 784 if (mode & VREAD) 785 mask |= S_IRGRP; 786 if (mode & VWRITE) 787 mask |= S_IWGRP; 788 return ((hp->h_mode & mask) == mask ? 0 : EACCES); 789 } 790 791 /* Otherwise, check everyone else. */ 792 if (mode & VEXEC) 793 mask |= S_IXOTH; 794 if (mode & VREAD) 795 mask |= S_IROTH; 796 if (mode & VWRITE) 797 mask |= S_IWOTH; 798 return ((hp->h_mode & mask) == mask ? 0 : EACCES); 799 } 800 801 /* 802 * Open called. 803 * 804 * Nothing to do. 805 * 806 * hpfs_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred, 807 * struct proc *a_td) 808 */ 809 /* ARGSUSED */ 810 static int 811 hpfs_open(struct vop_open_args *ap) 812 { 813 #if HPFS_DEBUG 814 struct vnode *vp = ap->a_vp; 815 struct hpfsnode *hp = VTOHP(vp); 816 817 printf("hpfs_open(0x%x):\n",hp->h_no); 818 #endif 819 820 /* 821 * Files marked append-only must be opened for appending. 822 */ 823 824 return (0); 825 } 826 827 /* 828 * Close called. 829 * 830 * Update the times on the inode. 831 * 832 * hpfs_close(struct vnode *a_vp, int a_fflag, struct ucred *a_cred, 833 * struct proc *a_td) 834 */ 835 /* ARGSUSED */ 836 static int 837 hpfs_close(struct vop_close_args *ap) 838 { 839 #if HPFS_DEBUG 840 struct vnode *vp = ap->a_vp; 841 struct hpfsnode *hp = VTOHP(vp); 842 843 printf("hpfs_close: %d\n",hp->h_no); 844 #endif 845 846 return (0); 847 } 848 849 static int 850 hpfs_de_uiomove(struct hpfsmount *hpmp, struct hpfsdirent *dep, 851 struct uio *uio) 852 { 853 struct dirent cde; 854 int i, error; 855 856 dprintf(("[no: 0x%x, size: %d, name: %2d:%.*s, flag: 0x%x] ", 857 dep->de_fnode, dep->de_size, dep->de_namelen, 858 dep->de_namelen, dep->de_name, dep->de_flag)); 859 860 /*strncpy(cde.d_name, dep->de_name, dep->de_namelen);*/ 861 for (i=0; i<dep->de_namelen; i++) 862 cde.d_name[i] = hpfs_d2u(hpmp, dep->de_name[i]); 863 864 cde.d_name[dep->de_namelen] = '\0'; 865 cde.d_namlen = dep->de_namelen; 866 cde.d_fileno = dep->de_fnode; 867 cde.d_type = (dep->de_flag & DE_DIR) ? DT_DIR : DT_REG; 868 cde.d_reclen = sizeof(struct dirent); 869 870 error = uiomove((char *)&cde, sizeof(struct dirent), uio); 871 if (error) 872 return (error); 873 874 dprintf(("[0x%x] ", uio->uio_resid)); 875 return (error); 876 } 877 878 879 static struct dirent hpfs_de_dot = 880 { 0, sizeof(struct dirent), DT_DIR, 1, "." }; 881 static struct dirent hpfs_de_dotdot = 882 { 0, sizeof(struct dirent), DT_DIR, 2, ".." }; 883 884 /* 885 * hpfs_readdir(struct vnode *a_vp, struct uio *a_uio, struct ucred *a_cred, 886 * int *a_ncookies, u_int **cookies) 887 */ 888 int 889 hpfs_readdir(struct vop_readdir_args *ap) 890 { 891 struct vnode *vp = ap->a_vp; 892 struct hpfsnode *hp = VTOHP(vp); 893 struct hpfsmount *hpmp = hp->h_hpmp; 894 struct uio *uio = ap->a_uio; 895 int ncookies = 0, i, num, cnum; 896 int error = 0; 897 off_t off; 898 struct buf *bp; 899 struct dirblk *dp; 900 struct hpfsdirent *dep; 901 lsn_t olsn; 902 lsn_t lsn; 903 int level; 904 905 dprintf(("hpfs_readdir(0x%x, 0x%x, 0x%x): ",hp->h_no,(u_int32_t)uio->uio_offset,uio->uio_resid)); 906 907 off = uio->uio_offset; 908 909 if( uio->uio_offset < sizeof(struct dirent) ) { 910 dprintf((". faked, ")); 911 hpfs_de_dot.d_fileno = hp->h_no; 912 error = uiomove((char *)&hpfs_de_dot,sizeof(struct dirent),uio); 913 if(error) { 914 return (error); 915 } 916 917 ncookies ++; 918 } 919 920 if( uio->uio_offset < 2 * sizeof(struct dirent) ) { 921 dprintf((".. faked, ")); 922 hpfs_de_dotdot.d_fileno = hp->h_fn.fn_parent; 923 924 error = uiomove((char *)&hpfs_de_dotdot, sizeof(struct dirent), 925 uio); 926 if(error) { 927 return (error); 928 } 929 930 ncookies ++; 931 } 932 933 num = uio->uio_offset / sizeof(struct dirent) - 2; 934 cnum = 0; 935 936 lsn = ((alleaf_t *)hp->h_fn.fn_abd)->al_lsn; 937 938 olsn = 0; 939 level = 1; 940 941 dive: 942 dprintf(("[dive 0x%x] ", lsn)); 943 error = bread(hp->h_devvp, lsn, D_BSIZE, &bp); 944 if (error) { 945 brelse(bp); 946 return (error); 947 } 948 949 dp = (struct dirblk *) bp->b_data; 950 if (dp->d_magic != D_MAGIC) { 951 printf("hpfs_readdir: MAGIC DOESN'T MATCH\n"); 952 brelse(bp); 953 return (EINVAL); 954 } 955 956 dep = D_DIRENT(dp); 957 958 if (olsn) { 959 dprintf(("[restore 0x%x] ", olsn)); 960 961 while(!(dep->de_flag & DE_END) ) { 962 if((dep->de_flag & DE_DOWN) && 963 (olsn == DE_DOWNLSN(dep))) 964 break; 965 dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen); 966 } 967 968 if((dep->de_flag & DE_DOWN) && (olsn == DE_DOWNLSN(dep))) { 969 if (dep->de_flag & DE_END) 970 goto blockdone; 971 972 if (!(dep->de_flag & DE_SPECIAL)) { 973 if (num <= cnum) { 974 if (uio->uio_resid < sizeof(struct dirent)) { 975 brelse(bp); 976 dprintf(("[resid] ")); 977 goto readdone; 978 } 979 980 error = hpfs_de_uiomove(hpmp, dep, uio); 981 if (error) { 982 brelse (bp); 983 return (error); 984 } 985 ncookies++; 986 987 if (uio->uio_resid < sizeof(struct dirent)) { 988 brelse(bp); 989 dprintf(("[resid] ")); 990 goto readdone; 991 } 992 } 993 cnum++; 994 } 995 996 dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen); 997 } else { 998 printf("hpfs_readdir: ERROR! oLSN not found\n"); 999 brelse(bp); 1000 return (EINVAL); 1001 } 1002 } 1003 1004 olsn = 0; 1005 1006 while(!(dep->de_flag & DE_END)) { 1007 if(dep->de_flag & DE_DOWN) { 1008 lsn = DE_DOWNLSN(dep); 1009 brelse(bp); 1010 level++; 1011 goto dive; 1012 } 1013 1014 if (!(dep->de_flag & DE_SPECIAL)) { 1015 if (num <= cnum) { 1016 if (uio->uio_resid < sizeof(struct dirent)) { 1017 brelse(bp); 1018 dprintf(("[resid] ")); 1019 goto readdone; 1020 } 1021 1022 error = hpfs_de_uiomove(hpmp, dep, uio); 1023 if (error) { 1024 brelse (bp); 1025 return (error); 1026 } 1027 ncookies++; 1028 1029 if (uio->uio_resid < sizeof(struct dirent)) { 1030 brelse(bp); 1031 dprintf(("[resid] ")); 1032 goto readdone; 1033 } 1034 } 1035 cnum++; 1036 } 1037 1038 dep = (hpfsdirent_t *)((caddr_t)dep + dep->de_reclen); 1039 } 1040 1041 if(dep->de_flag & DE_DOWN) { 1042 dprintf(("[enddive] ")); 1043 lsn = DE_DOWNLSN(dep); 1044 brelse(bp); 1045 level++; 1046 goto dive; 1047 } 1048 1049 blockdone: 1050 dprintf(("[EOB] ")); 1051 olsn = lsn; 1052 lsn = dp->d_parent; 1053 brelse(bp); 1054 level--; 1055 1056 dprintf(("[level %d] ", level)); 1057 1058 if (level > 0) 1059 goto dive; /* undive really */ 1060 1061 if (ap->a_eofflag) { 1062 dprintf(("[EOF] ")); 1063 *ap->a_eofflag = 1; 1064 } 1065 1066 readdone: 1067 dprintf(("[readdone]\n")); 1068 if (!error && ap->a_ncookies != NULL) { 1069 struct dirent* dpStart; 1070 struct dirent* dp; 1071 #if defined(__DragonFly__) 1072 u_long *cookies; 1073 u_long *cookiep; 1074 #else /* defined(__NetBSD__) */ 1075 off_t *cookies; 1076 off_t *cookiep; 1077 #endif 1078 1079 dprintf(("%d cookies, ",ncookies)); 1080 if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1) 1081 panic("hpfs_readdir: unexpected uio from NFS server"); 1082 dpStart = (struct dirent *) 1083 ((caddr_t)uio->uio_iov->iov_base - 1084 (uio->uio_offset - off)); 1085 #if defined(__DragonFly__) 1086 MALLOC(cookies, u_long *, ncookies * sizeof(u_long), 1087 M_TEMP, M_WAITOK); 1088 #else /* defined(__NetBSD__) */ 1089 MALLOC(cookies, off_t *, ncookies * sizeof(off_t), 1090 M_TEMP, M_WAITOK); 1091 #endif 1092 for (dp = dpStart, cookiep = cookies, i=0; 1093 i < ncookies; 1094 dp = (struct dirent *)((caddr_t) dp + dp->d_reclen), i++) { 1095 off += dp->d_reclen; 1096 *cookiep++ = (u_int) off; 1097 } 1098 *ap->a_ncookies = ncookies; 1099 *ap->a_cookies = cookies; 1100 } 1101 1102 return (0); 1103 } 1104 1105 /* 1106 * hpfs_lookup(struct vnode *a_dvp, struct vnode **a_vpp, 1107 * struct componentname *a_cnp) 1108 */ 1109 int 1110 hpfs_lookup(struct vop_lookup_args *ap) 1111 { 1112 struct vnode *dvp = ap->a_dvp; 1113 struct hpfsnode *dhp = VTOHP(dvp); 1114 struct hpfsmount *hpmp = dhp->h_hpmp; 1115 struct componentname *cnp = ap->a_cnp; 1116 struct ucred *cred = cnp->cn_cred; 1117 int error; 1118 int nameiop = cnp->cn_nameiop; 1119 int flags = cnp->cn_flags; 1120 int lockparent = flags & CNP_LOCKPARENT; 1121 #if HPFS_DEBUG 1122 int wantparent = flags & (CNP_LOCKPARENT | CNP_WANTPARENT); 1123 #endif 1124 dprintf(("hpfs_lookup(0x%x, %s, %ld, %d, %d): \n", 1125 dhp->h_no, cnp->cn_nameptr, cnp->cn_namelen, 1126 lockparent, wantparent)); 1127 1128 if (nameiop != NAMEI_CREATE && nameiop != NAMEI_DELETE && nameiop != NAMEI_LOOKUP) { 1129 printf("hpfs_lookup: LOOKUP, DELETE and CREATE are only supported\n"); 1130 return (EOPNOTSUPP); 1131 } 1132 1133 error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_td); 1134 if(error) 1135 return (error); 1136 1137 if( (cnp->cn_namelen == 1) && 1138 !strncmp(cnp->cn_nameptr,".",1) ) { 1139 dprintf(("hpfs_lookup(0x%x,...): . faked\n",dhp->h_no)); 1140 1141 vref(dvp); 1142 *ap->a_vpp = dvp; 1143 1144 return (0); 1145 } else if( (cnp->cn_namelen == 2) && 1146 !strncmp(cnp->cn_nameptr,"..",2) && (flags & CNP_ISDOTDOT) ) { 1147 dprintf(("hpfs_lookup(0x%x,...): .. faked (0x%x)\n", 1148 dhp->h_no, dhp->h_fn.fn_parent)); 1149 1150 VOP__UNLOCK(dvp,0,cnp->cn_td); 1151 1152 error = VFS_VGET(hpmp->hpm_mp, 1153 dhp->h_fn.fn_parent, ap->a_vpp); 1154 if(error) { 1155 VOP__LOCK(dvp, 0, cnp->cn_td); 1156 return(error); 1157 } 1158 1159 if( lockparent && (flags & CNP_ISLASTCN) && 1160 (error = VOP__LOCK(dvp, 0, cnp->cn_td)) ) { 1161 vput( *(ap->a_vpp) ); 1162 return (error); 1163 } 1164 return (error); 1165 } else { 1166 struct buf *bp; 1167 struct hpfsdirent *dep; 1168 struct hpfsnode *hp; 1169 1170 error = hpfs_genlookupbyname(dhp, 1171 cnp->cn_nameptr, cnp->cn_namelen, &bp, &dep); 1172 if (error) { 1173 if ((error == ENOENT) && (flags & CNP_ISLASTCN) && 1174 (nameiop == NAMEI_CREATE || nameiop == NAMEI_RENAME)) { 1175 if(!lockparent) 1176 VOP__UNLOCK(dvp, 0, cnp->cn_td); 1177 cnp->cn_flags |= CNP_SAVENAME; 1178 return (EJUSTRETURN); 1179 } 1180 1181 return (error); 1182 } 1183 1184 dprintf(("hpfs_lookup: fnode: 0x%x, CPID: 0x%x\n", 1185 dep->de_fnode, dep->de_cpid)); 1186 1187 if (nameiop == NAMEI_DELETE && (flags & CNP_ISLASTCN)) { 1188 error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_td); 1189 if (error) { 1190 brelse(bp); 1191 return (error); 1192 } 1193 } 1194 1195 if (dhp->h_no == dep->de_fnode) { 1196 brelse(bp); 1197 vref(dvp); 1198 *ap->a_vpp = dvp; 1199 return (0); 1200 } 1201 1202 error = VFS_VGET(hpmp->hpm_mp, dep->de_fnode, ap->a_vpp); 1203 if (error) { 1204 printf("hpfs_lookup: VFS_VGET FAILED %d\n", error); 1205 brelse(bp); 1206 return(error); 1207 } 1208 1209 hp = VTOHP(*ap->a_vpp); 1210 1211 hp->h_mtime = dep->de_mtime; 1212 hp->h_ctime = dep->de_ctime; 1213 hp->h_atime = dep->de_atime; 1214 bcopy(dep->de_name, hp->h_name, dep->de_namelen); 1215 hp->h_name[dep->de_namelen] = '\0'; 1216 hp->h_namelen = dep->de_namelen; 1217 hp->h_flag |= H_PARVALID; 1218 1219 brelse(bp); 1220 1221 if(!lockparent || !(flags & CNP_ISLASTCN)) 1222 VOP__UNLOCK(dvp, 0, cnp->cn_td); 1223 if ((flags & CNP_MAKEENTRY) && 1224 (!(flags & CNP_ISLASTCN) || 1225 (nameiop != NAMEI_DELETE && nameiop != NAMEI_CREATE))) 1226 cache_enter(dvp, NCPNULL, *ap->a_vpp, cnp); 1227 } 1228 return (error); 1229 } 1230 1231 /* 1232 * hpfs_remove(struct vnode *a_dvp, struct vnode *a_vp, 1233 * struct componentname *a_cnp) 1234 */ 1235 int 1236 hpfs_remove(struct vop_remove_args *ap) 1237 { 1238 int error; 1239 1240 dprintf(("hpfs_remove(0x%x, %s, %ld): \n", VTOHP(ap->a_vp)->h_no, 1241 ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen)); 1242 1243 if (ap->a_vp->v_type == VDIR) 1244 return (EPERM); 1245 1246 error = hpfs_removefnode (ap->a_dvp, ap->a_vp, ap->a_cnp); 1247 return (error); 1248 } 1249 1250 /* 1251 * hpfs_create(struct vnode *a_dvp, struct vnode **a_vpp, 1252 * struct componentname *a_cnp, struct vattr *a_vap) 1253 */ 1254 int 1255 hpfs_create(struct vop_create_args *ap) 1256 { 1257 int error; 1258 1259 dprintf(("hpfs_create(0x%x, %s, %ld): \n", VTOHP(ap->a_dvp)->h_no, 1260 ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen)); 1261 1262 if (!(ap->a_cnp->cn_flags & CNP_HASBUF)) 1263 panic ("hpfs_create: no name\n"); 1264 1265 error = hpfs_makefnode (ap->a_dvp, ap->a_vpp, ap->a_cnp, ap->a_vap); 1266 1267 return (error); 1268 } 1269 1270 /* 1271 * Return POSIX pathconf information applicable to NTFS filesystem 1272 * 1273 * hpfs_pathconf(struct vnode *a_vp, int a_name, t *a_retval) 1274 */ 1275 int 1276 hpfs_pathconf(struct vop_pathconf_args *ap) 1277 { 1278 switch (ap->a_name) { 1279 case _PC_LINK_MAX: 1280 *ap->a_retval = 1; 1281 return (0); 1282 case _PC_NAME_MAX: 1283 *ap->a_retval = HPFS_MAXFILENAME; 1284 return (0); 1285 case _PC_PATH_MAX: 1286 *ap->a_retval = PATH_MAX; 1287 return (0); 1288 case _PC_CHOWN_RESTRICTED: 1289 *ap->a_retval = 1; 1290 return (0); 1291 case _PC_NO_TRUNC: 1292 *ap->a_retval = 0; 1293 return (0); 1294 #if defined(__NetBSD__) 1295 case _PC_SYNC_IO: 1296 *ap->a_retval = 1; 1297 return (0); 1298 case _PC_FILESIZEBITS: 1299 *ap->a_retval = 32; 1300 return (0); 1301 #endif 1302 default: 1303 return (EINVAL); 1304 } 1305 /* NOTREACHED */ 1306 } 1307 1308 1309 /* 1310 * Global vfs data structures 1311 */ 1312 #if defined(__DragonFly__) 1313 struct vnodeopv_entry_desc hpfs_vnodeop_entries[] = { 1314 { &vop_default_desc, (void *)vop_defaultop }, 1315 1316 { &vop_getattr_desc, (void *)hpfs_getattr }, 1317 { &vop_setattr_desc, (void *)hpfs_setattr }, 1318 { &vop_inactive_desc, (void *)hpfs_inactive }, 1319 { &vop_reclaim_desc, (void *)hpfs_reclaim }, 1320 { &vop_print_desc, (void *)hpfs_print }, 1321 { &vop_create_desc, (void *)hpfs_create }, 1322 { &vop_remove_desc, (void *)hpfs_remove }, 1323 { &vop_islocked_desc, (void *)vop_stdislocked }, 1324 { &vop_unlock_desc, (void *)vop_stdunlock }, 1325 { &vop_lock_desc, (void *)vop_stdlock }, 1326 { &vop_cachedlookup_desc, (void *)hpfs_lookup }, 1327 { &vop_lookup_desc, (void *)vfs_cache_lookup }, 1328 { &vop_access_desc, (void *)hpfs_access }, 1329 { &vop_close_desc, (void *)hpfs_close }, 1330 { &vop_open_desc, (void *)hpfs_open }, 1331 { &vop_readdir_desc, (void *)hpfs_readdir }, 1332 { &vop_fsync_desc, (void *)hpfs_fsync }, 1333 { &vop_bmap_desc, (void *)hpfs_bmap }, 1334 { &vop_getpages_desc, (void *) hpfs_getpages }, 1335 { &vop_putpages_desc, (void *) hpfs_putpages }, 1336 { &vop_strategy_desc, (void *)hpfs_strategy }, 1337 { &vop_bwrite_desc, (void *)vop_stdbwrite }, 1338 { &vop_read_desc, (void *)hpfs_read }, 1339 { &vop_write_desc, (void *)hpfs_write }, 1340 { &vop_ioctl_desc, (void *)hpfs_ioctl }, 1341 { &vop_pathconf_desc, (void *)hpfs_pathconf }, 1342 { NULL, NULL } 1343 }; 1344 1345 #else /* defined(__NetBSD__) */ 1346 struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = { 1347 { &vop_default_desc, (void *) genfs_badop }, /* XXX */ 1348 { &vop_lookup_desc, (void *) hpfs_lookup }, /* lookup */ 1349 { &vop_create_desc, genfs_eopnotsupp }, /* create */ 1350 { &vop_mknod_desc, genfs_eopnotsupp }, /* mknod */ 1351 { &vop_open_desc, (void *) hpfs_open }, /* open */ 1352 { &vop_close_desc,(void *) hpfs_close }, /* close */ 1353 { &vop_access_desc, (void *) hpfs_access }, /* access */ 1354 { &vop_getattr_desc, (void *) hpfs_getattr }, /* getattr */ 1355 { &vop_setattr_desc, genfs_eopnotsupp }, /* setattr */ 1356 { &vop_read_desc, (void *) hpfs_read }, /* read */ 1357 { &vop_write_desc, (void *) hpfs_write }, /* write */ 1358 { &vop_lease_desc, genfs_lease_check }, /* lease */ 1359 { &vop_fcntl_desc, genfs_fcntl }, /* fcntl */ 1360 { &vop_ioctl_desc, genfs_enoioctl }, /* ioctl */ 1361 { &vop_poll_desc, genfs_poll }, /* poll */ 1362 { &vop_revoke_desc, genfs_revoke }, /* revoke */ 1363 { &vop_mmap_desc, genfs_eopnotsupp }, /* mmap */ 1364 { &vop_fsync_desc, genfs_fsync }, /* fsync */ 1365 { &vop_seek_desc, genfs_seek }, /* seek */ 1366 { &vop_remove_desc, genfs_eopnotsupp }, /* remove */ 1367 { &vop_link_desc, genfs_eopnotsupp }, /* link */ 1368 { &vop_rename_desc, genfs_eopnotsupp }, /* rename */ 1369 { &vop_mkdir_desc, genfs_eopnotsupp }, /* mkdir */ 1370 { &vop_rmdir_desc, genfs_eopnotsupp }, /* rmdir */ 1371 { &vop_symlink_desc, genfs_eopnotsupp }, /* symlink */ 1372 { &vop_readdir_desc, (void *) hpfs_readdir }, /* readdir */ 1373 { &vop_readlink_desc, genfs_eopnotsupp }, /* readlink */ 1374 { &vop_abortop_desc, genfs_abortop }, /* abortop */ 1375 { &vop_inactive_desc, (void *) hpfs_inactive }, /* inactive */ 1376 { &vop_reclaim_desc, (void *) hpfs_reclaim }, /* reclaim */ 1377 { &vop_lock_desc, genfs_lock }, /* lock */ 1378 { &vop_unlock_desc, genfs_unlock }, /* unlock */ 1379 { &vop_bmap_desc, (void *) hpfs_bmap }, /* bmap */ 1380 { &vop_strategy_desc, (void *) hpfs_strategy }, /* strategy */ 1381 { &vop_print_desc, (void *) hpfs_print }, /* print */ 1382 { &vop_islocked_desc, genfs_islocked }, /* islocked */ 1383 { &vop_pathconf_desc, hpfs_pathconf }, /* pathconf */ 1384 { &vop_advlock_desc, genfs_nullop }, /* advlock */ 1385 { &vop_blkatoff_desc, genfs_eopnotsupp }, /* blkatoff */ 1386 { &vop_valloc_desc, genfs_eopnotsupp }, /* valloc */ 1387 { &vop_reallocblks_desc, genfs_eopnotsupp }, /* reallocblks */ 1388 { &vop_vfree_desc, genfs_eopnotsupp }, /* vfree */ 1389 { &vop_truncate_desc, genfs_eopnotsupp }, /* truncate */ 1390 { &vop_update_desc, genfs_eopnotsupp }, /* update */ 1391 { &vop_bwrite_desc, vn_bwrite }, /* bwrite */ 1392 { (struct vnodeop_desc *)NULL, (int (*) (void *))NULL } 1393 }; 1394 1395 #endif 1396