Home | History | Annotate | Line # | Download | only in hfs
hfs.h revision 1.5.4.2
      1  1.5.4.2  pooka /*	$NetBSD: hfs.h,v 1.5.4.2 2007/07/31 21:14:18 pooka Exp $	*/
      2  1.5.4.2  pooka 
      3  1.5.4.2  pooka /*-
      4  1.5.4.2  pooka  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
      5  1.5.4.2  pooka  * All rights reserved.
      6  1.5.4.2  pooka  *
      7  1.5.4.2  pooka  * This code is derived from software contributed to The NetBSD Foundation
      8  1.5.4.2  pooka  * by Yevgeny Binder and Dieter Baron.
      9  1.5.4.2  pooka  *
     10  1.5.4.2  pooka  * Redistribution and use in source and binary forms, with or without
     11  1.5.4.2  pooka  * modification, are permitted provided that the following conditions
     12  1.5.4.2  pooka  * are met:
     13  1.5.4.2  pooka  * 1. Redistributions of source code must retain the above copyright
     14  1.5.4.2  pooka  *    notice, this list of conditions and the following disclaimer.
     15  1.5.4.2  pooka  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.5.4.2  pooka  *    notice, this list of conditions and the following disclaimer in the
     17  1.5.4.2  pooka  *    documentation and/or other materials provided with the distribution.
     18  1.5.4.2  pooka  *
     19  1.5.4.2  pooka  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.5.4.2  pooka  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.5.4.2  pooka  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.5.4.2  pooka  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.5.4.2  pooka  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.5.4.2  pooka  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.5.4.2  pooka  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.5.4.2  pooka  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.5.4.2  pooka  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.5.4.2  pooka  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.5.4.2  pooka  * POSSIBILITY OF SUCH DAMAGE.
     30  1.5.4.2  pooka  */
     31  1.5.4.2  pooka 
     32  1.5.4.2  pooka #ifndef _FS_HFS_HFS_H_
     33  1.5.4.2  pooka #define _FS_HFS_HFS_H_
     34  1.5.4.2  pooka 
     35  1.5.4.2  pooka #include <sys/vnode.h>
     36  1.5.4.2  pooka #include <sys/mount.h>
     37  1.5.4.2  pooka 
     38  1.5.4.2  pooka #include <miscfs/genfs/genfs_node.h>
     39  1.5.4.2  pooka 
     40  1.5.4.2  pooka /* XXX remove before release */
     41  1.5.4.2  pooka /*#define HFS_DEBUG*/
     42  1.5.4.2  pooka 
     43  1.5.4.2  pooka #ifdef HFS_DEBUG
     44  1.5.4.2  pooka 	#if defined(_KERNEL) && !defined(_LKM)
     45  1.5.4.2  pooka 		#include "opt_ddb.h"
     46  1.5.4.2  pooka 	#endif /* defined(_KERNEL_) && !defined(_LKM) */
     47  1.5.4.2  pooka #endif /* HFS_DEBUG */
     48  1.5.4.2  pooka 
     49  1.5.4.2  pooka #include <fs/hfs/libhfs.h>
     50  1.5.4.2  pooka 
     51  1.5.4.2  pooka /* XXX: make these mount options */
     52  1.5.4.2  pooka #define HFS_DEFAULT_UID	0
     53  1.5.4.2  pooka #define HFS_DEFAULT_GID	0
     54  1.5.4.2  pooka #define HFS_DEFAULT_DIR_MODE	0755
     55  1.5.4.2  pooka #define HFS_DEFAULT_FILE_MODE	0755
     56  1.5.4.2  pooka 
     57  1.5.4.2  pooka MALLOC_DECLARE(M_HFSMNT);	/* defined in hfs_vfsops.c */
     58  1.5.4.2  pooka 
     59  1.5.4.2  pooka struct hfs_args {
     60  1.5.4.2  pooka 	char *fspec;		/* block special device to mount */
     61  1.5.4.2  pooka };
     62  1.5.4.2  pooka 
     63  1.5.4.2  pooka struct hfsmount {
     64  1.5.4.2  pooka 	struct mount *hm_mountp;	/* filesystem vfs structure */
     65  1.5.4.2  pooka 	dev_t hm_dev;				/* device mounted */
     66  1.5.4.2  pooka 	struct vnode *hm_devvp;		/* block device mounted vnode */
     67  1.5.4.2  pooka 	hfs_volume hm_vol;			/* essential volume information */
     68  1.5.4.2  pooka };
     69  1.5.4.2  pooka 
     70  1.5.4.2  pooka struct hfsnode {
     71  1.5.4.2  pooka 	struct genfs_node h_gnode;
     72  1.5.4.2  pooka 	LIST_ENTRY(hfsnode) h_hash;/* hash chain */
     73  1.5.4.2  pooka 	struct vnode *h_vnode;		/* vnode associated with this hnode */
     74  1.5.4.2  pooka 	struct hfsmount *h_hmp;	/* mount point associated with this hnode */
     75  1.5.4.2  pooka 	struct vnode *h_devvp;		/* vnode for block I/O */
     76  1.5.4.2  pooka 	dev_t	h_dev;				/* device associated with this hnode */
     77  1.5.4.2  pooka 
     78  1.5.4.2  pooka 	union {
     79  1.5.4.2  pooka 		hfs_file_record_t		file;
     80  1.5.4.2  pooka 		hfs_folder_record_t	folder;
     81  1.5.4.2  pooka 		struct {
     82  1.5.4.2  pooka 			int16_t			rec_type;
     83  1.5.4.2  pooka 			uint16_t		flags;
     84  1.5.4.2  pooka 			uint32_t		valence;
     85  1.5.4.2  pooka 			hfs_cnid_t		cnid;
     86  1.5.4.2  pooka 		}; /* convenience for accessing common record info */
     87  1.5.4.2  pooka 	} h_rec; /* catalog record for this hnode */
     88  1.5.4.2  pooka 
     89  1.5.4.2  pooka 	/*
     90  1.5.4.2  pooka 	 * We cache this vnode's parent CNID here upon vnode creation (i.e., during
     91  1.5.4.2  pooka 	 * hfs_vop_vget()) for quick access without needing to search the catalog.
     92  1.5.4.2  pooka 	 * Note, however, that this value must also be updated whenever this file
     93  1.5.4.2  pooka 	 * is moved.
     94  1.5.4.2  pooka 	 */
     95  1.5.4.2  pooka 	hfs_cnid_t		h_parent;
     96  1.5.4.2  pooka 
     97  1.5.4.2  pooka 	uint8_t h_fork;
     98  1.5.4.2  pooka 
     99  1.5.4.2  pooka 	long	dummy;	/* FOR DEVELOPMENT ONLY */
    100  1.5.4.2  pooka };
    101  1.5.4.2  pooka 
    102  1.5.4.2  pooka typedef struct {
    103  1.5.4.2  pooka 	struct vnode* devvp; /* vnode for device I/O */
    104  1.5.4.2  pooka 	size_t devblksz; /* device block size (NOT HFS+ allocation block size)*/
    105  1.5.4.2  pooka } hfs_libcb_data; /* custom data used in hfs_volume.cbdata */
    106  1.5.4.2  pooka 
    107  1.5.4.2  pooka typedef struct {
    108  1.5.4.2  pooka 	kauth_cred_t cred;
    109  1.5.4.2  pooka 	struct lwp *l;
    110  1.5.4.2  pooka 	struct vnode *devvp;
    111  1.5.4.2  pooka } hfs_libcb_argsopen;
    112  1.5.4.2  pooka 
    113  1.5.4.2  pooka typedef struct {
    114  1.5.4.2  pooka 	struct lwp *l;
    115  1.5.4.2  pooka } hfs_libcb_argsclose;
    116  1.5.4.2  pooka 
    117  1.5.4.2  pooka typedef struct {
    118  1.5.4.2  pooka 	kauth_cred_t cred;
    119  1.5.4.2  pooka 	struct lwp *l;
    120  1.5.4.2  pooka } hfs_libcb_argsread;
    121  1.5.4.2  pooka 
    122  1.5.4.2  pooka /*
    123  1.5.4.2  pooka  * Convenience macros
    124  1.5.4.2  pooka  */
    125  1.5.4.2  pooka 
    126  1.5.4.2  pooka /* Convert mount ptr to hfsmount ptr. */
    127  1.5.4.2  pooka #define VFSTOHFS(mp)    ((struct hfsmount *)((mp)->mnt_data))
    128  1.5.4.2  pooka 
    129  1.5.4.2  pooka /* Convert between vnode ptrs and hfsnode ptrs. */
    130  1.5.4.2  pooka #define VTOH(vp)    ((struct hfsnode *)(vp)->v_data)
    131  1.5.4.2  pooka #define	HTOV(hp)	((hp)->h_vnode)
    132  1.5.4.2  pooka 
    133  1.5.4.2  pooka /* Get volume's allocation block size given a vnode ptr */
    134  1.5.4.2  pooka #define HFS_BLOCKSIZE(vp)    (VTOH(vp)->h_hmp->hm_vol.vh.block_size)
    135  1.5.4.2  pooka 
    136  1.5.4.2  pooka 
    137  1.5.4.2  pooka /* Convert special device major/minor */
    138  1.5.4.2  pooka #define HFS_CONVERT_RDEV(x)	makedev((x)>>24, (x)&0xffffff)
    139  1.5.4.2  pooka 
    140  1.5.4.2  pooka /*
    141  1.5.4.2  pooka  * Global variables
    142  1.5.4.2  pooka  */
    143  1.5.4.2  pooka 
    144  1.5.4.2  pooka extern const struct vnodeopv_desc hfs_vnodeop_opv_desc;
    145  1.5.4.2  pooka extern const struct vnodeopv_desc hfs_specop_opv_desc;
    146  1.5.4.2  pooka extern const struct vnodeopv_desc hfs_fifoop_opv_desc;
    147  1.5.4.2  pooka extern int (**hfs_specop_p) (void *);
    148  1.5.4.2  pooka extern int (**hfs_fifoop_p) (void *);
    149  1.5.4.2  pooka 
    150  1.5.4.2  pooka 
    151  1.5.4.2  pooka /*
    152  1.5.4.2  pooka  * Function prototypes
    153  1.5.4.2  pooka  */
    154  1.5.4.2  pooka 
    155  1.5.4.2  pooka /* hfs_nhash.c */
    156  1.5.4.2  pooka void hfs_nhashinit (void);
    157  1.5.4.2  pooka void hfs_nhashdone (void);
    158  1.5.4.2  pooka struct vnode *hfs_nhashget (dev_t, hfs_cnid_t, uint8_t, int);
    159  1.5.4.2  pooka void hfs_nhashinsert (struct hfsnode *);
    160  1.5.4.2  pooka void hfs_nhashremove (struct hfsnode *);
    161  1.5.4.2  pooka 
    162  1.5.4.2  pooka /* hfs_subr.c */
    163  1.5.4.2  pooka void hfs_vinit (struct mount *, int (**)(void *), int (**)(void *),
    164  1.5.4.2  pooka 		 struct vnode **);
    165  1.5.4.2  pooka int hfs_pread(struct vnode*, void*, size_t, uint64_t, uint64_t, kauth_cred_t);
    166  1.5.4.2  pooka char* hfs_unicode_to_ascii(const unichar_t*, uint8_t, char*);
    167  1.5.4.2  pooka unichar_t* hfs_ascii_to_unicode(const char*, uint8_t, unichar_t*);
    168  1.5.4.2  pooka 
    169  1.5.4.2  pooka void hfs_time_to_timespec(uint32_t, struct timespec *);
    170  1.5.4.2  pooka enum vtype hfs_catalog_keyed_record_vtype(const hfs_catalog_keyed_record_t *);
    171  1.5.4.2  pooka 
    172  1.5.4.2  pooka void hfs_libcb_error(const char*, const char*, int, va_list);
    173  1.5.4.2  pooka void* hfs_libcb_malloc(size_t, hfs_callback_args*);
    174  1.5.4.2  pooka void* hfs_libcb_realloc(void*, size_t, hfs_callback_args*);
    175  1.5.4.2  pooka void hfs_libcb_free(void*, hfs_callback_args*);
    176  1.5.4.2  pooka int hfs_libcb_opendev(hfs_volume*, const char*, hfs_callback_args*);
    177  1.5.4.2  pooka void hfs_libcb_closedev(hfs_volume*, hfs_callback_args*);
    178  1.5.4.2  pooka int hfs_libcb_read(hfs_volume*, void*, uint64_t, uint64_t,
    179  1.5.4.2  pooka 	hfs_callback_args*);
    180  1.5.4.2  pooka 
    181  1.5.4.2  pooka uint16_t be16tohp(void**);
    182  1.5.4.2  pooka uint32_t be32tohp(void**);
    183  1.5.4.2  pooka uint64_t be64tohp(void**);
    184  1.5.4.2  pooka 
    185  1.5.4.2  pooka 
    186  1.5.4.2  pooka /* hfs_vfsops.c */
    187  1.5.4.2  pooka VFS_PROTOS(hfs);
    188  1.5.4.2  pooka 
    189  1.5.4.2  pooka int hfs_mountfs (struct vnode *, struct mount *, struct lwp *, const char *);
    190  1.5.4.2  pooka int hfs_vget_internal(struct mount *, ino_t, uint8_t, struct vnode **);
    191  1.5.4.2  pooka 
    192  1.5.4.2  pooka /* hfs_vnops.c */
    193  1.5.4.2  pooka extern int (**hfs_vnodeop_p) (void *);
    194  1.5.4.2  pooka 
    195  1.5.4.2  pooka #endif /* !_FS_HFS_HFS_H_ */
    196