X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d7e50217d7adf6e52786a38bcaa4cd698cb9a79e..c0fea4742e91338fffdcf79f86a7c1d5e2b97eb1:/bsd/hfs/hfs_catalog.h diff --git a/bsd/hfs/hfs_catalog.h b/bsd/hfs/hfs_catalog.h index 8ed86ba31..2f91eae90 100644 --- a/bsd/hfs/hfs_catalog.h +++ b/bsd/hfs/hfs_catalog.h @@ -1,24 +1,21 @@ /* - * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2002-2005 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -29,9 +26,7 @@ #ifdef KERNEL #ifdef __APPLE_API_PRIVATE -#include #include -#include #include @@ -65,6 +60,7 @@ struct cat_desc { /* cd_flags */ #define CD_HASBUF 0x01 /* allocated filename buffer */ #define CD_DECOMPOSED 0x02 /* name is fully decomposed */ +#define CD_ISMETA 0x40 /* describes a metadata file */ #define CD_ISDIR 0x80 /* describes a directory */ /* @@ -73,36 +69,74 @@ struct cat_desc { struct cat_attr { cnid_t ca_fileid; /* inode number (for stat) normally == cnid */ mode_t ca_mode; /* file access mode and type (16 bits) */ - nlink_t ca_nlink; /* file link count (16 bit integer) */ + u_int16_t ca_recflags; /* catalog record flags (16 bit integer) */ + u_int32_t ca_nlink; /* file link count */ uid_t ca_uid; /* file owner */ gid_t ca_gid; /* file group */ dev_t ca_rdev; /* device a special file represents */ time_t ca_atime; /* last access time */ + time_t ca_atimeondisk; /* access time value on disk */ time_t ca_mtime; /* last data modification time */ - int32_t ca_mtime_nsec; /* last data modification time nanosec */ time_t ca_ctime; /* last file status change */ time_t ca_itime; /* file initialization time */ time_t ca_btime; /* last backup time */ - u_long ca_flags; /* status flags (chflags) */ + u_int32_t ca_flags; /* status flags (chflags) */ union { u_int32_t cau_blocks; /* total file blocks used (rsrc + data) */ u_int32_t cau_entries; /* total directory entries (valence) */ } ca_union; u_int8_t ca_finderinfo[32]; /* Opaque Finder information */ + u_int32_t ca_attrblks; /* cached count of attribute data blocks */ }; /* Aliases for common fields */ #define ca_blocks ca_union.cau_blocks #define ca_entries ca_union.cau_entries /* - * Catalog Node Fork (runtime + on disk) + * Catalog Node Fork (runtime) + * + * NOTE: this is not the same as a struct HFSPlusForkData */ struct cat_fork { - u_int64_t cf_size; /* fork's logical size in bytes */ - u_int32_t cf_clump; /* fork's clump size in bytes */ - u_int32_t cf_blocks; /* total blocks used by this fork */ - struct HFSPlusExtentDescriptor cf_extents[8]; /* initial set of extents */ + u_int64_t cf_size; /* fork's logical size in bytes */ + union { + u_int32_t cfu_clump; /* fork's clump size in bytes (sys files only) */ + u_int64_t cfu_bytesread; /* bytes read from this fork */ + } cf_union; + u_int32_t cf_vblocks; /* virtual (unalloated) blocks */ + u_int32_t cf_blocks; /* total blocks used by this fork */ + struct HFSPlusExtentDescriptor cf_extents[8]; /* initial set of extents */ +}; + +#define cf_clump cf_union.cfu_clump +#define cf_bytesread cf_union.cfu_bytesread + + +/* + * Directory Hint + * Used to hold state across directory enumerations. + * + */ +struct directoryhint { + TAILQ_ENTRY(directoryhint) dh_link; /* chain */ + int dh_index; /* index into directory (zero relative) */ + u_int32_t dh_time; + struct cat_desc dh_desc; /* entry's descriptor */ }; +typedef struct directoryhint directoryhint_t; + +/* + * HFS_MAXDIRHINTS cannot be larger than 63 without reducing + * HFS_INDEX_BITS, because given the 6-bit tag, at most 63 different + * tags can exist. When HFS_MAXDIRHINTS is larger than 63, the same + * list may contain dirhints of the same tag, and a staled dirhint may + * be returned. + */ +#define HFS_MAXDIRHINTS 32 +#define HFS_DIRHINT_TTL 45 + +#define HFS_INDEX_MASK 0x03ffffff +#define HFS_INDEX_BITS 26 /* @@ -131,6 +165,48 @@ struct cat_entrylist { struct cat_entry entry[MAXCATENTRIES]; /* array of entries */ }; +/* + * Catalog Operations Hint + * + * lower 16 bits: count of B-tree insert operations + * upper 16 bits: count of B-tree delete operations + * + */ +#define CAT_DELETE 0x00020000 +#define CAT_CREATE 0x00000002 +#define CAT_RENAME 0x00020002 +#define CAT_EXCHANGE 0x00020002 + +typedef u_int32_t catops_t; + +/* + * The size of cat_cookie_t much match the size of + * the nreserve struct (in BTreeNodeReserve.c). + */ +typedef struct cat_cookie_t { + char opaque[24]; +} cat_cookie_t; + +/* Universal catalog key */ +union CatalogKey { + HFSCatalogKey hfs; + HFSPlusCatalogKey hfsPlus; +}; +typedef union CatalogKey CatalogKey; + +/* Universal catalog data record */ +union CatalogRecord { + int16_t recordType; + HFSCatalogFolder hfsFolder; + HFSCatalogFile hfsFile; + HFSCatalogThread hfsThread; + HFSPlusCatalogFolder hfsPlusFolder; + HFSPlusCatalogFile hfsPlusFile; + HFSPlusCatalogThread hfsPlusThread; +}; +typedef union CatalogRecord CatalogRecord; + + /* * Catalog Interface * @@ -157,7 +233,8 @@ extern int cat_lookup ( struct hfsmount *hfsmp, int wantrsrc, struct cat_desc *outdescp, struct cat_attr *attrp, - struct cat_fork *forkp); + struct cat_fork *forkp, + cnid_t *desc_cnid); extern int cat_idlookup (struct hfsmount *hfsmp, cnid_t cnid, @@ -165,10 +242,13 @@ extern int cat_idlookup (struct hfsmount *hfsmp, 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, - struct cat_desc *prevdesc, - int index, + directoryhint_t *dirhint, struct cat_entrylist *ce_list); extern int cat_rename ( struct hfsmount * hfsmp, @@ -185,14 +265,64 @@ extern int cat_update ( struct hfsmount *hfsmp, extern int cat_getdirentries( struct hfsmount *hfsmp, - struct cat_desc *descp, - struct uio *uio, - int *eofflag); + 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 /* __APPLE_API_PRIVATE */ #endif /* KERNEL */ #endif /* __HFS_CATALOG__ */