Home | History | Annotate | Line # | Download | only in hfs
hfs.h revision 1.2.4.2
      1  1.2.4.2  rmind /*	$NetBSD: hfs.h,v 1.2.4.2 2007/03/12 06:14:52 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 #ifndef _FS_HFS_HFS_H_
     33  1.2.4.2  rmind #define _FS_HFS_HFS_H_
     34  1.2.4.2  rmind 
     35  1.2.4.2  rmind #include <sys/vnode.h>
     36  1.2.4.2  rmind #include <sys/mount.h>
     37  1.2.4.2  rmind 
     38  1.2.4.2  rmind #include <miscfs/genfs/genfs_node.h>
     39  1.2.4.2  rmind 
     40  1.2.4.2  rmind /* XXX remove before release */
     41  1.2.4.2  rmind /*#define HFS_DEBUG*/
     42  1.2.4.2  rmind 
     43  1.2.4.2  rmind #ifdef HFS_DEBUG
     44  1.2.4.2  rmind 	#if defined(_KERNEL) && !defined(_LKM)
     45  1.2.4.2  rmind 		#include "opt_ddb.h"
     46  1.2.4.2  rmind 	#endif /* defined(_KERNEL_) && !defined(_LKM) */
     47  1.2.4.2  rmind #endif /* HFS_DEBUG */
     48  1.2.4.2  rmind 
     49  1.2.4.2  rmind #include <fs/hfs/libhfs.h>
     50  1.2.4.2  rmind 
     51  1.2.4.2  rmind /* XXX: make these mount options */
     52  1.2.4.2  rmind #define HFS_DEFAULT_UID	0
     53  1.2.4.2  rmind #define HFS_DEFAULT_GID	0
     54  1.2.4.2  rmind #define HFS_DEFAULT_DIR_MODE	0755
     55  1.2.4.2  rmind #define HFS_DEFAULT_FILE_MODE	0755
     56  1.2.4.2  rmind 
     57  1.2.4.2  rmind MALLOC_DECLARE(M_HFSMNT);	/* defined in hfs_vfsops.c */
     58  1.2.4.2  rmind 
     59  1.2.4.2  rmind struct hfs_args {
     60  1.2.4.2  rmind 	char *fspec;		/* block special device to mount */
     61  1.2.4.2  rmind 	uint64_t offset; /*number of bytes to start of volume from start of device*/
     62  1.2.4.2  rmind };
     63  1.2.4.2  rmind 
     64  1.2.4.2  rmind struct hfsmount {
     65  1.2.4.2  rmind 	struct mount *hm_mountp;	/* filesystem vfs structure */
     66  1.2.4.2  rmind 	dev_t hm_dev;				/* device mounted */
     67  1.2.4.2  rmind 	struct vnode *hm_devvp;		/* block device mounted vnode */
     68  1.2.4.2  rmind 	hfs_volume hm_vol;			/* essential volume information */
     69  1.2.4.2  rmind 	uint64_t offset;		/* number of device bloks to start of volume from start of device*/
     70  1.2.4.2  rmind };
     71  1.2.4.2  rmind 
     72  1.2.4.2  rmind struct hfsnode {
     73  1.2.4.2  rmind 	struct genfs_node h_gnode;
     74  1.2.4.2  rmind 	LIST_ENTRY(hfsnode) h_hash;/* hash chain */
     75  1.2.4.2  rmind 	struct vnode *h_vnode;		/* vnode associated with this hnode */
     76  1.2.4.2  rmind 	struct hfsmount *h_hmp;	/* mount point associated with this hnode */
     77  1.2.4.2  rmind 	struct vnode *h_devvp;		/* vnode for block I/O */
     78  1.2.4.2  rmind 	dev_t	h_dev;				/* device associated with this hnode */
     79  1.2.4.2  rmind 
     80  1.2.4.2  rmind 	union {
     81  1.2.4.2  rmind 		hfs_file_record_t		file;
     82  1.2.4.2  rmind 		hfs_folder_record_t	folder;
     83  1.2.4.2  rmind 		struct {
     84  1.2.4.2  rmind 			int16_t			rec_type;
     85  1.2.4.2  rmind 			uint16_t		flags;
     86  1.2.4.2  rmind 			uint32_t		valence;
     87  1.2.4.2  rmind 			hfs_cnid_t		cnid;
     88  1.2.4.2  rmind 		}; /* convenience for accessing common record info */
     89  1.2.4.2  rmind 	} h_rec; /* catalog record for this hnode */
     90  1.2.4.2  rmind 
     91  1.2.4.2  rmind 	/*
     92  1.2.4.2  rmind 	 * We cache this vnode's parent CNID here upon vnode creation (i.e., during
     93  1.2.4.2  rmind 	 * hfs_vop_vget()) for quick access without needing to search the catalog.
     94  1.2.4.2  rmind 	 * Note, however, that this value must also be updated whenever this file
     95  1.2.4.2  rmind 	 * is moved.
     96  1.2.4.2  rmind 	 */
     97  1.2.4.2  rmind 	hfs_cnid_t		h_parent;
     98  1.2.4.2  rmind 
     99  1.2.4.2  rmind 	uint8_t h_fork;
    100  1.2.4.2  rmind 
    101  1.2.4.2  rmind 	long	dummy;	/* FOR DEVELOPMENT ONLY */
    102  1.2.4.2  rmind };
    103  1.2.4.2  rmind 
    104  1.2.4.2  rmind typedef struct {
    105  1.2.4.2  rmind 	uint64_t offset; /* offset to start of volume from start of device */
    106  1.2.4.2  rmind 	struct vnode* devvp; /* vnode for device I/O */
    107  1.2.4.2  rmind 	size_t devblksz; /* device block size (NOT HFS+ allocation block size)*/
    108  1.2.4.2  rmind } hfs_libcb_data; /* custom data used in hfs_volume.cbdata */
    109  1.2.4.2  rmind 
    110  1.2.4.2  rmind typedef struct {
    111  1.2.4.2  rmind 	kauth_cred_t cred;
    112  1.2.4.2  rmind 	struct lwp *l;
    113  1.2.4.2  rmind 	struct vnode *devvp;
    114  1.2.4.2  rmind } hfs_libcb_argsopen;
    115  1.2.4.2  rmind 
    116  1.2.4.2  rmind typedef struct {
    117  1.2.4.2  rmind 	struct lwp *l;
    118  1.2.4.2  rmind } hfs_libcb_argsclose;
    119  1.2.4.2  rmind 
    120  1.2.4.2  rmind typedef struct {
    121  1.2.4.2  rmind 	kauth_cred_t cred;
    122  1.2.4.2  rmind 	struct lwp *l;
    123  1.2.4.2  rmind } hfs_libcb_argsread;
    124  1.2.4.2  rmind 
    125  1.2.4.2  rmind /*
    126  1.2.4.2  rmind  * Convenience macros
    127  1.2.4.2  rmind  */
    128  1.2.4.2  rmind 
    129  1.2.4.2  rmind /* Convert mount ptr to hfsmount ptr. */
    130  1.2.4.2  rmind #define VFSTOHFS(mp)    ((struct hfsmount *)((mp)->mnt_data))
    131  1.2.4.2  rmind 
    132  1.2.4.2  rmind /* Convert between vnode ptrs and hfsnode ptrs. */
    133  1.2.4.2  rmind #define VTOH(vp)    ((struct hfsnode *)(vp)->v_data)
    134  1.2.4.2  rmind #define	HTOV(hp)	((hp)->h_vnode)
    135  1.2.4.2  rmind 
    136  1.2.4.2  rmind /* Get volume's allocation block size given a vnode ptr */
    137  1.2.4.2  rmind #define HFS_BLOCKSIZE(vp)    (VTOH(vp)->h_hmp->hm_vol.vh.block_size)
    138  1.2.4.2  rmind 
    139  1.2.4.2  rmind 
    140  1.2.4.2  rmind /* Convert special device major/minor */
    141  1.2.4.2  rmind #define HFS_CONVERT_RDEV(x)	makedev((x)>>24, (x)&0xffffff)
    142  1.2.4.2  rmind 
    143  1.2.4.2  rmind /*
    144  1.2.4.2  rmind  * Global variables
    145  1.2.4.2  rmind  */
    146  1.2.4.2  rmind 
    147  1.2.4.2  rmind extern const struct vnodeopv_desc hfs_vnodeop_opv_desc;
    148  1.2.4.2  rmind extern const struct vnodeopv_desc hfs_specop_opv_desc;
    149  1.2.4.2  rmind extern const struct vnodeopv_desc hfs_fifoop_opv_desc;
    150  1.2.4.2  rmind extern int (**hfs_specop_p) (void *);
    151  1.2.4.2  rmind extern int (**hfs_fifoop_p) (void *);
    152  1.2.4.2  rmind 
    153  1.2.4.2  rmind 
    154  1.2.4.2  rmind /*
    155  1.2.4.2  rmind  * Function prototypes
    156  1.2.4.2  rmind  */
    157  1.2.4.2  rmind 
    158  1.2.4.2  rmind /* hfs_nhash.c */
    159  1.2.4.2  rmind void hfs_nhashinit (void);
    160  1.2.4.2  rmind void hfs_nhashdone (void);
    161  1.2.4.2  rmind struct vnode *hfs_nhashget (dev_t, hfs_cnid_t, uint8_t, int);
    162  1.2.4.2  rmind void hfs_nhashinsert (struct hfsnode *);
    163  1.2.4.2  rmind void hfs_nhashremove (struct hfsnode *);
    164  1.2.4.2  rmind 
    165  1.2.4.2  rmind /* hfs_subr.c */
    166  1.2.4.2  rmind void hfs_vinit (struct mount *, int (**)(void *), int (**)(void *),
    167  1.2.4.2  rmind 		 struct vnode **);
    168  1.2.4.2  rmind int hfs_pread(struct vnode*, void*, size_t, uint64_t, uint64_t, kauth_cred_t);
    169  1.2.4.2  rmind char* hfs_unicode_to_ascii(const unichar_t*, uint8_t, char*);
    170  1.2.4.2  rmind unichar_t* hfs_ascii_to_unicode(const char*, uint8_t, unichar_t*);
    171  1.2.4.2  rmind 
    172  1.2.4.2  rmind void hfs_time_to_timespec(uint32_t, struct timespec *);
    173  1.2.4.2  rmind enum vtype hfs_catalog_keyed_record_vtype(const hfs_catalog_keyed_record_t *);
    174  1.2.4.2  rmind 
    175  1.2.4.2  rmind void hfs_libcb_error(const char*, const char*, int, va_list);
    176  1.2.4.2  rmind void* hfs_libcb_malloc(size_t, hfs_callback_args*);
    177  1.2.4.2  rmind void* hfs_libcb_realloc(void*, size_t, hfs_callback_args*);
    178  1.2.4.2  rmind void hfs_libcb_free(void*, hfs_callback_args*);
    179  1.2.4.2  rmind int hfs_libcb_opendev(hfs_volume*, const char*, uint64_t,hfs_callback_args*);
    180  1.2.4.2  rmind void hfs_libcb_closedev(hfs_volume*, hfs_callback_args*);
    181  1.2.4.2  rmind int hfs_libcb_read(hfs_volume*, void*, uint64_t, uint64_t,
    182  1.2.4.2  rmind 	hfs_callback_args*);
    183  1.2.4.2  rmind 
    184  1.2.4.2  rmind uint16_t be16tohp(void**);
    185  1.2.4.2  rmind uint32_t be32tohp(void**);
    186  1.2.4.2  rmind uint64_t be64tohp(void**);
    187  1.2.4.2  rmind 
    188  1.2.4.2  rmind 
    189  1.2.4.2  rmind /* hfs_vfsops.c */
    190  1.2.4.2  rmind int hfs_mount (struct mount *, const char *, void *, struct nameidata *,
    191  1.2.4.2  rmind 	struct lwp *);
    192  1.2.4.2  rmind int hfs_mountfs (struct vnode *, struct mount *, struct lwp *,
    193  1.2.4.2  rmind 	const char *, uint64_t);
    194  1.2.4.2  rmind int hfs_start (struct mount *, int, struct lwp *);
    195  1.2.4.2  rmind int hfs_unmount (struct mount *, int, struct lwp *);
    196  1.2.4.2  rmind int hfs_root (struct mount *, struct vnode **);
    197  1.2.4.2  rmind int hfs_quotactl (struct mount *, int, uid_t, void *, struct lwp *);
    198  1.2.4.2  rmind int hfs_statvfs (struct mount *, struct statvfs *, struct lwp *);
    199  1.2.4.2  rmind int hfs_sync (struct mount *, int, kauth_cred_t , struct lwp *);
    200  1.2.4.2  rmind int hfs_vget (struct mount *, ino_t, struct vnode **);
    201  1.2.4.2  rmind int hfs_vget_internal(struct mount *, ino_t, uint8_t, struct vnode **);
    202  1.2.4.2  rmind int hfs_fhtovp (struct mount *, struct fid *, struct vnode **);
    203  1.2.4.2  rmind int hfs_vptofh (struct vnode *, struct fid *, size_t *);
    204  1.2.4.2  rmind void hfs_init (void);
    205  1.2.4.2  rmind void hfs_reinit (void);
    206  1.2.4.2  rmind void hfs_done (void);
    207  1.2.4.2  rmind int hfs_mountroot (void);
    208  1.2.4.2  rmind int hfs_extattrctl (struct mount *, int, struct vnode *, int, const char *,
    209  1.2.4.2  rmind 		     struct lwp *);
    210  1.2.4.2  rmind 
    211  1.2.4.2  rmind /* hfs_vnops.c */
    212  1.2.4.2  rmind extern int (**hfs_vnodeop_p) (void *);
    213  1.2.4.2  rmind 
    214  1.2.4.2  rmind #endif /* !_FS_HFS_HFS_H_ */
    215