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