Home | History | Annotate | Line # | Download | only in hfs
hfs_vnops.c revision 1.29.2.1
      1 /*	$NetBSD: hfs_vnops.c,v 1.29.2.1 2014/08/10 06:55:53 tls Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Yevgeny Binder and Dieter Baron.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Copyright (c) 1992, 1993
     34  *	The Regents of the University of California.  All rights reserved.
     35  *
     36  * This code is derived from software donated to Berkeley by
     37  * Jan-Simon Pendry.
     38  *
     39  * Redistribution and use in source and binary forms, with or without
     40  * modification, are permitted provided that the following conditions
     41  * are met:
     42  * 1. Redistributions of source code must retain the above copyright
     43  *    notice, this list of conditions and the following disclaimer.
     44  * 2. Redistributions in binary form must reproduce the above copyright
     45  *    notice, this list of conditions and the following disclaimer in the
     46  *    documentation and/or other materials provided with the distribution.
     47  * 3. Neither the name of the University nor the names of its contributors
     48  *    may be used to endorse or promote products derived from this software
     49  *    without specific prior written permission.
     50  *
     51  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     52  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     53  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     54  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     55  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     56  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     57  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     58  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     59  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     60  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     61  * SUCH DAMAGE.
     62  */
     63 
     64 /*
     65  * Copyright (c) 1982, 1986, 1989, 1993, 1995
     66  *	The Regents of the University of California.  All rights reserved.
     67  * (c) UNIX System Laboratories, Inc.
     68  * All or some portions of this file are derived from material licensed
     69  * to the University of California by American Telephone and Telegraph
     70  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     71  * the permission of UNIX System Laboratories, Inc.
     72  *
     73  * Redistribution and use in source and binary forms, with or without
     74  * modification, are permitted provided that the following conditions
     75  * are met:
     76  * 1. Redistributions of source code must retain the above copyright
     77  *    notice, this list of conditions and the following disclaimer.
     78  * 2. Redistributions in binary form must reproduce the above copyright
     79  *    notice, this list of conditions and the following disclaimer in the
     80  *    documentation and/or other materials provided with the distribution.
     81  * 3. Neither the name of the University nor the names of its contributors
     82  *    may be used to endorse or promote products derived from this software
     83  *    without specific prior written permission.
     84  *
     85  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     86  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     87  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     88  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     89  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     90  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     91  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     92  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     93  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     94  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     95  * SUCH DAMAGE.
     96  */
     97 
     98 
     99 /*
    100  * Apple HFS+ filesystem
    101  */
    102 
    103 #include <sys/cdefs.h>
    104 __KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.29.2.1 2014/08/10 06:55:53 tls Exp $");
    105 
    106 #ifdef _KERNEL_OPT
    107 #include "opt_ipsec.h"
    108 #endif
    109 
    110 #include <sys/param.h>
    111 #include <sys/systm.h>
    112 #include <sys/kernel.h>
    113 #include <sys/vmmeter.h>
    114 #include <sys/time.h>
    115 #include <sys/proc.h>
    116 #include <sys/vnode.h>
    117 #include <sys/malloc.h>
    118 #include <sys/file.h>
    119 #include <sys/stat.h>
    120 #include <sys/mount.h>
    121 #include <sys/namei.h>
    122 #include <sys/buf.h>
    123 #include <sys/dirent.h>
    124 #include <sys/msgbuf.h>
    125 
    126 #include <miscfs/fifofs/fifo.h>
    127 #include <miscfs/specfs/specdev.h>
    128 
    129 #include <fs/hfs/hfs.h>
    130 #include <fs/hfs/unicode.h>
    131 
    132 #include <miscfs/genfs/genfs.h>
    133 
    134 int	hfs_vop_lookup(void *);
    135 int	hfs_vop_open(void *);
    136 int	hfs_vop_close(void *);
    137 int	hfs_vop_access(void *);
    138 int	hfs_vop_getattr(void *);
    139 int	hfs_vop_setattr(void *);
    140 int	hfs_vop_bmap(void *);
    141 int	hfs_vop_read(void *);
    142 int	hfs_vop_readdir(void *);
    143 int	hfs_vop_readlink(void *);
    144 int	hfs_vop_reclaim(void *);
    145 int	hfs_vop_print(void *);
    146 
    147 #ifdef HFS_DEBUG
    148 #define DPRINTF(a) printf a
    149 #else
    150 #define DPRINTF(a)
    151 #endif
    152 
    153 
    154 int (**hfs_vnodeop_p) (void *);
    155 const struct vnodeopv_entry_desc hfs_vnodeop_entries[] = {
    156 	{ &vop_default_desc, vn_default_error },
    157 	{ &vop_lookup_desc, hfs_vop_lookup },		/* lookup */
    158 	{ &vop_create_desc, genfs_eopnotsupp },		/* create */
    159 	{ &vop_whiteout_desc, genfs_eopnotsupp },	/* whiteout */
    160 	{ &vop_mknod_desc, genfs_eopnotsupp },		/* mknod */
    161 	{ &vop_open_desc, hfs_vop_open },		/* open */
    162 	{ &vop_close_desc, hfs_vop_close },		/* close */
    163 	{ &vop_access_desc, hfs_vop_access },		/* access */
    164 	{ &vop_getattr_desc, hfs_vop_getattr },		/* getattr */
    165 	{ &vop_setattr_desc, hfs_vop_setattr },		/* setattr */
    166 	{ &vop_read_desc, hfs_vop_read },		/* read */
    167 	{ &vop_write_desc, genfs_eopnotsupp },		/* write */
    168 	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
    169 	{ &vop_fdiscard_desc, genfs_eopnotsupp },	/* fdiscard */
    170 	{ &vop_ioctl_desc, genfs_eopnotsupp },		/* ioctl */
    171 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
    172 	{ &vop_poll_desc, genfs_eopnotsupp },		/* poll */
    173 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
    174 	{ &vop_revoke_desc, genfs_eopnotsupp },		/* revoke */
    175 	{ &vop_mmap_desc, genfs_mmap },			/* mmap */
    176 	{ &vop_fsync_desc, genfs_nullop },		/* fsync */
    177 	{ &vop_seek_desc, genfs_seek },			/* seek */
    178 	{ &vop_remove_desc, genfs_eopnotsupp },		/* remove */
    179 	{ &vop_link_desc, genfs_eopnotsupp },		/* link */
    180 	{ &vop_rename_desc, genfs_eopnotsupp },		/* rename */
    181 	{ &vop_mkdir_desc, genfs_eopnotsupp },		/* mkdir */
    182 	{ &vop_rmdir_desc, genfs_eopnotsupp },		/* rmdir */
    183 	{ &vop_symlink_desc, genfs_eopnotsupp },	/* symlink */
    184 	{ &vop_readdir_desc, hfs_vop_readdir },		/* readdir */
    185 	{ &vop_readlink_desc, hfs_vop_readlink },	/* readlink */
    186 	{ &vop_abortop_desc, genfs_abortop },		/* abortop */
    187 	{ &vop_inactive_desc, genfs_eopnotsupp },	/* inactive */
    188 	{ &vop_reclaim_desc, hfs_vop_reclaim },		/* reclaim */
    189 	{ &vop_lock_desc, genfs_lock },			/* lock */
    190 	{ &vop_unlock_desc, genfs_unlock },		/* unlock */
    191 	{ &vop_bmap_desc, hfs_vop_bmap },		/* bmap */
    192 	{ &vop_strategy_desc, genfs_eopnotsupp },	/* strategy */
    193 	{ &vop_print_desc, hfs_vop_print },		/* print */
    194 	{ &vop_islocked_desc, genfs_islocked },		/* islocked */
    195 	{ &vop_pathconf_desc, genfs_eopnotsupp },	/* pathconf */
    196 	{ &vop_advlock_desc, genfs_eopnotsupp },	/* advlock */
    197 	{ &vop_bwrite_desc, genfs_eopnotsupp },		/* bwrite */
    198 	{ &vop_getpages_desc, genfs_getpages },		/* getpages */
    199 	{ &vop_putpages_desc, genfs_putpages },		/* putpages */
    200 	{ &vop_openextattr_desc, genfs_eopnotsupp },	/* openextattr */
    201 	{ &vop_closeextattr_desc, genfs_eopnotsupp },	/* closeextattr */
    202 	{ &vop_getextattr_desc, genfs_eopnotsupp },	/* getextattr */
    203 	{ &vop_setextattr_desc, genfs_eopnotsupp },	/* setextattr */
    204 	{ &vop_listextattr_desc, genfs_eopnotsupp },	/* listextattr */
    205 	{ &vop_deleteextattr_desc, genfs_eopnotsupp },	/* deleteextattr */
    206 	{ NULL, NULL }
    207 };
    208 const struct vnodeopv_desc hfs_vnodeop_opv_desc =
    209 	{ &hfs_vnodeop_p, hfs_vnodeop_entries };
    210 
    211 int (**hfs_specop_p) (void *);
    212 const struct vnodeopv_entry_desc hfs_specop_entries[] = {
    213 	{ &vop_default_desc, vn_default_error },
    214 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
    215 	{ &vop_create_desc, spec_create },		/* create */
    216 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
    217 	{ &vop_open_desc, spec_open },			/* open */
    218 	{ &vop_close_desc, spec_close },		/* close */
    219 	{ &vop_access_desc, hfs_vop_access },		/* access */
    220 	{ &vop_getattr_desc, hfs_vop_getattr },		/* getattr */
    221 	{ &vop_setattr_desc, hfs_vop_setattr },		/* setattr */
    222 	{ &vop_read_desc, spec_read },			/* read */
    223 	{ &vop_write_desc, spec_write },		/* write */
    224 	{ &vop_fallocate_desc, spec_fallocate },	/* fallocate */
    225 	{ &vop_fdiscard_desc, spec_fdiscard },		/* fdiscard */
    226 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
    227 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
    228 	{ &vop_poll_desc, spec_poll },			/* poll */
    229 	{ &vop_kqfilter_desc, spec_kqfilter },		/* kqfilter */
    230 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
    231 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
    232 	{ &vop_fsync_desc, spec_fsync },		/* fsync */
    233 	{ &vop_seek_desc, spec_seek },			/* seek */
    234 	{ &vop_remove_desc, spec_remove },		/* remove */
    235 	{ &vop_link_desc, spec_link },			/* link */
    236 	{ &vop_rename_desc, spec_rename },		/* rename */
    237 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
    238 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
    239 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
    240 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
    241 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
    242 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
    243 	{ &vop_inactive_desc, genfs_eopnotsupp },	/* inactive */
    244 	{ &vop_reclaim_desc, hfs_vop_reclaim },		/* reclaim */
    245 	{ &vop_lock_desc, genfs_lock },			/* lock */
    246 	{ &vop_unlock_desc, genfs_unlock },		/* unlock */
    247 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
    248 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
    249 	{ &vop_print_desc, hfs_vop_print },		/* print */
    250 	{ &vop_islocked_desc, genfs_islocked },		/* islocked */
    251 	{ &vop_pathconf_desc, spec_pathconf },		/* pathconf */
    252 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
    253 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    254 	{ &vop_getpages_desc, spec_getpages },		/* getpages */
    255 	{ &vop_putpages_desc, spec_putpages },		/* putpages */
    256 #if 0
    257 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    258 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    259 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    260 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    261 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    262 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    263 #endif
    264 	{ NULL, NULL }
    265 };
    266 const struct vnodeopv_desc hfs_specop_opv_desc =
    267 	{ &hfs_specop_p, hfs_specop_entries };
    268 
    269 int (**hfs_fifoop_p) (void *);
    270 const struct vnodeopv_entry_desc hfs_fifoop_entries[] = {
    271 	{ &vop_default_desc, vn_default_error },
    272 	{ &vop_lookup_desc, vn_fifo_bypass },		/* lookup */
    273 	{ &vop_create_desc, vn_fifo_bypass },		/* create */
    274 	{ &vop_mknod_desc, vn_fifo_bypass },		/* mknod */
    275 	{ &vop_open_desc, vn_fifo_bypass },		/* open */
    276 	{ &vop_close_desc, vn_fifo_bypass },		/* close */
    277 	{ &vop_access_desc, hfs_vop_access },		/* access */
    278 	{ &vop_getattr_desc, hfs_vop_getattr },		/* getattr */
    279 	{ &vop_setattr_desc, hfs_vop_setattr },		/* setattr */
    280 	{ &vop_read_desc, vn_fifo_bypass },		/* read */
    281 	{ &vop_write_desc, vn_fifo_bypass },		/* write */
    282 	{ &vop_fallocate_desc, vn_fifo_bypass },	/* fallocate */
    283 	{ &vop_fdiscard_desc, vn_fifo_bypass },		/* fdiscard */
    284 	{ &vop_ioctl_desc, vn_fifo_bypass },		/* ioctl */
    285 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
    286 	{ &vop_poll_desc, vn_fifo_bypass },		/* poll */
    287 	{ &vop_kqfilter_desc, vn_fifo_bypass },		/* kqfilter */
    288 	{ &vop_revoke_desc, vn_fifo_bypass },		/* revoke */
    289 	{ &vop_mmap_desc, vn_fifo_bypass },		/* mmap */
    290 	{ &vop_fsync_desc, vn_fifo_bypass },		/* fsync */
    291 	{ &vop_seek_desc, vn_fifo_bypass },		/* seek */
    292 	{ &vop_remove_desc, vn_fifo_bypass },		/* remove */
    293 	{ &vop_link_desc, vn_fifo_bypass },		/* link */
    294 	{ &vop_rename_desc, vn_fifo_bypass },		/* rename */
    295 	{ &vop_mkdir_desc, vn_fifo_bypass },		/* mkdir */
    296 	{ &vop_rmdir_desc, vn_fifo_bypass },		/* rmdir */
    297 	{ &vop_symlink_desc, vn_fifo_bypass },		/* symlink */
    298 	{ &vop_readdir_desc, vn_fifo_bypass },		/* readdir */
    299 	{ &vop_readlink_desc, vn_fifo_bypass },		/* readlink */
    300 	{ &vop_abortop_desc, vn_fifo_bypass },		/* abortop */
    301 	{ &vop_inactive_desc, genfs_eopnotsupp },	/* inactive */
    302 	{ &vop_reclaim_desc, hfs_vop_reclaim },		/* reclaim */
    303 	{ &vop_lock_desc, genfs_lock },			/* lock */
    304 	{ &vop_unlock_desc, genfs_unlock },		/* unlock */
    305 	{ &vop_bmap_desc, vn_fifo_bypass },		/* bmap */
    306 	{ &vop_strategy_desc, vn_fifo_bypass },		/* strategy */
    307 	{ &vop_print_desc, hfs_vop_print },		/* print */
    308 	{ &vop_islocked_desc, genfs_islocked },		/* islocked */
    309 	{ &vop_pathconf_desc, vn_fifo_bypass },		/* pathconf */
    310 	{ &vop_advlock_desc, vn_fifo_bypass },		/* advlock */
    311 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    312 	{ &vop_putpages_desc, vn_fifo_bypass }, 	/* putpages */
    313 #if 0
    314 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    315 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    316 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    317 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    318 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    319 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    320 #endif
    321 	{ NULL, NULL }
    322 };
    323 const struct vnodeopv_desc hfs_fifoop_opv_desc =
    324 	{ &hfs_fifoop_p, hfs_fifoop_entries };
    325 
    326 int
    327 hfs_vop_lookup(void *v)
    328 {
    329 	struct vop_lookup_v2_args /* {
    330 		struct vnode * a_dvp;
    331 		struct vnode ** a_vpp;
    332 		struct componentname * a_cnp;
    333 	} */ *ap = v;
    334 	struct componentname *cnp;
    335 	struct hfsnode *dp;	/* hfsnode for directory being searched */
    336 	kauth_cred_t cred;
    337 	struct vnode **vpp;		/* resultant vnode */
    338 	struct vnode *pdp;		/* saved dp during symlink work */
    339 	struct vnode *tdp;		/* returned by VFS_VGET */
    340 	struct vnode *vdp;		/* vnode for directory being searched */
    341 	hfs_catalog_key_t key;	/* hfs+ catalog search key for requested child */
    342 	hfs_catalog_keyed_record_t rec; /* catalog record of requested child */
    343 	unichar_t* unicn;		/* name of component, in Unicode */
    344 	const char *pname;
    345 	int error;
    346 	int flags;
    347 	int result;			/* result of libhfs operations */
    348 
    349 	DPRINTF(("VOP = hfs_vop_lookup()\n"));
    350 
    351 	cnp = ap->a_cnp;
    352 	cred = cnp->cn_cred;
    353 	vdp = ap->a_dvp;
    354 	dp = VTOH(vdp);
    355 	error = 0;
    356 	pname = cnp->cn_nameptr;
    357 	result = 0;
    358 	unicn = NULL;
    359 	vpp = ap->a_vpp;
    360 	*vpp = NULL;
    361 
    362 	flags = cnp->cn_flags;
    363 
    364 
    365 	/*
    366 	 * Check accessiblity of directory.
    367 	 */
    368 	if ((error = VOP_ACCESS(vdp, VEXEC, cred)) != 0)
    369 		return error;
    370 
    371 	if ((flags & ISLASTCN) && (vdp->v_mount->mnt_flag & MNT_RDONLY) &&
    372 	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
    373 		return EROFS;
    374 
    375 	/*
    376 	 * We now have a segment name to search for, and a directory to search.
    377 	 *
    378 	 * Before tediously performing a linear scan of the directory,
    379 	 * check the name cache to see if the directory/name pair
    380 	 * we are looking for is known already.
    381 	 */
    382 /* XXX Cache disabled until we can make sure it works. */
    383 #if 0
    384 	if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
    385 		return error;
    386 #endif
    387 
    388 
    389 #if 0
    390 	if (cnp->cn_namelen == 1 && *pname == '.') {
    391 		*vpp = vdp;
    392 		vref(vdp);
    393 		return 0;
    394 	}
    395 #endif
    396 
    397 	pdp = vdp;
    398 	if (flags & ISDOTDOT) {
    399 		DPRINTF(("DOTDOT "));
    400 		VOP_UNLOCK(pdp);	/* race to get the inode */
    401 		error = VFS_VGET(vdp->v_mount, dp->h_parent, &tdp);
    402 		vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY);
    403 		if (error != 0)
    404 			goto error;
    405 		*vpp = tdp;
    406 #if 0
    407 	} else if (dp->h_rec.u.cnid == rec.file.u.cnid) {
    408 #endif
    409 	} else if (cnp->cn_namelen == 1 && pname[0] == '.') {
    410 		DPRINTF(("DOT "));
    411 		vref(vdp);	/* we want ourself, ie "." */
    412 		*vpp = vdp;
    413 	} else {
    414 		hfs_callback_args cbargs;
    415 		uint8_t len, ni;
    416 
    417 		hfslib_init_cbargs(&cbargs);
    418 
    419 		/* XXX: when decomposing, string could grow
    420 		   and we have to handle overflow */
    421 		unicn = malloc(cnp->cn_namelen * sizeof(unicn[0]),
    422 		    M_TEMP, M_WAITOK);
    423 		len = utf8_to_utf16(unicn, cnp->cn_namelen,
    424 		    cnp->cn_nameptr, cnp->cn_namelen, 0, NULL);
    425 		for (ni = 0; ni < len; ni++)
    426 			if (unicn[ni] == (unichar_t)':')
    427 				unicn[ni] = (unichar_t)'/';
    428 		/* XXX: check conversion errors? */
    429 		if (hfslib_make_catalog_key(VTOH(vdp)->h_rec.u.cnid, len, unicn,
    430 		    &key) == 0) {
    431 			DPRINTF(("ERROR in hfslib_make_catalog_key\n"));
    432 			error = EINVAL;
    433 			goto error;
    434 		}
    435 
    436 		result = hfslib_find_catalog_record_with_key(&dp->h_hmp->hm_vol,
    437 		    &key, &rec, &cbargs);
    438 		if (result > 0) {
    439 			error = EINVAL;
    440 			goto error;
    441 		}
    442 		if (result < 0) {
    443 			if (cnp->cn_nameiop == CREATE)
    444 				error = EROFS;
    445 			else
    446 				error = ENOENT;
    447 			goto error;
    448 		}
    449 
    450 		if (rec.file.user_info.file_type == HFS_HARD_LINK_FILE_TYPE
    451 		    && rec.file.user_info.file_creator == HFS_HFSLUS_CREATOR) {
    452 			if (hfslib_get_hardlink(&dp->h_hmp->hm_vol,
    453 			    rec.file.bsd.special.inode_num,
    454 			    &rec, &cbargs) != 0) {
    455 				error = EINVAL;
    456 				goto error;
    457 			}
    458 		}
    459 
    460 		if (rec.type == HFS_REC_FILE
    461 		    && strcmp(cnp->cn_nameptr+cnp->cn_namelen, "/rsrc") == 0
    462 		    && rec.file.rsrc_fork.logical_size > 0) {
    463 		    /* advance namei next pointer to end of stirng */
    464 		    cnp->cn_consume = 5;
    465 		    cnp->cn_flags &= ~REQUIREDIR; /* XXX: needed? */
    466 		    error = hfs_vget_internal(vdp->v_mount, rec.file.cnid,
    467 			HFS_RSRCFORK, &tdp);
    468 		}
    469 		else
    470 			error = VFS_VGET(vdp->v_mount, rec.file.cnid, &tdp);
    471 		if (error != 0)
    472 			goto error;
    473 		*vpp = tdp;
    474 	}
    475 	DPRINTF(("\n"));
    476 	/*
    477 	 * Insert name into cache if appropriate.
    478 	 */
    479 /* XXX Cache disabled until we can make sure it works. */
    480 #if 0
    481 	cache_enter(vdp, *vpp, cnp);
    482 #endif
    483 
    484 	if (*vpp != vdp)
    485 		VOP_UNLOCK(*vpp);
    486 	error = 0;
    487 
    488 	/* FALLTHROUGH */
    489 error:
    490 	if (unicn != NULL)
    491 		free(unicn, M_TEMP);
    492 
    493 	return error;
    494 }
    495 
    496 int
    497 hfs_vop_open(void *v)
    498 {
    499 #if 0
    500 	struct vop_open_args /* {
    501 		struct vnode *a_vp;
    502 		int a_mode;
    503 		kauth_cred_t a_cred;
    504 	} */ *ap = v;
    505 	struct hfsnode *hn = VTOH(ap->a_vp);
    506 #endif
    507 	DPRINTF(("VOP = hfs_vop_open()\n"));
    508 
    509 	/*
    510 	 * XXX This is a good place to read and cache the file's extents to
    511 	 * XXX avoid doing it upon every read/write. Must however keep the
    512 	 * XXX cache in sync when the file grows/shrinks. (So would that go
    513 	 * XXX in vop_truncate?)
    514 	 */
    515 
    516 	return 0;
    517 }
    518 
    519 int
    520 hfs_vop_close(void *v)
    521 {
    522 #if 0
    523 	struct vop_close_args /* {
    524 		struct vnode *a_vp;
    525 		int a_fflag;
    526 		kauth_cred_t a_cred;
    527 	} */ *ap = v;
    528 	struct hfsnode *hn = VTOH(ap->a_vp);
    529 #endif
    530 	DPRINTF(("VOP = hfs_vop_close()\n"));
    531 
    532 	/* Release extents cache here. */
    533 
    534 	return 0;
    535 }
    536 
    537 static int
    538 hfs_check_possible(struct vnode *vp, mode_t mode)
    539 {
    540 
    541 	/*
    542 	 * Disallow writes on files, directories, and symlinks
    543 	 * since we have no write support yet.
    544 	 */
    545 
    546 	if (mode & VWRITE) {
    547 		switch (vp->v_type) {
    548 		case VDIR:
    549 		case VLNK:
    550 		case VREG:
    551 			return EROFS;
    552 		default:
    553 			break;
    554 		}
    555 	}
    556 
    557 	return 0;
    558 }
    559 
    560 static int
    561 hfs_check_permitted(vnode_t *vp, struct vattr *va, mode_t mode,
    562     kauth_cred_t cred)
    563 {
    564 
    565 	return kauth_authorize_vnode(cred, KAUTH_ACCESS_ACTION(mode,
    566 	    va->va_type, va->va_mode), vp, NULL,  genfs_can_access(va->va_type,
    567 	    va->va_mode, va->va_uid, va->va_gid, mode, cred));
    568 }
    569 
    570 int
    571 hfs_vop_access(void *v)
    572 {
    573 	struct vop_access_args /* {
    574 		struct vnode *a_vp;
    575 		int a_mode;
    576 		kauth_cred_t a_cred;
    577 	} */ *ap = v;
    578 	struct vattr va;
    579 	int error;
    580 
    581 	DPRINTF(("VOP = hfs_vop_access()\n"));
    582 
    583 	error = hfs_check_possible(ap->a_vp, ap->a_mode);
    584 	if (error)
    585 		return error;
    586 
    587 	if ((error = VOP_GETATTR(ap->a_vp, &va, ap->a_cred)) != 0)
    588 		return error;
    589 
    590 	error = hfs_check_permitted(ap->a_vp, &va, ap->a_mode, ap->a_cred);
    591 
    592 	return error;
    593 }
    594 
    595 int
    596 hfs_vop_getattr(void *v)
    597 {
    598 	struct vop_getattr_args /* {
    599 		struct vnode	*a_vp;
    600 		struct vattr	*a_vap;
    601 		struct ucred	*a_cred;
    602 	} */ *ap = v;
    603 	struct vnode	*vp;
    604 	struct hfsnode	*hp;
    605 	struct vattr	*vap;
    606 	hfs_bsd_data_t *bsd;
    607 	hfs_fork_t     *fork;
    608 
    609 	DPRINTF(("VOP = hfs_vop_getattr()\n"));
    610 
    611 	vp = ap->a_vp;
    612 	hp = VTOH(vp);
    613 	vap = ap->a_vap;
    614 
    615 	vattr_null(vap);
    616 
    617 	/*
    618 	 * XXX Cannot trust permissions/modes/flags stored in an HFS+ catalog
    619 	 * XXX record those values are not set on files created under Mac OS 9.
    620 	 */
    621 	vap->va_type = ap->a_vp->v_type;
    622 	if (hp->h_rec.u.rec_type == HFS_REC_FILE) {
    623 		hfs_file_record_t *f = &hp->h_rec.file;
    624 		if (hp->h_fork == HFS_RSRCFORK)
    625 			fork = &f->rsrc_fork;
    626 		else
    627 			fork = &f->data_fork;
    628 		vap->va_fileid = f->cnid;
    629 		bsd = &f->bsd;
    630 		vap->va_bytes = fork->total_blocks * HFS_BLOCKSIZE(vp);
    631 		vap->va_size = fork->logical_size;
    632 		hfs_time_to_timespec(f->date_created, &vap->va_ctime);
    633 		hfs_time_to_timespec(f->date_content_mod, &vap->va_mtime);
    634 		hfs_time_to_timespec(f->date_accessed, &vap->va_atime);
    635 		vap->va_nlink = 1;
    636 	}
    637 	else if (hp->h_rec.u.rec_type == HFS_REC_FLDR) {
    638 		hfs_folder_record_t *f = &hp->h_rec.folder;
    639 		vap->va_fileid = hp->h_rec.folder.cnid;
    640 		bsd = &f->bsd;
    641 		vap->va_size = 512; /* XXX Temporary */
    642 		vap->va_bytes = 512; /* XXX Temporary */
    643 		hfs_time_to_timespec(f->date_created, &vap->va_ctime);
    644 		hfs_time_to_timespec(f->date_content_mod,&vap->va_mtime);
    645 		hfs_time_to_timespec(f->date_accessed, &vap->va_atime);
    646 		vap->va_nlink = 2; /* XXX */
    647 	}
    648 	else {
    649 		DPRINTF(("hfs+: hfs_vop_getattr(): invalid record type %i",
    650 		    hp->h_rec.u.rec_type));
    651 		return EINVAL;
    652 	}
    653 
    654 	if ((bsd->file_mode & S_IFMT) == 0) {
    655 		/* no bsd permissions recorded, use default values */
    656 		if (hp->h_rec.u.rec_type == HFS_REC_FILE)
    657 			vap->va_mode = (S_IFREG | HFS_DEFAULT_FILE_MODE);
    658 		else
    659 			vap->va_mode = (S_IFDIR | HFS_DEFAULT_DIR_MODE);
    660 		vap->va_uid = HFS_DEFAULT_UID;
    661 		vap->va_gid = HFS_DEFAULT_GID;
    662 	}
    663 	else {
    664 		vap->va_mode = bsd->file_mode;
    665 		vap->va_uid = bsd->owner_id;
    666 		vap->va_gid = bsd->group_id;
    667 		if ((vap->va_mode & S_IFMT) == S_IFCHR
    668 		    || (vap->va_mode & S_IFMT) == S_IFBLK) {
    669 			vap->va_rdev
    670 			    = HFS_CONVERT_RDEV(bsd->special.raw_device);
    671 		}
    672 		else if (bsd->special.link_count != 0) {
    673 		    /* XXX: only if in metadata directory */
    674 		    vap->va_nlink = bsd->special.link_count;
    675 		}
    676 	}
    677 
    678 	vap->va_fsid = hp->h_dev;
    679 	vap->va_blocksize = hp->h_hmp->hm_vol.vh.block_size;
    680 	vap->va_gen = 1;
    681 	vap->va_flags = 0;
    682 
    683 	return 0;
    684 }
    685 
    686 int
    687 hfs_vop_setattr(void *v)
    688 {
    689 	struct vop_setattr_args /* {
    690 		struct vnode	*a_vp;
    691 		struct vattr	*a_vap;
    692 		kauth_cred_t	a_cred;
    693 	} */ *ap = v;
    694 	struct vattr	*vap;
    695 	struct vnode	*vp;
    696 
    697 	vap = ap->a_vap;
    698 	vp = ap->a_vp;
    699 
    700 	/*
    701 	 * Check for unsettable attributes.
    702 	 */
    703 	if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||
    704 	    (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
    705 	    (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
    706 	    ((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
    707 		return EINVAL;
    708 	}
    709 
    710 	/* XXX: needs revisiting for write support */
    711 	if (vap->va_flags != VNOVAL
    712 	    || vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL
    713 	    || vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL
    714 	    || vap->va_birthtime.tv_sec != VNOVAL) {
    715 		return EROFS;
    716 	}
    717 
    718 	if (vap->va_size != VNOVAL) {
    719 		/*
    720 		 * Disallow write attempts on read-only file systems;
    721 		 * unless the file is a socket, fifo, or a block or
    722 		 * character device resident on the file system.
    723 		 */
    724 		switch (vp->v_type) {
    725 		case VDIR:
    726 			return EISDIR;
    727 		case VCHR:
    728 		case VBLK:
    729 		case VFIFO:
    730 			break;
    731 		case VREG:
    732 			return EROFS;
    733 		default:
    734 			return EOPNOTSUPP;
    735 		}
    736 	}
    737 
    738 	return 0;
    739 }
    740 
    741 int
    742 hfs_vop_bmap(void *v)
    743 {
    744 	struct vop_bmap_args /* {
    745 		struct vnode *a_vp;
    746 		daddr_t  a_bn;
    747 		struct vnode **a_vpp;
    748 		daddr_t *a_bnp;
    749 		int *a_runp;
    750 	} */ *ap = v;
    751 	struct vnode *vp;
    752 	struct hfsnode *hp;
    753 	daddr_t lblkno;
    754 	hfs_callback_args cbargs;
    755 	hfs_libcb_argsread argsread;
    756 	hfs_extent_descriptor_t *extents;
    757 	uint16_t numextents, i;
    758 	int bshift;
    759 
    760 	vp = ap->a_vp;
    761 	hp = VTOH(vp);
    762 	lblkno = ap->a_bn;
    763 	bshift = vp->v_mount->mnt_fs_bshift;
    764 
    765 	/*
    766 	 * Check for underlying vnode requests and ensure that logical
    767 	 * to physical mapping is requested.
    768 	 */
    769 	if (ap->a_vpp != NULL)
    770 		*ap->a_vpp = hp->h_devvp;
    771 	if (ap->a_bnp == NULL)
    772 		return 0;
    773 
    774 	hfslib_init_cbargs(&cbargs);
    775 	argsread.cred = NULL;
    776 	argsread.l = NULL;
    777 	cbargs.read = &argsread;
    778 
    779 	numextents = hfslib_get_file_extents(&hp->h_hmp->hm_vol,
    780 	    hp->h_rec.u.cnid, hp->h_fork, &extents, &cbargs);
    781 
    782 	/* XXX: is this correct for 0-length files? */
    783 	if (numextents == 0)
    784 		return EBADF;
    785 
    786 	for (i = 0; i < numextents; i++) {
    787 		if (lblkno < extents[i].block_count)
    788 			break;
    789 		lblkno -= extents[i].block_count;
    790 	}
    791 
    792 	if (i == numextents) {
    793 		/* XXX: block number past EOF */
    794 		i--;
    795 		lblkno += extents[i].block_count;
    796 	}
    797 
    798 	*ap->a_bnp = ((extents[i].start_block + lblkno) << (bshift-DEV_BSHIFT))
    799 	    + (hp->h_hmp->hm_vol.offset >> DEV_BSHIFT);
    800 
    801 	if (ap->a_runp) {
    802 		int nblk;
    803 
    804 		nblk = extents[i].block_count - lblkno - 1;
    805 		if (nblk <= 0)
    806 			*ap->a_runp = 0;
    807 		else if (nblk > MAXBSIZE >> bshift)
    808 			*ap->a_runp = (MAXBSIZE >> bshift) - 1;
    809 		else
    810 			*ap->a_runp = nblk;
    811 
    812 	}
    813 
    814 	free(extents, M_TEMP);
    815 
    816 	return 0;
    817 }
    818 
    819 int
    820 hfs_vop_read(void *v)
    821 {
    822 	struct vop_read_args /* {
    823 		struct vnode *a_vp;
    824 		struct uio *a_uio;
    825 		int a_ioflag;
    826 		kauth_cred_t a_cred;
    827 	} */ *ap = v;
    828 	struct vnode *vp;
    829 	struct hfsnode *hp;
    830 	struct uio *uio;
    831 	uint64_t fsize; /* logical size of file */
    832 	int advice;
    833         int error;
    834 
    835 	vp = ap->a_vp;
    836 	hp = VTOH(vp);
    837 	uio = ap->a_uio;
    838 	if (hp->h_fork == HFS_RSRCFORK)
    839 		fsize = hp->h_rec.file.rsrc_fork.logical_size;
    840 	else
    841 		fsize = hp->h_rec.file.data_fork.logical_size;
    842 	error = 0;
    843 	advice = IO_ADV_DECODE(ap->a_ioflag);
    844 
    845         if (uio->uio_offset < 0)
    846                 return EINVAL;
    847 
    848         if (uio->uio_resid == 0 || uio->uio_offset >= fsize)
    849                 return 0;
    850 
    851         if (vp->v_type != VREG && vp->v_type != VLNK)
    852 		return EINVAL;
    853 
    854 	error = 0;
    855 	while (uio->uio_resid > 0 && error == 0) {
    856 		vsize_t len;
    857 
    858 		len = MIN(uio->uio_resid, fsize - uio->uio_offset);
    859 		if (len == 0)
    860 			break;
    861 
    862 		error = ubc_uiomove(&vp->v_uobj, uio, len, advice,
    863 		    UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
    864 	}
    865 
    866         return error;
    867 }
    868 
    869 int
    870 hfs_vop_readdir(void *v)
    871 {
    872 struct vop_readdir_args /* {
    873 		struct vnode *a_vp;
    874 		struct uio *a_uio;
    875 		kauth_cred_t a_cred;
    876 		int *a_eofflag;
    877 		off_t **a_cookies;
    878 		int a_*ncookies;
    879 	} */ *ap = v;
    880 
    881 	DPRINTF(("VOP = hfs_vop_readdir()\n"));
    882 
    883 	struct dirent curent; /* the dirent entry we are constructing */
    884 	struct hfsnode *hp;
    885 	hfs_catalog_keyed_record_t *children;
    886 	hfs_unistr255_t *childnames;
    887 	hfs_callback_args cbargs;
    888 	hfs_libcb_argsread argsread;
    889 	struct uio *uio;
    890 	off_t bufoff; /* offset in buffer relative to start of dirents */
    891 	uint32_t numchildren;
    892 	uint32_t curchild; /* index of child we are stuffing into dirent */
    893 	size_t namlen, ni;
    894 	int error;
    895 	int i; /* dummy variable */
    896 
    897 	bufoff = 0;
    898 	children = NULL;
    899 	error = 0;
    900 	numchildren = 0;
    901 	hp = VTOH(ap->a_vp);
    902 	uio = ap->a_uio;
    903 
    904 	if (uio->uio_offset < 0)
    905 		return EINVAL;
    906 	if (ap->a_eofflag != NULL)
    907 		*ap->a_eofflag = 0;
    908 
    909 /* XXX Inform that we don't support NFS, for now. */
    910 #if 0
    911 	if(ap->a_eofflag != NULL || ap->a_cookies != NULL ||
    912 	    ap->a_ncookies != NULL)
    913 		return EOPNOTSUPP;
    914 #endif
    915 	DPRINTF(("READDIR uio: offset=%td, resid=%zu\n",
    916 	    uio->uio_offset, uio->uio_resid));
    917 	hfslib_init_cbargs(&cbargs);
    918 	argsread.cred = ap->a_cred;
    919 	argsread.l = NULL;
    920 	cbargs.read = &argsread;
    921 
    922 	/* XXX Should we cache this? */
    923 	if (hfslib_get_directory_contents(&hp->h_hmp->hm_vol, hp->h_rec.u.cnid,
    924 	    &children, &childnames, &numchildren, &cbargs) != 0) {
    925 		DPRINTF(("ENOENT\n"));
    926 		error = ENOENT;
    927 		goto error;
    928 	}
    929 
    930 	DPRINTF(("numchildren = %u\n", numchildren));
    931 	for (curchild = 0; curchild < numchildren && uio->uio_resid > 0;
    932 	    curchild++) {
    933 		namlen = utf16_to_utf8(curent.d_name, NAME_MAX,
    934 		    childnames[curchild].unicode, childnames[curchild].length,
    935 		    0, NULL);
    936 		/* XXX: check conversion errors? */
    937 		if (namlen > NAME_MAX) {
    938 			/* XXX: how to handle name too long? */
    939 			continue;
    940 		}
    941 		for (ni = 0; ni < namlen; ni++)
    942 			if (curent.d_name[ni] == '/')
    943 				curent.d_name[ni] = ':';
    944 		curent.d_namlen = namlen;
    945 		curent.d_reclen = _DIRENT_SIZE(&curent);
    946 
    947 		/* Skip to desired dirent. */
    948 		bufoff += curent.d_reclen;
    949 		if (bufoff - curent.d_reclen < uio->uio_offset)
    950 			continue;
    951 
    952 		/* Make sure we don't return partial entries. */
    953 		if (uio->uio_resid < curent.d_reclen) {
    954 			DPRINTF(("PARTIAL ENTRY\n"));
    955 			if (ap->a_eofflag != NULL)
    956 				*ap->a_eofflag = 1;
    957 			break;
    958 		}
    959 
    960 		curent.d_fileno = children[curchild].file.cnid;
    961 		switch (hfs_catalog_keyed_record_vtype(children+curchild)) {
    962 		case VREG:
    963 			curent.d_type = DT_REG;
    964 			break;
    965 		case VDIR:
    966 			curent.d_type = DT_DIR;
    967 			break;
    968 		case VBLK:
    969 			curent.d_type = DT_BLK;
    970 			break;
    971 		case VCHR:
    972 			curent.d_type = DT_CHR;
    973 			break;
    974 		case VLNK:
    975 			curent.d_type = DT_LNK;
    976 			break;
    977 		case VSOCK:
    978 			curent.d_type = DT_SOCK;
    979 			break;
    980 		case VFIFO:
    981 			curent.d_type = DT_FIFO;
    982 			break;
    983 		default:
    984 			curent.d_type = DT_UNKNOWN;
    985 			break;
    986 		}
    987 		DPRINTF(("curchildname = %s\t\t", curchildname));
    988 		/* pad curent.d_name to aligned byte boundary */
    989                 for (i = curent.d_namlen;
    990                      i < curent.d_reclen - _DIRENT_NAMEOFF(&curent); i++)
    991                         curent.d_name[i] = 0;
    992 
    993 		DPRINTF(("curent.d_name = %s\n", curent.d_name));
    994 
    995 		if ((error = uiomove(&curent, curent.d_reclen, uio)) != 0)
    996 			goto error;
    997 	}
    998 
    999 
   1000 	/* FALLTHROUGH */
   1001 
   1002 error:
   1003 	if (numchildren > 0) {
   1004 		if (children != NULL)
   1005 			free(children, M_TEMP);
   1006 		if (childnames != NULL)
   1007 			free(childnames, M_TEMP);
   1008 	}
   1009 
   1010 	if (error) {
   1011 		DPRINTF(("ERROR = %i\n", error));
   1012 	}
   1013 
   1014 	return error;
   1015 }
   1016 
   1017 int
   1018 hfs_vop_readlink(void *v) {
   1019 	struct vop_readlink_args /* {
   1020 		struct vnode *a_vp;
   1021         	struct uio *a_uio;
   1022         	kauth_cred_t a_cred;
   1023 	} */ *ap = v;
   1024 
   1025 	return VOP_READ(ap->a_vp, ap->a_uio, 0, ap->a_cred);
   1026 }
   1027 
   1028 int
   1029 hfs_vop_reclaim(void *v)
   1030 {
   1031 	struct vop_reclaim_args /* {
   1032 		struct vnode *a_vp;
   1033 	} */ *ap = v;
   1034 	struct vnode *vp;
   1035 	struct hfsnode *hp;
   1036 
   1037 	DPRINTF(("VOP = hfs_vop_reclaim()\n"));
   1038 
   1039 	vp = ap->a_vp;
   1040 	hp = VTOH(vp);
   1041 
   1042 	/* Remove the hfsnode from its hash chain. */
   1043 	hfs_nhashremove(hp);
   1044 
   1045 	/* Decrement the reference count to the volume's device. */
   1046 	if (hp->h_devvp) {
   1047 		vrele(hp->h_devvp);
   1048 		hp->h_devvp = 0;
   1049 	}
   1050 
   1051 	genfs_node_destroy(vp);
   1052 	free(vp->v_data, M_TEMP);
   1053 	vp->v_data = NULL;
   1054 
   1055 	return 0;
   1056 }
   1057 
   1058 int
   1059 hfs_vop_print(void *v)
   1060 {
   1061 	struct vop_print_args /* {
   1062 		struct vnode	*a_vp;
   1063 	} */ *ap = v;
   1064 	struct vnode	*vp;
   1065 	struct hfsnode	*hp;
   1066 
   1067 	DPRINTF(("VOP = hfs_vop_print()\n"));
   1068 
   1069 	vp = ap->a_vp;
   1070 	hp = VTOH(vp);
   1071 
   1072 	printf("dummy = %X\n", (unsigned)hp->dummy);
   1073 	printf("\n");
   1074 
   1075 	return 0;
   1076 }
   1077