#ifndef __BOOTCACHES_H__
#define __BOOTCACHES_H__
#include <CoreFoundation/CoreFoundation.h>
#include <DiskArbitration/DiskArbitration.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <IOKit/kext/kextmanager_types.h> // uuid_string_t
#include <mach-o/arch.h>
#define kTSCacheDir "/System/Library/Caches/com.apple.bootstamps/"
#define kTSCacheMask 0755 // Sec reviewed
#define kSysCacheMask 0755
#define kRPSDirMask 0755
#define kBootCachesPath "/usr/standalone/bootcaches.plist"
#define kBCPreBootKey CFSTR("PreBootPaths") // dict
#define kBCLabelKey CFSTR("DiskLabel") // ".disk_label"
#define kBCBootersKey CFSTR("BooterPaths") // dict
#define kBCEFIBooterKey CFSTR("EFIBooter") // "boot.efi"
#define kBCOFBooterKey CFSTR("OFBooter") // "BootX"
#define kBCPostBootKey CFSTR("PostBootPaths") // dict
#define kBCMKextKey CFSTR("MKext") // dict
#define kBCMKext2Key CFSTR("MKext2") // dict
#define kBCArchsKey CFSTR("Archs") // ar: ppc, i386
#define kBCExtensionsDirKey CFSTR("ExtensionsDir") // /S/L/E
#define kBCPathKey CFSTR("Path") // /S/L/E.mkext
#define kBCAdditionalPathsKey CFSTR("AdditionalPaths") // array
#define kBCBootConfigKey CFSTR("BootConfig") // path string
typedef enum {
kMkextCRCError = -1,
kMkextCRCFound = 0,
kMkextCRCNotFound = 1,
} MkextCRCResult;
typedef struct {
char rpath[PATH_MAX]; char tspath[PATH_MAX]; struct timeval tstamps[2]; } cachedPath;
#define NCHARSUUID (2*sizeof(uuid_t) + 5) // hex with 4 -'s and one NUL
#define DEVMAXPATHSIZE 128 // devfs/devfsdefs.h:
struct bootCaches {
int cachefd; char bsdname[DEVMAXPATHSIZE]; char uuid_str[NCHARSUUID]; char volname[NAME_MAX]; char root[PATH_MAX]; CFDictionaryRef cacheinfo; struct stat sb;
char exts[PATH_MAX]; int nrps; cachedPath *rpspaths; int nmisc; cachedPath *miscpaths; cachedPath efibooter; cachedPath ofbooter;
cachedPath *mkext; cachedPath *bootconfig; cachedPath *label; };
Boolean hasBootRootBoots(struct bootCaches *caches,
CFArrayRef *auxPartsCopy, Boolean *isAPM);
Boolean bootedFromDifferentMkext(void);
struct bootCaches* readCaches(DADiskRef dadisk);
void destroyCaches(struct bootCaches *caches);
int fillCachedPath(cachedPath *cpath, char *uuidchars, char *relpath);
DADiskRef createDiskForMount(DASessionRef session, const char *mount);
int needsUpdate(char *root, cachedPath* cpath, Boolean *outofdate);
int needUpdates(struct bootCaches *caches, Boolean *any,
Boolean *rps, Boolean *booters, Boolean *misc);
int applyStamps(struct bootCaches *caches);
Boolean plistCachesNeedRebuild(const NXArchInfo * kernelArchInfo);
Boolean check_mkext(struct bootCaches *caches);
int rebuild_mkext(struct bootCaches *caches, Boolean wait);
void _daDone(DADiskRef disk, DADissenterRef dissenter, void *ctx);
#endif