#ifndef __BOOTROOT_H__
#define __BOOTROOT_H__
#include <CoreFoundation/CoreFoundation.h>
#include <DiskArbitration/DiskArbitration.h>
#include <sys/stat.h>
#include <sys/time.h>
#define kTSCacheDir "/System/Library/Caches/com.apple.bootstamps/"
#define kTSCacheMask 0755 // Sec reviewed
#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 kBCPostBootKey CFSTR("PostBootPaths") // dict
#define kBCMKextKey CFSTR("MKext") // 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;
Boolean isBootRoot(char *volroot, Boolean *isGPT);
Boolean bootedFromDifferentMkext(void);
Boolean bootedFromDifferentKernel(void);
typedef struct {
char rpath[PATH_MAX]; char tspath[PATH_MAX]; struct timeval tstamps[2]; } cachedPath;
struct bootCaches {
int cachefd; CFStringRef volUUIDStr; char volname[NAME_MAX]; char root[PATH_MAX]; CFDictionaryRef cacheinfo;
char exts[PATH_MAX]; int nrps; cachedPath *rpspaths; int nmisc; cachedPath *miscpaths; cachedPath efibooter; cachedPath ofbooter;
cachedPath *mkext; cachedPath *bootconfig; cachedPath *label; };
struct bootCaches* readCaches(char *volroot);
void destroyCaches(struct bootCaches *caches);
int fillCachedPath(cachedPath *cpath, char *uuidchars, char *relpath);
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);
int fork_kextcache(char *cacheRoot, char *argv[], Boolean wait);
Boolean check_mkext(struct bootCaches *caches);
int rebuild_mkext(struct bootCaches *caches, Boolean wait);
void _daDone(DADiskRef disk, DADissenterRef dissenter, void *ctx);
#endif