-enum {
- kCatNameIsAllocated = 0x1, /* The name is malloc'd and is in cnm_nameptr */
- kCatNameIsMangled = 0x2, /* The name is mangled */
- kCatNameUsesReserved = 0x4, /* It overides the space reserved by cnm_namespace into cndu_extra, careful */
- kCatNameIsConsumed = 0x8, /* The name has been already processed, no freeing or work is needed */
- kCatNameNoCopyName = 0x10, /* Dont copy the name */
- kCatNameMangleName = 0x20 /* Mangle name if greater than passed in length */
-};
-
-/*
- * CatalogNameSpecifier is a structure that contains a name and possibly its form
- *
- * Special care needs to be taken with the flags, they can cause side effects.
- */
-struct CatalogNameSpecifier {
- u_int16_t cnm_flags; /* See above */
- u_int16_t cnm_length; /* Length of the name */
- u_int32_t cnm_parID; /* ID of the parent directory */
- unsigned char *cnm_nameptr; /* If allocated, a ptr to the space, else NULL */
- unsigned char cnm_namespace[MAXHFSVNODELEN+1]; /* Space where the name can be kept */
-};
-/*
- * NOTE IT IS REQUIRED that KMaxMangleNameLen >= MAXHFSVNODELEN
- * Also the total size of CatalogNameSpecifier should be less then cndu_extra, which
- * currently it easily is, this is not a requirement, just a nicety.
- *
- * The rules to how to store a name:
- * If its less than MAXHFSVNODELEN always store it in cnm_namespace.
- * If we can get by doing mangling then cnm_namespace
- * else allocate the space needed to cnm_nameptr.
- * This reflects what is done at vnode creation.
- */
-
-
-enum {
- kCatalogFolderNode = 1,
- kCatalogFileNode = 2
-};
-
-/*
- * CatalogNodeData has same layout as the on-disk HFS Plus file/dir records.
- * Classic hfs file/dir records are converted to match this layout.
- *
- * The cnd_extra padding allows big hfs plus thread records (520 bytes max)
- * to be read onto this stucture during a cnid lookup.
- *
- * IMPORTANT!!!!!!
- * After declaring this structure, you must use the macro INIT_CATALOGDATA to prepare it
- * and CLEAN_CATALOGDATA after using it, to clean any allocated structures.
- *
- * If you do not need to have the name, then pass in kCatNameNoCopyName for flags
- */
-struct CatalogNodeData {
- int16_t cnd_type;
- u_int16_t cnd_flags;
- u_int32_t cnd_valence; /* dirs only */
- u_int32_t cnd_nodeID;
- u_int32_t cnd_createDate;
- u_int32_t cnd_contentModDate;
- u_int32_t cnd_attributeModDate;
- u_int32_t cnd_accessDate;
- u_int32_t cnd_backupDate;
- u_int32_t cnd_ownerID;
- u_int32_t cnd_groupID;
- u_int8_t cnd_adminFlags; /* super-user changeable flags */
- u_int8_t cnd_ownerFlags; /* owner changeable flags */
- u_int16_t cnd_mode; /* file type + permission bits */
- union {
- u_int32_t cndu_iNodeNum; /* indirect links only */
- u_int32_t cndu_linkCount; /* indirect nodes only */
- u_int32_t cndu_rawDevice; /* special files (FBLK and FCHR) only */
- } cnd_un;
- u_int8_t cnd_finderInfo[32];
- u_int32_t cnd_textEncoding;
- u_int32_t cnd_reserved;
- HFSPlusForkData cnd_datafork;
- HFSPlusForkData cnd_rsrcfork;
- u_int32_t cnd_iNodeNumCopy;
- u_int32_t cnd_linkCNID; /* for hard links only */
- u_int8_t cnd_extra[264]; /* make struct at least 520 bytes long */
- struct CatalogNameSpecifier cnd_namespecifier;
-};
-typedef struct CatalogNodeData CatalogNodeData;
-
-#define cnd_iNodeNum cnd_un.cndu_iNodeNum
-#define cnd_linkCount cnd_un.cndu_linkCount
-#define cnd_rawDevice cnd_un.cndu_rawDevice
-
-#define cnm_flags cnd_namespecifier.cnm_flags
-#define cnm_length cnd_namespecifier.cnm_length
-#define cnm_parID cnd_namespecifier.cnm_parID
-#define cnm_nameptr cnd_namespecifier.cnm_nameptr
-#define cnm_namespace cnd_namespecifier.cnm_namespace
-
-#define INIT_CATALOGDATA(C,F) do { bzero(&((C)->cnd_namespecifier), sizeof(struct CatalogNameSpecifier)); (C)->cnm_flags=(F);}while(0);
-#if HFS_DIAGNOSTIC
-extern void debug_check_catalogdata(struct CatalogNodeData *cat);
-#define CLEAN_CATALOGDATA(C) do { debug_check_catalogdata(C); \
- if ((C)->cnm_flags & kCatNameIsAllocated) {\
- FREE((C)->cnm_nameptr, M_TEMP);\
- (C)->cnm_flags &= ~kCatNameIsAllocated;\
- (C)->cnm_nameptr = NULL;\
- }}while(0);
-#else
-#define CLEAN_CATALOGDATA(C) do { if ((C)->cnm_flags & kCatNameIsAllocated) {\
- FREE((C)->cnm_nameptr, M_TEMP);\
- (C)->cnm_flags &= ~kCatNameIsAllocated;\
- (C)->cnm_nameptr = NULL;\
- }}while(0);
-#endif
-
-/* structure to hold a catalog record information */
-/* Of everything you wanted to know about a catalog entry, file and directory */
-typedef struct hfsCatalogInfo {
- CatalogNodeData nodeData;
- u_int32_t hint;
-} hfsCatalogInfo;