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