#ifndef _HFS_CNODE_H_
#define _HFS_CNODE_H_
#include <sys/appleapiopts.h>
#ifdef KERNEL
#ifdef __APPLE_API_PRIVATE
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/vnode.h>
#include <sys/quota.h>
#include <kern/locks.h>
#include <hfs/hfs_catalog.h>
#include <hfs/rangelist.h>
struct filefork {
struct cnode *ff_cp;
struct rl_head ff_invalidranges;
union {
void *ffu_sysfileinfo;
char *ffu_symlinkptr;
} ff_union;
struct cat_fork ff_data;
};
typedef struct filefork filefork_t;
#define ff_size ff_data.cf_size
#define ff_clumpsize ff_data.cf_clump
#define ff_bytesread ff_data.cf_bytesread
#define ff_blocks ff_data.cf_blocks
#define ff_extents ff_data.cf_extents
#define ff_unallocblocks ff_data.cf_vblocks
#define ff_symlinkptr ff_union.ffu_symlinkptr
#define ff_sysfileinfo ff_union.ffu_sysfileinfo
#define fcbEOF ff_size
#define fcbExtents ff_extents
#define fcbBTCBPtr ff_sysfileinfo
typedef u_int8_t atomicflag_t;
struct cnode {
lck_rw_t c_rwlock;
void * c_lockowner;
lck_rw_t c_truncatelock;
LIST_ENTRY(cnode) c_hash;
u_int32_t c_flag;
u_int32_t c_hflag;
struct vnode *c_vp;
struct vnode *c_rsrc_vp;
struct vnode *c_devvp;
dev_t c_dev;
struct dquot *c_dquot[MAXQUOTAS];
struct klist c_knotes;
u_long c_childhint;
struct cat_desc c_desc;
struct cat_attr c_attr;
TAILQ_HEAD(hfs_hinthead, directoryhint) c_hintlist;
int16_t c_dirhinttag;
union {
int16_t cu_dirhintcnt;
int16_t cu_syslockcount;
} c_union;
struct filefork *c_datafork;
struct filefork *c_rsrcfork;
atomicflag_t c_touch_acctime;
atomicflag_t c_touch_chgtime;
atomicflag_t c_touch_modtime;
};
typedef struct cnode cnode_t;
#define c_cnid c_desc.cd_cnid
#define c_hint c_desc.cd_hint
#define c_parentcnid c_desc.cd_parentcnid
#define c_encoding c_desc.cd_encoding
#define c_fileid c_attr.ca_fileid
#define c_mode c_attr.ca_mode
#define c_nlink c_attr.ca_nlink
#define c_uid c_attr.ca_uid
#define c_gid c_attr.ca_gid
#define c_rdev c_attr.ca_rdev
#define c_atime c_attr.ca_atime
#define c_mtime c_attr.ca_mtime
#define c_ctime c_attr.ca_ctime
#define c_itime c_attr.ca_itime
#define c_btime c_attr.ca_btime
#define c_flags c_attr.ca_flags
#define c_finderinfo c_attr.ca_finderinfo
#define c_blocks c_attr.ca_blocks
#define c_attrblks c_attr.ca_attrblks
#define c_entries c_attr.ca_entries
#define c_zftimeout c_childhint
#define c_dirhintcnt c_union.cu_dirhintcnt
#define c_syslockcount c_union.cu_syslockcount
#define H_ALLOC 0x00001
#define H_ATTACH 0x00002
#define H_TRANSIT 0x00004
#define H_WAITING 0x00008
#define C_NEED_RVNODE_PUT 0x00001
#define C_NEED_DVNODE_PUT 0x00002
#define C_ZFWANTSYNC 0x00004
#define C_FROMSYNC 0x00008
#define C_MODIFIED 0x00010
#define C_NOEXISTS 0x00020
#define C_DELETED 0x00040
#define C_HARDLINK 0x00080
#define C_FORCEUPDATE 0x00100
#define C_HASXATTRS 0x00200
#define ZFTIMELIMIT (5 * 60)
#define VTOC(vp) ((struct cnode *)vnode_fsnode((vp)))
#define CTOV(cp,rsrc) (((rsrc) && S_ISREG((cp)->c_mode)) ? \
(cp)->c_rsrc_vp : (cp)->c_vp)
#define FTOC(fp) ((fp)->ff_cp)
#define VTOF(vp) ((vp) == VTOC((vp))->c_rsrc_vp ? \
VTOC((vp))->c_rsrcfork : \
VTOC((vp))->c_datafork)
#define FTOV(fp) ((fp) == FTOC(fp)->c_rsrcfork ? \
FTOC(fp)->c_rsrc_vp : \
FTOC(fp)->c_vp)
#define FORK_IS_RSRC(fp) ((fp) == FTOC(fp)->c_rsrcfork)
#define VNODE_IS_RSRC(vp) ((vp) == VTOC((vp))->c_rsrc_vp)
#define ATIME_ONDISK_ACCURACY 300
struct hfsfid {
u_int32_t hfsfid_cnid;
u_int32_t hfsfid_gen;
};
extern void hfs_touchtimes(struct hfsmount *, struct cnode *);
extern void hfs_chashinit(void);
extern void hfs_chashinsert(struct cnode *cp);
extern int hfs_chashremove(struct cnode *cp);
extern void hfs_chash_abort(struct cnode *cp);
extern void hfs_chash_rehash(struct cnode *cp1, struct cnode *cp2);
extern void hfs_chashwakeup(struct cnode *cp, int flags);
extern void hfs_chash_mark_in_transit(struct cnode *cp);
extern struct vnode * hfs_chash_getvnode(dev_t dev, ino_t inum, int wantrsrc, int skiplock);
extern struct cnode * hfs_chash_getcnode(dev_t dev, ino_t inum, struct vnode **vpp, int wantrsrc, int skiplock);
extern int hfs_chash_snoop(dev_t, ino_t, int (*)(const struct cat_desc *,
const struct cat_attr *, void *), void *);
extern directoryhint_t * hfs_getdirhint(struct cnode *, int);
extern void hfs_reldirhint(struct cnode *, directoryhint_t *);
extern void hfs_reldirhints(struct cnode *, int);
enum hfslocktype {HFS_SHARED_LOCK = 1, HFS_EXCLUSIVE_LOCK = 2, HFS_FORCE_LOCK = 3};
#define HFS_SHARED_OWNER (void *)0xffffffff
extern int hfs_lock(struct cnode *, enum hfslocktype);
extern int hfs_lockpair(struct cnode *, struct cnode *, enum hfslocktype);
extern int hfs_lockfour(struct cnode *, struct cnode *, struct cnode *, struct cnode *,
enum hfslocktype);
extern void hfs_unlock(struct cnode *);
extern void hfs_unlockpair(struct cnode *, struct cnode *);
extern void hfs_unlockfour(struct cnode *, struct cnode *, struct cnode *, struct cnode *);
extern void hfs_lock_truncate(struct cnode *, int);
extern void hfs_unlock_truncate(struct cnode *);
#endif
#endif
#endif