#ifndef __HFS_CATALOG__
#define __HFS_CATALOG__
#include <sys/appleapiopts.h>
#ifdef KERNEL
#ifdef __APPLE_API_PRIVATE
#include <sys/vnode.h>
#include <hfs/hfs_format.h>
typedef u_int32_t cnid_t;
struct cat_desc {
u_int8_t cd_flags;
u_int8_t cd_encoding;
int16_t cd_namelen;
char * cd_nameptr;
cnid_t cd_parentcnid;
u_long cd_hint;
cnid_t cd_cnid;
};
#define CD_HASBUF 0x01
#define CD_DECOMPOSED 0x02
#define CD_ISMETA 0x40
#define CD_ISDIR 0x80
struct cat_attr {
cnid_t ca_fileid;
mode_t ca_mode;
u_int16_t ca_recflags;
u_int32_t ca_nlink;
uid_t ca_uid;
gid_t ca_gid;
dev_t ca_rdev;
time_t ca_atime;
time_t ca_atimeondisk;
time_t ca_mtime;
time_t ca_ctime;
time_t ca_itime;
time_t ca_btime;
u_int32_t ca_flags;
union {
u_int32_t cau_blocks;
u_int32_t cau_entries;
} ca_union;
u_int8_t ca_finderinfo[32];
u_int32_t ca_attrblks;
};
#define ca_blocks ca_union.cau_blocks
#define ca_entries ca_union.cau_entries
struct cat_fork {
u_int64_t cf_size;
union {
u_int32_t cfu_clump;
u_int64_t cfu_bytesread;
} cf_union;
u_int32_t cf_vblocks;
u_int32_t cf_blocks;
struct HFSPlusExtentDescriptor cf_extents[8];
};
#define cf_clump cf_union.cfu_clump
#define cf_bytesread cf_union.cfu_bytesread
struct directoryhint {
TAILQ_ENTRY(directoryhint) dh_link;
int dh_index;
u_int32_t dh_time;
struct cat_desc dh_desc;
};
typedef struct directoryhint directoryhint_t;
#define HFS_MAXDIRHINTS 32
#define HFS_DIRHINT_TTL 45
#define HFS_INDEX_MASK 0x03ffffff
#define HFS_INDEX_BITS 26
struct cat_entry {
struct cat_desc ce_desc;
struct cat_attr ce_attr;
off_t ce_datasize;
off_t ce_rsrcsize;
u_long ce_datablks;
u_long ce_rsrcblks;
};
#define MAXCATENTRIES 8
struct cat_entrylist {
u_long maxentries;
u_long realentries;
struct cat_entry entry[MAXCATENTRIES];
};
#define CAT_DELETE 0x00020000
#define CAT_CREATE 0x00000002
#define CAT_RENAME 0x00020002
#define CAT_EXCHANGE 0x00020002
typedef u_int32_t catops_t;
typedef struct cat_cookie_t {
char opaque[24];
} cat_cookie_t;
union CatalogKey {
HFSCatalogKey hfs;
HFSPlusCatalogKey hfsPlus;
};
typedef union CatalogKey CatalogKey;
union CatalogRecord {
int16_t recordType;
HFSCatalogFolder hfsFolder;
HFSCatalogFile hfsFile;
HFSCatalogThread hfsThread;
HFSPlusCatalogFolder hfsPlusFolder;
HFSPlusCatalogFile hfsPlusFile;
HFSPlusCatalogThread hfsPlusThread;
};
typedef union CatalogRecord CatalogRecord;
struct hfsmount;
extern void cat_releasedesc(struct cat_desc *descp);
extern int cat_create ( struct hfsmount *hfsmp,
struct cat_desc *descp,
struct cat_attr *attrp,
struct cat_desc *out_descp);
extern int cat_delete ( struct hfsmount *hfsmp,
struct cat_desc *descp,
struct cat_attr *attrp);
extern int cat_lookup ( struct hfsmount *hfsmp,
struct cat_desc *descp,
int wantrsrc,
struct cat_desc *outdescp,
struct cat_attr *attrp,
struct cat_fork *forkp,
cnid_t *desc_cnid);
extern int cat_idlookup (struct hfsmount *hfsmp,
cnid_t cnid,
struct cat_desc *outdescp,
struct cat_attr *attrp,
struct cat_fork *forkp);
extern int cat_findname (struct hfsmount *hfsmp,
cnid_t cnid,
struct cat_desc *outdescp);
extern int cat_getentriesattr(
struct hfsmount *hfsmp,
directoryhint_t *dirhint,
struct cat_entrylist *ce_list);
extern int cat_rename ( struct hfsmount * hfsmp,
struct cat_desc * from_cdp,
struct cat_desc * todir_cdp,
struct cat_desc * to_cdp,
struct cat_desc * cdp);
extern int cat_update ( struct hfsmount *hfsmp,
struct cat_desc *descp,
struct cat_attr *attrp,
struct cat_fork *dataforkp,
struct cat_fork *rsrcforkp);
extern int cat_getdirentries(
struct hfsmount *hfsmp,
int entrycnt,
directoryhint_t *dirhint,
uio_t uio,
int extended,
int * items,
int * eofflag);
extern int cat_insertfilethread (
struct hfsmount *hfsmp,
struct cat_desc *descp);
extern int cat_preflight(
struct hfsmount *hfsmp,
catops_t ops,
cat_cookie_t *cookie,
struct proc *p);
extern void cat_postflight(
struct hfsmount *hfsmp,
cat_cookie_t *cookie,
struct proc *p);
extern int cat_binarykeycompare(
HFSPlusCatalogKey *searchKey,
HFSPlusCatalogKey *trialKey);
extern int CompareCatalogKeys(
HFSCatalogKey *searchKey,
HFSCatalogKey *trialKey);
extern int CompareExtendedCatalogKeys(
HFSPlusCatalogKey *searchKey,
HFSPlusCatalogKey *trialKey);
extern void cat_convertattr(
struct hfsmount *hfsmp,
CatalogRecord * recp,
struct cat_attr *attrp,
struct cat_fork *datafp,
struct cat_fork *rsrcfp);
extern int cat_convertkey(
struct hfsmount *hfsmp,
CatalogKey *key,
CatalogRecord * recp,
struct cat_desc *descp);
extern int resolvelink(
struct hfsmount *hfsmp,
u_long linkref,
struct HFSPlusCatalogFile *recp);
extern int cat_getkeyplusattr(
struct hfsmount *hfsmp,
cnid_t cnid,
CatalogKey *key,
struct cat_attr *attrp);
#endif
#endif
#endif