#if !defined(__FS_FORMATNAME__)
#define __FS_FORMATNAME__ 1
#include "FSPrivate.h"
#include "bootsect.h" // for MSDOS
#include "bpb.h"
#include <CoreFoundation/CFBundle.h>
#include <CoreFoundation/CFDictionary.h>
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFPriv.h>
#include <libkern/OSAtomic.h> // for OSSpinLock
#include <sys/mount.h> // for struct statfs
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <hfs/hfs_format.h> // for HFS
#define MAX_FS_SUBTYPES 5
#define MAX_FSNAME 10
#define kFSSystemLibraryFileSystemsPath CFSTR("/System/Library/Filesystems")
#define KEY_FS_PERSONALITIES CFSTR("FSPersonalities")
#define KEY_FS_SUBTYPE CFSTR("FSSubType")
#define KEY_FS_NAME CFSTR("FSName")
#define UNKNOWN_FS_NAME CFSTR("Unknown")
#ifndef kFSEncryptNameKey
#define kFSEncryptNameKey "FSEncryptionName"
#endif
#ifndef kIOHDIXImageEncryptedProperty
#define kIOHDIXImageEncryptedProperty "image-encrypted"
#endif
#define APFS_NAME "apfs"
#define CASE_SENSITIVE CFSTR("CaseSensitive")
#define kAPFSEncryptedKey "Encrypted"
#define kAPFSEncryptionRolling "EncryptionRolling"
#define APFS_FS_NAME CFSTR("APFS")
#define APFS_CONTAINER_CLASS "AppleAPFSContainer"
enum {
kAPFSXSubType = 0,
kAPFSSubType = 1
};
#define APFS_IOUC_VOLUME_GET_VEK_STATE 19 // from apfs_iouc.h. If this changes, the world ends.
typedef struct {
uint32_t index;
} volume_vek_state_input;
typedef struct {
bool user_protected;
bool sys_protected;
} volume_vek_state_output;
#define HFS_NAME "hfs"
enum {
kHFSPlusSubType = 0,
kHFSJSubType = 1,
kHFSXSubType = 2,
kHFSXJSubType = 3,
kHFSSubType = 128
};
#define MAX_HFS_BLOCKSIZE 65536 // 64 KB
#define MSDOS_NAME "msdos"
enum {
kFAT12SubType = 0,
kFAT16SubType = 1,
kFAT32SubType = 2,
};
#define MAX_DOS_BLOCKSIZE 2048
CFStringRef FSCopyFormatNameForFSType(CFStringRef fsType, int16_t fsSubtype, bool localized, bool encrypted);
bool getfstype(char *devnode, char *fsname, int *fssubtype);
bool is_apfs(char *devnode, int *fssubtype);
bool is_hfs(char *devnode, int *fssubtype);
bool is_msdos(char *devnode, int *fssubtype);
static int getblk(int fd, unsigned long blk, int blksize, char* buf);
static int getwrapper(const HFSMasterDirectoryBlock *mdbp, off_t *offset);
ssize_t readdisk(int fd, off_t startaddr, size_t length, size_t blocksize, char* buf);
errno_t GetFSEncryptionStatus(const char *bsdname, bool *encryption_status, bool require_FDE,
fs_media_encryption_details_t *encryption_details);
errno_t GetDiskImageEncryptionStatus(const char *bsdname, bool *encryption_status);
#endif