types

package
v1.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/** Volume Flags **/
	APFS_FS_UNENCRYPTED            volFlag = 0x00000001
	APFS_FS_RESERVED_2             volFlag = 0x00000002
	APFS_FS_RESERVED_4             volFlag = 0x00000004
	APFS_FS_ONEKEY                 volFlag = 0x00000008
	APFS_FS_SPILLEDOVER            volFlag = 0x00000010
	APFS_FS_RUN_SPILLOVER_CLEANER  volFlag = 0x00000020
	APFS_FS_ALWAYS_CHECK_EXTENTREF volFlag = 0x00000040
	APFS_FS_RESERVED_80            volFlag = 0x00000080
	APFS_FS_RESERVED_100           volFlag = 0x00000100

	APFS_FS_FLAGS_VALID_MASK = (APFS_FS_UNENCRYPTED | APFS_FS_RESERVED_2 | APFS_FS_RESERVED_4 | APFS_FS_ONEKEY | APFS_FS_SPILLEDOVER | APFS_FS_RUN_SPILLOVER_CLEANER | APFS_FS_ALWAYS_CHECK_EXTENTREF | APFS_FS_RESERVED_80 | APFS_FS_RESERVED_100)

	APFS_FS_CRYPTOFLAGS = (APFS_FS_UNENCRYPTED | APFS_FS_ONEKEY)

	/** Volume Roles **/
	APFS_VOL_ROLE_NONE volRole = 0x0000

	APFS_VOL_ROLE_SYSTEM    volRole = 0x0001
	APFS_VOL_ROLE_USER      volRole = 0x0002
	APFS_VOL_ROLE_RECOVERY  volRole = 0x0004
	APFS_VOL_ROLE_VM        volRole = 0x0008
	APFS_VOL_ROLE_PREBOOT   volRole = 0x0010
	APFS_VOL_ROLE_INSTALLER volRole = 0x0020

	APFS_VOLUME_ENUM_SHIFT = 6

	APFS_VOL_ROLE_DATA     volRole = (1 << APFS_VOLUME_ENUM_SHIFT) // = 0x0040 --- formerly defined explicitly as `0x0040`
	APFS_VOL_ROLE_BASEBAND volRole = (2 << APFS_VOLUME_ENUM_SHIFT) // = 0x0080 --- formerly defined explicitly as `0x0080`

	// Roles supported since revision 2020-05-15 --- macOS 10.15+, iOS 13+
	APFS_VOL_ROLE_UPDATE      volRole = (3 << APFS_VOLUME_ENUM_SHIFT)  // = 0x00c0
	APFS_VOL_ROLE_XART        volRole = (4 << APFS_VOLUME_ENUM_SHIFT)  // = 0x0100
	APFS_VOL_ROLE_HARDWARE    volRole = (5 << APFS_VOLUME_ENUM_SHIFT)  // = 0x0140
	APFS_VOL_ROLE_BACKUP      volRole = (6 << APFS_VOLUME_ENUM_SHIFT)  // = 0x0180
	APFS_VOL_ROLE_RESERVED_7  volRole = (7 << APFS_VOLUME_ENUM_SHIFT)  // = 0x01c0 --- spec also uses the name `APFS_VOL_ROLE_SIDECAR`, but that could be an error
	APFS_VOL_ROLE_RESERVED_8  volRole = (8 << APFS_VOLUME_ENUM_SHIFT)  // = 0x0200 --- formerly named `APFS_VOL_ROLE_RESERVED_200`
	APFS_VOL_ROLE_ENTERPRISE  volRole = (9 << APFS_VOLUME_ENUM_SHIFT)  // = 0x0240
	APFS_VOL_ROLE_RESERVED_10 volRole = (10 << APFS_VOLUME_ENUM_SHIFT) // = 0x0280
	APFS_VOL_ROLE_PRELOGIN    volRole = (11 << APFS_VOLUME_ENUM_SHIFT) // = 0x02c0

	/** Optional Volume Feature Flags **/
	APFS_FEATURE_DEFRAG_PRERELEASE       optVolFeatFlag = 0x00000001
	APFS_FEATURE_HARDLINK_MAP_RECORDS    optVolFeatFlag = 0x00000002
	APFS_FEATURE_DEFRAG                  optVolFeatFlag = 0x00000004
	APFS_FEATURE_STRICTATIME             optVolFeatFlag = 0x00000008
	APFS_FEATURE_VOLGRP_SYSTEM_INO_SPACE optVolFeatFlag = 0x00000010

	APFS_SUPPORTED_FEATURES_MASK = (APFS_FEATURE_DEFRAG | APFS_FEATURE_DEFRAG_PRERELEASE | APFS_FEATURE_HARDLINK_MAP_RECORDS | APFS_FEATURE_STRICTATIME | APFS_FEATURE_VOLGRP_SYSTEM_INO_SPACE)

	/** Read-Only Comaptible Volume Feature Flags **/
	APFS_SUPPORTED_ROCOMPAT_MASK = 0

	/** Incompatible Volume Feature Flags **/
	APFS_INCOMPAT_CASE_INSENSITIVE          incompatVolFeatFlag = 0x00000001
	APFS_INCOMPAT_DATALESS_SNAPS            incompatVolFeatFlag = 0x00000002
	APFS_INCOMPAT_ENC_ROLLED                incompatVolFeatFlag = 0x00000004
	APFS_INCOMPAT_NORMALIZATION_INSENSITIVE incompatVolFeatFlag = 0x00000008
	APFS_INCOMPAT_INCOMPLETE_RESTORE        incompatVolFeatFlag = 0x00000010
	APFS_INCOMPAT_SEALED_VOLUME             incompatVolFeatFlag = 0x00000020
	APFS_INCOMPAT_RESERVED_40               incompatVolFeatFlag = 0x00000040

	APFS_SUPPORTED_INCOMPAT_MASK = (APFS_INCOMPAT_CASE_INSENSITIVE | APFS_INCOMPAT_DATALESS_SNAPS | APFS_INCOMPAT_ENC_ROLLED | APFS_INCOMPAT_NORMALIZATION_INSENSITIVE | APFS_INCOMPAT_INCOMPLETE_RESTORE | APFS_INCOMPAT_SEALED_VOLUME | APFS_INCOMPAT_RESERVED_40)
)
View Source
const (
	APFS_MAGIC       = "APSB"
	APFS_MAX_HIST    = 8
	APFS_VOLNAME_LEN = 256
)
View Source
const (
	/** B-Tree Table of Contents Constants **/
	BTREE_TOC_ENTRY_INCREMENT  = 8
	BTREE_TOC_ENTRY_MAX_UNUSED = (2 * BTREE_TOC_ENTRY_INCREMENT)

	/** B-Tree Node Constants **/
	BTREE_NODE_SIZE_DEFAULT    = 4096 // = 4 Ki
	BTREE_NODE_MIN_ENTRY_COUNT = 4
)
View Source
const (
	/** B-Tree Flags **/
	BTREE_UINT64_KEYS       btreeInfoFixedFlags = 0x00000001 // Code that works with the B-tree should enable optimizations to make comparison of keys fast.
	BTREE_SEQUENTIAL_INSERT btreeInfoFixedFlags = 0x00000002 // Code that works with the B-tree should enable optimizations to keep the B-tree compact during sequential insertion of entries.
	BTREE_ALLOW_GHOSTS      btreeInfoFixedFlags = 0x00000004 // The table of contents is allowed to contain keys that have no corresponding value.
	BTREE_EPHEMERAL         btreeInfoFixedFlags = 0x00000008 // The nodes in the B-tree use ephemeral object identifiers to link to child nodes.
	BTREE_PHYSICAL          btreeInfoFixedFlags = 0x00000010 // The nodes in the B-tree use physical object identifiers to link to child nodes.
	BTREE_NONPERSISTENT     btreeInfoFixedFlags = 0x00000020 // The B-tree isnʼt persisted across unmounting.
	BTREE_KV_NONALIGNED     btreeInfoFixedFlags = 0x00000040 // The keys and values in the B-tree arenʼt required to be aligned to eight-byte boundaries.
	BTREE_HASHED            btreeInfoFixedFlags = 0x00000080 // The nonleaf nodes of this B-tree store a hash of their child nodes.
	BTREE_NOHEADER          btreeInfoFixedFlags = 0x00000100 // The nodes of this B-tree are stored without object headers.
)
View Source
const (
	/** B-Tree Node Flags **/
	BTNODE_ROOT btreeNodeFlag = 0x0001
	BTNODE_LEAF btreeNodeFlag = 0x0002

	BTNODE_FIXED_KV_SIZE btreeNodeFlag = 0x0004
	BTNODE_HASHED        btreeNodeFlag = 0x0008
	BTNODE_NOHEADER      btreeNodeFlag = 0x0010

	BTNODE_CHECK_KOFF_INVAL btreeNodeFlag = 0x8000
)
View Source
const (
	/** Protection Classes **/
	PROTECTION_CLASS_DIR_NONE cp_key_class_t = 0
	PROTECTION_CLASS_A        cp_key_class_t = 1
	PROTECTION_CLASS_B        cp_key_class_t = 2
	PROTECTION_CLASS_C        cp_key_class_t = 3
	PROTECTION_CLASS_D        cp_key_class_t = 4
	PROTECTION_CLASS_F        cp_key_class_t = 6
	PROTECTION_CLASS_M        cp_key_class_t = 14

	CP_EFFECTIVE_CLASSMASK = 0x0000001f

	/** Encryption Identifiers **/
	CRYPTO_SW_ID      = 4
	CRYPTO_RESERVED_5 = 5

	APFS_UNASSIGNED_CRYPTO_ID = 0xFFFFFFFFFFFFFFFF // ~0ULL
)
View Source
const (
	APFS_VOL_KEYBAG_ENTRY_MAX_SIZE     = 512
	APFS_FV_PERSONAL_RECOVERY_KEY_UUID = "EBC6C064-0000-11AA-AA11-00306543ECAC"
)
View Source
const (
	/** Keybag Tags **/
	KB_TAG_UNKNOWN    = 0
	KB_TAG_RESERVED_1 = 1

	KB_TAG_VOLUME_KEY             = 2
	KB_TAG_VOLUME_UNLOCK_RECORDS  = 3
	KB_TAG_VOLUME_PASSPHRASE_HINT = 4

	KB_TAG_WRAPPING_M_KEY = 5
	KB_TAG_VOLUME_M_KEY   = 6

	KB_TAG_RESERVED_F8 = 0xf8
)
View Source
const (
	/** Encryption-Rolling Checksum Block Sizes **/
	ER_512B_BLOCKSIZE  = 0
	ER_2KiB_BLOCKSIZE  = 1
	ER_4KiB_BLOCKSIZE  = 2
	ER_8KiB_BLOCKSIZE  = 3
	ER_16KiB_BLOCKSIZE = 4
	ER_32KiB_BLOCKSIZE = 5
	ER_64KiB_BLOCKSIZE = 6

	/** Encryption Rolling Flags **/
	ERSB_FLAG_ENCRYPTING   = 0x00000001
	ERSB_FLAG_DECRYPTING   = 0x00000002
	ERSB_FLAG_KEYROLLING   = 0x00000004
	ERSB_FLAG_PAUSED       = 0x00000008
	ERSB_FLAG_FAILED       = 0x00000010
	ERSB_FLAG_CID_IS_TWEAK = 0x00000020
	ERSB_FLAG_FREE_1       = 0x00000040
	ERSB_FLAG_FREE_2       = 0x00000080

	ERSB_FLAG_CM_BLOCK_SIZE_MASK  = 0x00000F00
	ERSB_FLAG_CM_BLOCK_SIZE_SHIFT = 8

	ERSB_FLAG_ER_PHASE_MASK  = 0x00003000
	ERSB_FLAG_ER_PHASE_SHIFT = 12
	ERSB_FLAG_FROM_ONEKEY    = 0x00004000

	/** Encryption-Rolling Constants **/
	ER_CHECKSUM_LENGTH = 8
	ER_MAGIC           = "FLAB"
	ER_VERSION         = 1

	ER_MAX_CHECKSUM_COUNT_SHIFT = 16
	ER_CUR_CHECKSUM_COUNT_MASK  = 0x0000ffff
)
View Source
const (
	ER_PHASE_OMAP_ROLL erPhase = 1
	ER_PHASE_DATA_ROLL erPhase = 2
	ER_PHASE_SNAP_ROLL erPhase = 3
)
View Source
const (
	MAX_DECMPFS_XATTR_SIZE = 3802
	DECMPFS_MAGIC          = "cmpf" // 0x636d7066
	DECMPFS_XATTR_NAME     = "com.apple.decmpfs"
)
View Source
const (
	CMP_TYPE1     compMethod = 1 // Uncompressed data in xattr
	CMP_ATTR_ZLIB compMethod = 3
	CMP_RSRC_ZLIB compMethod = 4 // 64k blocks
	/*
	 *  case 5: specifies de-dup within the generation store. Don't copy decmpfs xattr.
	 *  case 6: unused
	 */
	CMP_ATTR_LZVN         compMethod = 7
	CMP_RSRC_LZVN         compMethod = 8  // 64k blocks
	CMP_ATTR_UNCOMPRESSED compMethod = 9  // uncompressed data in xattr (similar to but not identical to CMP_Type1)
	CMP_RSRC_UNCOMPRESSED compMethod = 10 // 64k chunked uncompressed data in resource fork
	CMP_ATTR_LZFSE        compMethod = 11
	CMP_RSRC_LZFSE        compMethod = 12 // 64k blocks
	CMP_ATTR_LZBITMAP     compMethod = 13
	CMP_RSRC_LZBITMAP     compMethod = 14 // 64k blocks

	CMP_MAX compMethod = 255 // Highest compression_type supported
)

https://opensource.apple.com/source/copyfile/copyfile-138/copyfile.c.auto.html

View Source
const (
	PEXT_LEN_MASK   = 0x0fffffffffffffff
	PEXT_KIND_MASK  = 0xf000000000000000
	PEXT_KIND_SHIFT = 60
)
View Source
const (
	J_FILE_EXTENT_LEN_MASK   = 0x00ffffffffffffff
	J_FILE_EXTENT_FLAG_MASK  = 0xff00000000000000
	J_FILE_EXTENT_FLAG_SHIFT = 56
)
View Source
const (
	/** Address Markers **/
	FUSION_TIER2_DEVICE_BYTE_ADDR = 0x4000000000000000

	/** Fusion Middle-Tree Flags **/
	FUSION_MT_DIRTY    = (1 << 0)
	FUSION_MT_TENANT   = (1 << 1)
	FUSION_MT_ALLFLAGS = (FUSION_MT_DIRTY | FUSION_MT_TENANT)
)
View Source
const (
	APFS_TYPE_ANY           j_obj_types = 0
	APFS_TYPE_SNAP_METADATA j_obj_types = 1
	APFS_TYPE_EXTENT        j_obj_types = 2
	APFS_TYPE_INODE         j_obj_types = 3
	APFS_TYPE_XATTR         j_obj_types = 4
	APFS_TYPE_SIBLING_LINK  j_obj_types = 5
	APFS_TYPE_DSTREAM_ID    j_obj_types = 6
	APFS_TYPE_CRYPTO_STATE  j_obj_types = 7
	APFS_TYPE_FILE_EXTENT   j_obj_types = 8
	APFS_TYPE_DIR_REC       j_obj_types = 9
	APFS_TYPE_DIR_STATS     j_obj_types = 10
	APFS_TYPE_SNAP_NAME     j_obj_types = 11
	APFS_TYPE_SIBLING_MAP   j_obj_types = 12
	APFS_TYPE_FILE_INFO     j_obj_types = 13

	APFS_TYPE_MAX_VALID j_obj_types = 13
	APFS_TYPE_MAX       j_obj_types = 15

	APFS_TYPE_INVALID j_obj_types = 15
)
View Source
const (
	APFS_KIND_ANY           j_obj_kinds = 0
	APFS_KIND_NEW           j_obj_kinds = 1
	APFS_KIND_UPDATE        j_obj_kinds = 2
	APFS_KIND_DEAD          j_obj_kinds = 3
	APFS_KIND_UPDATE_RECENT j_obj_kinds = 4

	APFS_KIND_INVALID j_obj_kinds = 255
)
View Source
const (
	INODE_IS_APFS_PRIVATE        j_inode_flags = 0x00000001
	INODE_MAINTAIN_DIR_STATS     j_inode_flags = 0x00000002
	INODE_DIR_STATS_ORIGIN       j_inode_flags = 0x00000004
	INODE_PROT_CLASS_EXPLICIT    j_inode_flags = 0x00000008
	INODE_WAS_CLONED             j_inode_flags = 0x00000010
	INODE_FLAG_UNUSED            j_inode_flags = 0x00000020
	INODE_HAS_SECURITY_EA        j_inode_flags = 0x00000040
	INODE_BEING_TRUNCATED        j_inode_flags = 0x00000080
	INODE_HAS_FINDER_INFO        j_inode_flags = 0x00000100
	INODE_IS_SPARSE              j_inode_flags = 0x00000200
	INODE_WAS_EVER_CLONED        j_inode_flags = 0x00000400
	INODE_ACTIVE_FILE_TRIMMED    j_inode_flags = 0x00000800
	INODE_PINNED_TO_MAIN         j_inode_flags = 0x00001000
	INODE_PINNED_TO_TIER2        j_inode_flags = 0x00002000
	INODE_HAS_RSRC_FORK          j_inode_flags = 0x00004000
	INODE_NO_RSRC_FORK           j_inode_flags = 0x00008000
	INODE_ALLOCATION_SPILLEDOVER j_inode_flags = 0x00010000
	INODE_FAST_PROMOTE           j_inode_flags = 0x00020000
	INODE_HAS_UNCOMPRESSED_SIZE  j_inode_flags = 0x00040000
	INODE_IS_PURGEABLE           j_inode_flags = 0x00080000
	INODE_WANTS_TO_BE_PURGEABLE  j_inode_flags = 0x00100000
	INODE_IS_SYNC_ROOT           j_inode_flags = 0x00200000
	INODE_SNAPSHOT_COW_EXEMPTION j_inode_flags = 0x00400000

	INODE_INHERITED_INTERNAL_FLAGS j_inode_flags = (INODE_MAINTAIN_DIR_STATS | INODE_SNAPSHOT_COW_EXEMPTION)

	INODE_CLONED_INTERNAL_FLAGS     j_inode_flags = (INODE_HAS_RSRC_FORK | INODE_NO_RSRC_FORK | INODE_HAS_FINDER_INFO | INODE_SNAPSHOT_COW_EXEMPTION)
	APFS_VALID_INTERNAL_INODE_FLAGS j_inode_flags = (INODE_IS_APFS_PRIVATE | INODE_MAINTAIN_DIR_STATS | INODE_DIR_STATS_ORIGIN | INODE_PROT_CLASS_EXPLICIT | INODE_WAS_CLONED | INODE_HAS_SECURITY_EA | INODE_BEING_TRUNCATED | INODE_HAS_FINDER_INFO | INODE_IS_SPARSE | INODE_WAS_EVER_CLONED | INODE_ACTIVE_FILE_TRIMMED | INODE_PINNED_TO_MAIN | INODE_PINNED_TO_TIER2 | INODE_HAS_RSRC_FORK | INODE_NO_RSRC_FORK | INODE_ALLOCATION_SPILLEDOVER | INODE_FAST_PROMOTE | INODE_HAS_UNCOMPRESSED_SIZE | INODE_IS_PURGEABLE | INODE_WANTS_TO_BE_PURGEABLE | INODE_IS_SYNC_ROOT | INODE_SNAPSHOT_COW_EXEMPTION)
	APFS_INODE_PINNED_MASK          j_inode_flags = (INODE_PINNED_TO_MAIN | INODE_PINNED_TO_TIER2)
)
View Source
const (
	XATTR_DATA_STREAM       j_xattr_flags = 0x00000001
	XATTR_DATA_EMBEDDED     j_xattr_flags = 0x00000002
	XATTR_FILE_SYSTEM_OWNED j_xattr_flags = 0x00000004
	XATTR_RESERVED_8        j_xattr_flags = 0x00000008
)
View Source
const (
	DREC_TYPE_MASK dir_rec_flags = 0x000f
	RESERVED_10    dir_rec_flags = 0x0010
)
View Source
const (
	/** Inode Numbers **/
	INVALID_INO_NUM       = 0
	ROOT_DIR_PARENT       = 1
	ROOT_DIR_INO_NUM      = 2
	PRIV_DIR_INO_NUM      = 3
	SNAP_DIR_INO_NUM      = 6
	PURGEABLE_DIR_INO_NUM = 7

	MIN_USER_INO_NUM = 16

	UNIFIED_ID_SPACE_MARK = 0x0800000000000000

	/** Extended Attributes Constants **/
	XATTR_MAX_EMBEDDED_SIZE                              = 3804 // = 3 Ki + 732
	XATTR_APFS_COW_EXEMPT_COUNT_NAME                     = "com.apple.fs.cow-exempt-file-count"
	XATTR_DB_REBUILD_IN_PROGRESS_EA_NAME                 = "com.apple.assetsd.dbRebuildInProgress"
	XATTR_DB_REBUILD_UUID_EA_NAME                        = "com.apple.assetsd.dbRebuildUuid"
	XATTR_THUMBNAIL_CAMERA_PREVIEW_IMAGE_ASSETID_EA_NAME = "com.apple.assetsd.thumbnailCameraPreviewImageAssetID"
	XATTR_UUID_EA_NAME                                   = "com.apple.assetsd.UUID"
	XATTR_DECMPFS_EA_NAME                                = "com.apple.decmpfs"
	XATTR_FINDER_INFO_EA_NAME                            = "com.apple.FinderInfo"
	XATTR_SYMLINK_EA_NAME                                = "com.apple.fs.symlink"
	XATTR_FIRMLINK_EA_NAME                               = "com.apple.fs.firmlink"
	XATTR_INFO_EA_NAME                                   = "com.apple.genstore.info"
	XATTR_ORIG_DISPLAY_NAME_EA_NAME                      = "com.apple.genstore.origdisplayname"
	XATTR_ORIG_PERMS_V1_EA_NAME                          = "com.apple.genstore.orig_perms_v1"
	XATTR_ORIG_POSIX_NAME_EA_NAME                        = "com.apple.genstore.origposixname"
	XATTR_SHA1_EA_NAME                                   = "com.apple.GeoServices.SHA1"
	XATTR_INSTALL_TYPE_EA_NAME                           = "com.apple.installd.installType"
	XATTR_UNIQUE_INSTALLID_EA_NAME                       = "com.apple.installd.uniqueInstallID"
	XATTR_PS_EA_NAME                                     = "com.apple.lastuseddate#PS"
	XATTR_KMD_ITEM_USER_TAGS_EA_NAME                     = "com.apple.metadata:_kMDItemUserTags"
	XATTR_COM_APPLE_BACKUP_EXCLUDEITEM_EA_NAME           = "com.apple.metadata:com_apple_backup_excludeItem"
	XATTR_KMD_ITEM_DOWNLOADED_DATE_EA_NAME               = "com.apple.metadata:kMDItemDownloadedDate"
	XATTR_KMD_ITEM_WHERE_FROMS_EA_NAME                   = "com.apple.metadata:kMDItemWhereFroms"
	XATTR_KMD_LABEL_EA_NAME                              = "com.apple.metadata:kMDLabel_fwlfb7nbt2o7degof3q2o2btjy"
	XATTR_QUARANTINE_EA_NAME                             = "com.apple.quarantine"
	XATTR_RESOURCEFORK_EA_NAME                           = "com.apple.ResourceFork"
	XATTR_ROOTLESS_EA_NAME                               = "com.apple.rootless"
	XATTR_SECURITY_EA_NAME                               = "com.apple.system.Security"
	XATTR_TEXT_ENCODING_EA_NAME                          = "com.apple.TextEncoding"
	XATTR_LAST_UPGRADE_CHECK_EA_NAME                     = "LastUpgradeCheck"
	XATTR_LOCK_EA_NAME                                   = "lock"
	XATTR_CRASHPAD_DB_INITIALIZED_EA_NAME                = "org.chromium.crashpad.database.initialized"

	/** File-System Object Constants **/
	OWNING_OBJ_ID_INVALID uint64 = 0xFFFFFFFFFFFFFFFF
	OWNING_OBJ_ID_UNKNOWN uint64 = 0xFFFFFFFFFFFFFFFE

	JOBJ_MAX_KEY_SIZE   = 832
	JOBJ_MAX_VALUE_SIZE = 3808 // = 3 Ki + 736

	MIN_DOC_ID = 3

	/** File Extent Constants **/
	FEXT_CRYPTO_ID_IS_TWEAK = 0x01
)
View Source
const (
	S_IFMT mode_t = 0170000 // The bit mask used to access the file type.

	FIFO mode_t = 0010000 // A named pipe.
	CHR  mode_t = 0020000 // A character-special file.
	DIR  mode_t = 0040000 // A directory.
	BLK  mode_t = 0060000 // A block-special file.
	REG  mode_t = 0100000 // A regular file.
	LNK  mode_t = 0120000 // A symbolic link.
	SOCK mode_t = 0140000 // A socket.
	WHT  mode_t = 0160000 // A whiteout.

	/** Directory Entry File Types **/
	DT_UNKNOWN dir_ent_file_type = 0
	DT_FIFO    dir_ent_file_type = 1  // A named pipe.
	DT_CHR     dir_ent_file_type = 2  // A character-special file.
	DT_DIR     dir_ent_file_type = 4  // A directory.
	DT_BLK     dir_ent_file_type = 6  // A block-special file.
	DT_REG     dir_ent_file_type = 8  // A regular file.
	DT_LNK     dir_ent_file_type = 10 // A symbolic link.
	DT_SOCK    dir_ent_file_type = 12 // A socket.
	DT_WHT     dir_ent_file_type = 14 // A whiteout.
)
View Source
const (
	OBJ_ID_MASK    = 0x0fffffffffffffff
	OBJ_TYPE_MASK  = 0xf000000000000000
	OBJ_TYPE_SHIFT = 60

	SYSTEM_OBJ_ID_MARK = 0x0fffffff00000000
)
View Source
const (
	/*
	 * Definitions of flags stored in file flags word.
	 *
	 * Super-user and owner changeable flags.
	 */
	UF_SETTABLE bsd_flags_t = 0x0000ffff /* mask of owner changeable flags */
	NONE        bsd_flags_t = 0x00000000
	NODUMP      bsd_flags_t = 0x00000001 /* do not dump file */
	IMMUTABLE   bsd_flags_t = 0x00000002 /* file may not be changed */
	APPEND      bsd_flags_t = 0x00000004 /* writes to file may only append */
	OPAQUE      bsd_flags_t = 0x00000008 /* directory is opaque wrt. union */
	/*
	 * The following bit is reserved for FreeBSD.  It is not implemented
	 * in Mac OS X.
	 */
	NOUNLINK   bsd_flags_t = 0x00000010 /* file may not be removed or renamed */
	COMPRESSED bsd_flags_t = 0x00000020 /* file is compressed (some file-systems) */

	/* UF_TRACKED is used for dealing with document IDs.  We no longer issue
	 *  notifications for deletes or renames for files which have UF_TRACKED set. */
	TRACKED bsd_flags_t = 0x00000040

	DATAVAULT bsd_flags_t = 0x00000080 /* entitlement required for reading and writing */

	/* Bits 0x0100 through 0x4000 are currently undefined. */
	HIDDEN bsd_flags_t = 0x00008000 /* hint that this item should not be displayed in a GUI */
	/*
	 * Super-user changeable flags.
	 */
	SF_SUPPORTED  bsd_flags_t = 0x009f0000 /* mask of superuser supported flags */
	SF_SETTABLE   bsd_flags_t = 0x3fff0000 /* mask of superuser changeable flags */
	SF_SYNTHETIC  bsd_flags_t = 0xc0000000 /* mask of system read-only synthetic flags */
	SF_ARCHIVED   bsd_flags_t = 0x00010000 /* file is archived */
	SF_IMMUTABLE  bsd_flags_t = 0x00020000 /* file may not be changed */
	SF_APPEND     bsd_flags_t = 0x00040000 /* writes to file may only append */
	SF_RESTRICTED bsd_flags_t = 0x00080000 /* entitlement required for writing */
	SF_NOUNLINK   bsd_flags_t = 0x00100000 /* Item may not be removed, renamed or mounted on */
	/*
	 * The following two bits are reserved for FreeBSD.  They are not
	 * implemented in Mac OS X.
	 */
	/* NOTE: There is no SF_HIDDEN bit. */
	SF_SNAPSHOT bsd_flags_t = 0x00200000 /* snapshot inode */
	SF_FIRMLINK bsd_flags_t = 0x00800000 /* file is a firmlink */
	/*
	 * Synthetic flags.
	 *
	 * These are read-only.  We keep them out of SF_SUPPORTED so that
	 * attempts to set them will fail.
	 */
	SF_DATALESS bsd_flags_t = 0x40000000 /* file is dataless object */
)
View Source
const (
	J_DREC_LEN_MASK   uint32 = 0x000003ff
	J_DREC_HASH_MASK  uint32 = 0xfffffc00 // Spec incorrectly says `0xfffff400`
	J_DREC_HASH_SHIFT        = 10
)
View Source
const (
	NX_EFI_JUMPSTART_MAGIC   = "RDSJ"
	NX_EFI_JUMPSTART_VERSION = 1
	/** Partition UUIDs **/
	APFS_GPT_PARTITION_UUID = "7C3457EF-0000-11AA-AA11-00306543ECAC"
)
View Source
const (
	NX_CNTR_OBJ_CKSUM_SET  nx_counter_id_t = 0
	NX_CNTR_OBJ_CKSUM_FAIL nx_counter_id_t = 1

	NX_NUM_COUNTERS nx_counter_id_t = 32
)
View Source
const (
	NX_MAGIC            = "NXSB"
	NX_MAX_FILE_SYSTEMS = 100

	NX_EPH_INFO_COUNT              = 4
	NX_EPH_MIN_BLOCK_COUNT         = 8
	NX_MAX_FILE_SYSTEM_EPH_STRUCTS = 4
	NX_TX_MIN_CHECKPOINT_COUNT     = 4
	NX_EPH_INFO_VERSION            = 1
)
View Source
const (
	/** Container Flags **/
	NX_RESERVED_1 nxContainerFlag = 0x00000001
	NX_RESERVED_2 nxContainerFlag = 0x00000002
	NX_CRYPTO_SW  nxContainerFlag = 0x00000004

	/** Optional Container Feature Flags **/
	NX_FEATURE_DEFRAG          nxFeature = 0x0000000000000001
	NX_FEATURE_LCFD            nxFeature = 0x0000000000000002
	NX_SUPPORTED_FEATURES_MASK           = (NX_FEATURE_DEFRAG | NX_FEATURE_LCFD)

	/** Read-Only Compatible Container Feature Flags **/
	NX_SUPPORTED_ROCOMPAT_MASK = 0

	/** Incompatible Container Feature Flags **/
	NX_INCOMPAT_VERSION1       nxIncompatFeature = 0x0000000000000001
	NX_INCOMPAT_VERSION2       nxIncompatFeature = 0x0000000000000002
	NX_INCOMPAT_FUSION         nxIncompatFeature = 0x0000000000000100
	NX_SUPPORTED_INCOMPAT_MASK                   = (NX_INCOMPAT_VERSION2 | NX_INCOMPAT_FUSION)

	/** Block and Container Size **/
	NX_MINIMUM_BLOCK_SIZE     = 0x1000   // =    4 Ki
	NX_DEFAULT_BLOCK_SIZE     = 0x1000   // =    4 Ki
	NX_MAXIMUM_BLOCK_SIZE     = 0x10000  // =   64 Ki
	NX_MINIMUM_CONTAINER_SIZE = 0x100000 // = 1024 Ki = 1 Mi
)
View Source
const (
	MAX_CKSUM_SIZE = 8

	OID_NX_SUPERBLOCK  = 1
	OID_INVALID        = 0
	OID_RESERVED_COUNT = 1024

	OBJECT_TYPE_MASK       = 0x0000ffff
	OBJECT_TYPE_FLAGS_MASK = 0xffff0000

	OBJ_STORAGETYPE_MASK           = 0xc0000000
	OBJECT_TYPE_FLAGS_DEFINED_MASK = 0xf8000000
)
View Source
const (
	OBJECT_TYPE_NX_SUPERBLOCK objType = 0x00000001

	OBJECT_TYPE_BTREE      objType = 0x00000002
	OBJECT_TYPE_BTREE_NODE objType = 0x00000003

	OBJECT_TYPE_SPACEMAN            objType = 0x00000005
	OBJECT_TYPE_SPACEMAN_CAB        objType = 0x00000006
	OBJECT_TYPE_SPACEMAN_CIB        objType = 0x00000007
	OBJECT_TYPE_SPACEMAN_BITMAP     objType = 0x00000008
	OBJECT_TYPE_SPACEMAN_FREE_QUEUE objType = 0x00000009

	OBJECT_TYPE_EXTENT_LIST_TREE objType = 0x0000000a
	OBJECT_TYPE_OMAP             objType = 0x0000000b
	OBJECT_TYPE_CHECKPOINT_MAP   objType = 0x0000000c

	OBJECT_TYPE_FS           objType = 0x0000000d
	OBJECT_TYPE_FSTREE       objType = 0x0000000e
	OBJECT_TYPE_BLOCKREFTREE objType = 0x0000000f
	OBJECT_TYPE_SNAPMETATREE objType = 0x00000010

	OBJECT_TYPE_NX_REAPER          objType = 0x00000011
	OBJECT_TYPE_NX_REAP_LIST       objType = 0x00000012
	OBJECT_TYPE_OMAP_SNAPSHOT      objType = 0x00000013
	OBJECT_TYPE_EFI_JUMPSTART      objType = 0x00000014
	OBJECT_TYPE_FUSION_MIDDLE_TREE objType = 0x00000015
	OBJECT_TYPE_NX_FUSION_WBC      objType = 0x00000016
	OBJECT_TYPE_NX_FUSION_WBC_LIST objType = 0x00000017
	OBJECT_TYPE_ER_STATE           objType = 0x00000018

	OBJECT_TYPE_GBITMAP       objType = 0x00000019
	OBJECT_TYPE_GBITMAP_TREE  objType = 0x0000001a
	OBJECT_TYPE_GBITMAP_BLOCK objType = 0x0000001b
	// new in 2020-06-22
	OBJECT_TYPE_ER_RECOVERY_BLOCK objType = 0x0000001c
	OBJECT_TYPE_SNAP_META_EXT     objType = 0x0000001d
	OBJECT_TYPE_INTEGRITY_META    objType = 0x0000001e
	OBJECT_TYPE_FEXT_TREE         objType = 0x0000001f
	OBJECT_TYPE_RESERVED_20       objType = 0x00000020

	OBJECT_TYPE_INVALID objType = 0x00000000
	OBJECT_TYPE_TEST    objType = 0x000000ff

	OBJECT_TYPE_CONTAINER_KEYBAG = `keys`
	OBJECT_TYPE_VOLUME_KEYBAG    = `recs`
	OBJECT_TYPE_MEDIA_KEYBAG     = `mkey`

	/** Object Type Flags **/
	OBJ_VIRTUAL   objFlag = 0x00000000
	OBJ_EPHEMERAL objFlag = 0x80000000
	OBJ_PHYSICAL  objFlag = 0x40000000

	OBJ_NOHEADER      objFlag = 0x20000000
	OBJ_ENCRYPTED     objFlag = 0x10000000
	OBJ_NONPERSISTENT objFlag = 0x08000000
)
View Source
const (
	/** Object Map Value Flags **/
	OMAP_VAL_DELETED           omapValFlag = 0x00000001
	OMAP_VAL_SAVED             omapValFlag = 0x00000002
	OMAP_VAL_ENCRYPTED         omapValFlag = 0x00000004
	OMAP_VAL_NOHEADER          omapValFlag = 0x00000008
	OMAP_VAL_CRYPTO_GENERATION omapValFlag = 0x00000010

	/** Snapshot Flags **/
	OMAP_SNAPSHOT_DELETED  omapSnapshotFlag = 0x00000001
	OMAP_SNAPSHOT_REVERTED omapSnapshotFlag = 0x00000002

	/** Object Map Flags **/
	OMAP_MANUALLY_MANAGED  omapFlag = 0x00000001
	OMAP_ENCRYPTING        omapFlag = 0x00000002
	OMAP_DECRYPTING        omapFlag = 0x00000004
	OMAP_KEYROLLING        omapFlag = 0x00000008
	OMAP_CRYPTO_GENERATION omapFlag = 0x00000010

	OMAP_VALID_FLAGS = 0x0000001f

	/** Object Map Constants **/
	OMAP_MAX_SNAP_COUNT = math.MaxUint32

	/** Object Map Reaper Phases **/
	OMAP_REAP_PHASE_MAP_TREE      omapReapPhase = 1
	OMAP_REAP_PHASE_SNAPSHOT_TREE omapReapPhase = 2
)
View Source
const (
	/** Volume Reaper States **/
	APFS_REAP_PHASE_START        = 0
	APFS_REAP_PHASE_SNAPSHOTS    = 1
	APFS_REAP_PHASE_ACTIVE_FS    = 2
	APFS_REAP_PHASE_DESTROY_OMAP = 3
	APFS_REAP_PHASE_DONE         = 4

	/** Reaper Flags **/
	NR_BHM_FLAG nrFlags = 0x00000001 // Reserved.
	NR_CONTINUE nrFlags = 0x00000002 // The current object is being reaped.

	/** Reaper List Entry Flags **/
	NRLE_VALID          rlFlags = 0x00000001
	NRLE_REAP_ID_RECORD rlFlags = 0x00000002
	NRLE_CALL           rlFlags = 0x00000004
	NRLE_COMPETITION    rlFlags = 0x00000008
	NRLE_CLEANUP        rlFlags = 0x00000010

	/** Reaper List Flags **/
	NRL_INDEX_INVALID = 0xffffffff
)
View Source
const (
	APFS_HASH_INVALID    apfs_hash_type_t = 0
	APFS_HASH_SHA256     apfs_hash_type_t = 0x1
	APFS_HASH_SHA512_256 apfs_hash_type_t = 0x2
	APFS_HASH_SHA384     apfs_hash_type_t = 0x3
	APFS_HASH_SHA512     apfs_hash_type_t = 0x4

	APFS_HASH_MIN apfs_hash_type_t = APFS_HASH_SHA256
	APFS_HASH_MAX apfs_hash_type_t = APFS_HASH_SHA512

	APFS_HASH_DEFAULT apfs_hash_type_t = APFS_HASH_SHA256
)
View Source
const (
	APFS_HASH_CCSHA256_SIZE     = 32
	APFS_HASH_CCSHA512_256_SIZE = 32
	APFS_HASH_CCSHA384_SIZE     = 48
	APFS_HASH_CCSHA512_SIZE     = 64

	APFS_HASH_MAX_SIZE = 64
)
View Source
const (
	INTEGRITY_META_VERSION_INVALID = 0
	INTEGRITY_META_VERSION_1       = 1
	INTEGRITY_META_VERSION_2       = 2
	INTEGRITY_META_VERSION_HIGHEST = INTEGRITY_META_VERSION_2
)

* Integrity Metadata Version Constants *

View Source
const (
	J_FILE_INFO_LBA_MASK   = 0x00ffffffffffffff
	J_FILE_INFO_TYPE_MASK  = 0xff00000000000000
	J_FILE_INFO_TYPE_SHIFT = 56
)
View Source
const (
	SM_ALLOCZONE_INVALID_END_BOUNDARY    = 0
	SM_ALLOCZONE_NUM_PREVIOUS_BOUNDARIES = 7
)
View Source
const (
	SD_MAIN  smdev = 0
	SD_TIER2 smdev = 1
	SD_COUNT smdev = 2
)
View Source
const (
	SFQ_IP    sfq = 0
	SFQ_MAIN  sfq = 1
	SFQ_TIER2 sfq = 2
	SFQ_COUNT sfq = 3
)
View Source
const (
	SM_FLAG_VERSIONED = 0x00000001

	/** Chunk Info Block Constants **/
	CI_COUNT_MASK          = 0x000fffff
	CI_COUNT_RESERVED_MASK = 0xfff00000

	/** Internal-Pool Bitmap **/
	SPACEMAN_IP_BM_TX_MULTIPLIER   = 16
	SPACEMAN_IP_BM_INDEX_INVALID   = 0xfff
	SPACEMAN_IP_BM_BLOCK_COUNT_MAX = 0xffe
)
View Source
const (
	/** Extended-Field Types **/
	DREC_EXT_TYPE_SIBLING_ID = 1

	INO_EXT_TYPE_SNAP_XID          xfType = 1
	INO_EXT_TYPE_DELTA_TREE_OID    xfType = 2
	INO_EXT_TYPE_DOCUMENT_ID       xfType = 3
	INO_EXT_TYPE_NAME              xfType = 4
	INO_EXT_TYPE_PREV_FSIZE        xfType = 5
	INO_EXT_TYPE_RESERVED_6        xfType = 6
	INO_EXT_TYPE_FINDER_INFO       xfType = 7
	INO_EXT_TYPE_DSTREAM           xfType = 8
	INO_EXT_TYPE_RESERVED_9        xfType = 9
	INO_EXT_TYPE_DIR_STATS_KEY     xfType = 10
	INO_EXT_TYPE_FS_UUID           xfType = 11
	INO_EXT_TYPE_RESERVED_12       xfType = 12
	INO_EXT_TYPE_SPARSE_BYTES      xfType = 13
	INO_EXT_TYPE_RDEV              xfType = 14
	INO_EXT_TYPE_PURGEABLE_FLAGS   xfType = 15
	INO_EXT_TYPE_ORIG_SYNC_ROOT_ID xfType = 16

	/** Extended-Field Flags **/
	XF_DATA_DEPENDENT   xfFlag = 0x0001
	XF_DO_NOT_COPY      xfFlag = 0x0002
	XF_RESERVED_4       xfFlag = 0x0004
	XF_CHILDREN_INHERIT xfFlag = 0x0008
	XF_USER_FIELD       xfFlag = 0x0010
	XF_SYSTEM_FIELD     xfFlag = 0x0020
	XF_RESERVED_40      xfFlag = 0x0040
	XF_RESERVED_80      xfFlag = 0x0080
)
View Source
const (
	APFS_FILE_INFO_DATA_HASH j_obj_file_info_type = 1
)
View Source
const APFS_KEYBAG_VERSION = 2
View Source
const APFS_MODIFIED_NAMELEN = 32
View Source
const APFS_SEAL_BROKEN = (1 << 0)

* Integrity Metadata Flags *

View Source
const BTREE_NODE_HASH_SIZE_MAX = 64
View Source
const CHECKPOINT_MAP_LAST cpMapFlag = 0x00000001

* Checkpoint Flags *

View Source
const CP_MAX_WRAPPEDKEYSIZE = 128
View Source
const FSROOT_OID = 2
View Source
const SM_DATAZONE_ALLOCZONE_COUNT = 8
View Source
const (
	SNAP_META_PENDING_DATALESS snap_meta_flags = 0x00000001
)

Variables

View Source
var BLOCK_SIZE uint64
View Source
var DirColor = color.New(color.Bold, color.FgHiBlue).SprintFunc()
View Source
var ErrBadBlockChecksum = errors.New("block failed checksum validation")
View Source
var NameColor = color.New(color.Bold, color.FgHiBlue).SprintFunc()
View Source
var TypeColor = color.New(color.Bold, color.FgHiYellow).SprintFunc()

Functions

func CreateChecksum

func CreateChecksum(data []byte) uint64

func VerifyChecksum

func VerifyChecksum(data []byte) bool

Types

type ApfsReapState added in v1.0.7

type ApfsReapState struct {
	LastPbn    uint64
	CurSnapXid XidT
	Phase      uint32
}

ApfsReapState is a apfs_reap_state_t struct

type ApfsSuperblock

type ApfsSuperblock struct {
	ApfsSuperblockT

	OMap          *Obj
	ExtentRefTree *Obj
	SnapMetaTree  *Obj
	// contains filtered or unexported fields
}

type ApfsSuperblockT

type ApfsSuperblockT struct {
	Magic   magic
	FsIndex uint32

	Features                   optVolFeatFlag
	ReadonlyCompatibleFeatures uint64
	IncompatibleFeatures       incompatVolFeatFlag

	UnmountTime EpochTime

	FsReserveBlockCount uint64
	FsQuotaBlockCount   uint64
	FsAllocCount        uint64

	MetaCrypto wrapped_meta_crypto_state_t

	RootTreeType      objType
	ExtentRefTreeType objType
	SnapMetaTreeType  objType

	OmapOid          OidT
	RootTreeOid      OidT
	ExtentrefTreeOid OidT
	SnapMetaTreeOid  OidT

	RevertToXid       XidT
	RevertToSblockOid OidT

	NextObjID uint64

	NumFiles          uint64
	NumDirectories    uint64
	NumSymlinks       uint64
	NumOtherFsobjects uint64
	NumSnapshots      uint64

	TotalBlockAlloced uint64
	TotalBlocksFreed  uint64

	VolumeUUID  UUID
	LastModTime EpochTime

	FsFlags volFlag

	FormattedBy apfs_modified_by_t
	ModifiedBy  [APFS_MAX_HIST]apfs_modified_by_t

	VolumeName [APFS_VOLNAME_LEN]byte
	NextDocID  uint32

	Role     volRole
	Reserved uint16

	RootToXid  XidT
	ErStateOid OidT

	// Fields supported on macOS 10.13.3+
	CloneinfoIDEpoch EpochTime
	CloneinfoXid     uint64

	// Fields supported on macOS 10.15+
	SnapMetaExtOid OidT
	VolumeGroupID  UUID

	// Fields supported on macOS 11+
	IntegrityMetaOid OidT
	FextTreeOid      OidT
	FextTreeType     objType

	ReservedType uint32
	ReservedOid  OidT
}

ApfsSuperblockT is a apfs_superblock_t struct

type BTreeInfoFixedT

type BTreeInfoFixedT struct {
	Flags    btreeInfoFixedFlags
	NodeSize uint32
	KeySize  uint32
	ValSize  uint32
}

BTreeInfoFixedT is a btree_info_fixed_t struct

type BTreeInfoT

type BTreeInfoT struct {
	Fixed      BTreeInfoFixedT
	LongestKey uint32
	LongestVal uint32
	KeyCount   uint64
	NodeCount  uint64
}

BTreeInfoT is a btree_info_t struct

type BTreeNodeIndexNodeValT

type BTreeNodeIndexNodeValT struct {
	ChildOid  OidT
	ChildHash [32]byte //BTREE_NODE_HASH_SIZE_MAX=64 acc to spec, but in reality appears to be max size of hash type used! 32 seen // FIXME: what?

}

BTreeNodeIndexNodeValT is a btn_index_node_val_t

func (BTreeNodeIndexNodeValT) String

func (v BTreeNodeIndexNodeValT) String() string

type BTreeNodePhys

type BTreeNodePhys struct {
	BTreeNodePhysT
	Entries []interface{}
	Parent  *BTreeNodePhys
	Info    *BTreeInfoT
	// contains filtered or unexported fields
}

BTreeNodePhys is a btree_node_phys_t struct with data array

func (*BTreeNodePhys) FixedKvSize

func (n *BTreeNodePhys) FixedKvSize() bool

func (*BTreeNodePhys) GetFSRecordsForOid

func (n *BTreeNodePhys) GetFSRecordsForOid(r io.ReaderAt, volFsRootNode BTreeNodePhys, oid OidT, maxXid XidT) (FSRecords, error)

GetFSRecordsForOid returns an array of all the file-system records with a given Virtual OID from a given file-system root tree.

func (*BTreeNodePhys) GetOMapEntry

func (n *BTreeNodePhys) GetOMapEntry(r io.ReaderAt, oid OidT, maxXid XidT) (*OMapNodeEntry, error)

GetOMapEntry returns the omap entry for a given oid

func (*BTreeNodePhys) Hashed

func (n *BTreeNodePhys) Hashed() bool

func (*BTreeNodePhys) IsLeaf

func (n *BTreeNodePhys) IsLeaf() bool

func (*BTreeNodePhys) IsRoot

func (n *BTreeNodePhys) IsRoot() bool

func (*BTreeNodePhys) ReadFextNodeEntry

func (n *BTreeNodePhys) ReadFextNodeEntry(r *bytes.Reader) error

ReadFextNodeEntry reads a fext node entry from reader

func (*BTreeNodePhys) ReadNodeEntry

func (n *BTreeNodePhys) ReadNodeEntry(r *bytes.Reader) error

ReadNodeEntry reads a node entry from reader

func (*BTreeNodePhys) ReadOMapNodeEntry

func (n *BTreeNodePhys) ReadOMapNodeEntry(r *bytes.Reader) error

ReadOMapNodeEntry reads a omap node entry from reader

func (*BTreeNodePhys) ReadSpacemanFreeQueueNodeEntry

func (n *BTreeNodePhys) ReadSpacemanFreeQueueNodeEntry(r *bytes.Reader) error

ReadSpacemanFreeQueueNodeEntry reads a spaceman free queue node entry from reader

type BTreeNodePhysT

type BTreeNodePhysT struct {
	// Obj         ObjPhysT
	Flags       btreeNodeFlag
	Level       uint16
	Nkeys       uint32
	TableSpace  nloc_t
	FreeSpace   nloc_t
	KeyFreeList nloc_t
	ValFreeList nloc_t
}

BTreeNodePhysT is a btree_node_phys_t struct

type CheckpointDesc

type CheckpointDesc struct {
	Obj  ObjPhysT
	Body interface{}
}

type CheckpointMapPhys

type CheckpointMapPhys struct {
	Hdr CheckpointMapPhysT
	Map []CheckpointMappingT
}

type CheckpointMapPhysT

type CheckpointMapPhysT struct {
	// Obj   ObjPhysT
	Flags cpMapFlag
	Count uint32
}

type CheckpointMappingT

type CheckpointMappingT struct {
	Type    objType
	SubType objType
	Size    uint32
	Pad     uint32
	FsOid   OidT
	Oid     OidT
	Paddr   OidT
}

type CmpfEnd

type CmpfEnd struct {
	Unk1  uint16
	Unk2  uint16
	Unk3  uint16
	Magic magic
	Flags uint32
	Size  uint64
	Unk4  uint32
	// contains filtered or unexported fields
}

type CmpfRsrc

type CmpfRsrc struct {
	EntryCount uint32
	Entries    [32]cmpfRsrcBlock
}

type CmpfRsrcBlockHead

type CmpfRsrcBlockHead struct {
	DataSize  uint32
	NumBlocks uint32
	Blocks    []cmpfRsrcBlock
}

type CmpfRsrcHead

type CmpfRsrcHead struct {
	HeaderSize uint32
	TotalSize  uint32
	DataSize   uint32
	Flags      uint32
}

CmpfRsrcHead (fields are big-endian)

type DecmpfsDiskHeader

type DecmpfsDiskHeader struct {
	AttrBytes []byte
	// contains filtered or unexported fields
}

DecmpfsDiskHeader this structure represents the xattr on disk; the fields below are little-endian

func GetDecmpfsHeader

func GetDecmpfsHeader(ne NodeEntry) (*DecmpfsDiskHeader, error)

GetDecmpfsHeader parses the decmpfs header from an xattr node entry

func (*DecmpfsDiskHeader) DecompressFile added in v1.0.6

func (h *DecmpfsDiskHeader) DecompressFile(r io.ReaderAt, decomp *bufio.Writer, fexts []FileExtent, nobar bool) (err error)

DecompressFile decompresses decmpfs data

func (DecmpfsDiskHeader) String

func (h DecmpfsDiskHeader) String() string

type DecmpfsHeader

type DecmpfsHeader struct {
	AttrSize         uint32
	Magic            magic
	CompressionType  uint32
	UncompressedSize uint64
	AttrBytes        [0]byte
}

DecmpfsHeader this structure represents the xattr in memory; the fields below are host-endian

type EfiJumpstart added in v1.0.7

type EfiJumpstart struct {
	NxEfiJumpstartT
	RecExtents []prange // The locations where the EFI driver is stored.
}

EfiJumpstart is a nx_efi_jumpstart struct

type EpochTime

type EpochTime uint64

func (EpochTime) String

func (e EpochTime) String() string

type ErRecoveryBlockPhys added in v1.0.7

type ErRecoveryBlockPhys struct {
	ErRecoveryBlockPhysT
	Data []byte
}

ErRecoveryBlockPhys is a er_recovery_block_physstruct

type ErRecoveryBlockPhysT added in v1.0.7

type ErRecoveryBlockPhysT struct {
	Obj     ObjPhysT
	Offset  uint64
	NextOid OidT
}

ErRecoveryBlockPhysT is a er_recovery_block_phys_t struct

type ErStatePhys added in v1.0.7

type ErStatePhys struct {
	Header               ErStatePhysHeader
	Flags                uint64
	SnapXid              uint64
	CurrentFextObjID     uint64
	FileOffset           uint64
	Progress             uint64
	TotalBlkToEncrypt    uint64
	BlockmapOid          OidT
	TidemarkObjID        uint64
	RecoveryExtentsCount uint64
	RecoveryListOid      OidT
	RecoveryLength       uint64
}

ErStatePhys is a er_state_phys_t struct

type ErStatePhysHeader added in v1.0.7

type ErStatePhysHeader struct {
	Obj     ObjPhysT
	Magic   magic
	Version uint32
}

ErStatePhysHeader is a er_state_phys_header_t struct

type ErStatePhysV1 added in v1.0.7

type ErStatePhysV1 struct {
	ErStatePhysV1T
	Checksum []byte
}

ErStatePhysV1 is a er_state_phys (v1) struct

type ErStatePhysV1T added in v1.0.7

type ErStatePhysV1T struct {
	Header            ErStatePhysHeader
	Flags             uint64
	SnapXid           uint64
	CurrentFextObjID  uint64
	FileOffset        uint64
	FextPbn           uint64
	Paddr             uint64
	Progress          uint64
	TotalBlkToEncrypt uint64
	BlockmapOid       uint64
	ChecksumCount     uint64
	Reserved          uint64
	FextCid           uint64
}

ErStatePhysV1T is a er_state_phys_v1_t struct

type EvictMappingValT

type EvictMappingValT struct {
	DstPaddr uint64
	Len      uint64

} // __attribute__((packed))

type FSRecords

type FSRecords []NodeEntry

FSRecords are an array of file system records

func (FSRecords) String

func (recs FSRecords) String() string

func (FSRecords) Tree

func (recs FSRecords) Tree() FSTree

Tree prints a FSRecords array as a tree

type FSTree

type FSTree interface {
	Add(text string) FSTree
	AddTree(tree FSTree)
	Items() []FSTree
	Text() string
	Print() string
}

FSTree file system tree - credit: https://github.com/d6o/GoTree

func NewFSTree

func NewFSTree(text string) FSTree

NewFSTree returns a new FSTree

type FextNodeEntry

type FextNodeEntry struct {
	Offset interface{}
	Key    fext_tree_key_t
	Val    fext_tree_val_t
}

func (FextNodeEntry) String

func (f FextNodeEntry) String() string

type FileExtent added in v1.0.13

type FileExtent struct {
	Address uint64
	Block   uint64
	Length  uint64
}

type FusionMtKey added in v1.0.7

type FusionMtKey paddr_t

type FusionMtVal added in v1.0.7

type FusionMtVal struct {
	Lba    paddr_t
	Length uint32
	Flags  uint32
}

FusionMtVal is a fusion_mt_val_t struct

type FusionWbcListEntry added in v1.0.7

type FusionWbcListEntry struct {
	WbcLba    paddr_t
	TargetLba paddr_t
	Length    uint64
}

FusionWbcListEntry is a fusion_wbc_list_entry_t struct

type FusionWbcListPhys added in v1.0.7

type FusionWbcListPhys struct {
	FusionWbcListPhysT
	ListEntries []FusionWbcListEntry
}

FusionWbcListPhys is a fusion_wbc_list_phys struct

type FusionWbcListPhysT added in v1.0.7

type FusionWbcListPhysT struct {
	ObjHdr     ObjPhysT
	Version    uint64
	TailOffset uint64
	IndexBegin uint32
	IndexEnd   uint32
	IndexMax   uint32
	Reserved   uint32
}

FusionWbcListPhysT is a fusion_wbc_list_phys_t struct

type FusionWbcPhys added in v1.0.7

type FusionWbcPhys struct {
	ObjHdr           ObjPhysT
	Version          uint64
	ListHeadOid      OidT
	ListTailOid      OidT
	StableHeadOffset uint64
	StableTailOffset uint64
	ListBlocksCount  uint32
	Reserved         uint32
	UsedByRc         uint64
	RcStash          prange
}

FusionWbcPhys is a fusion_wbc_phys_t struct

type GbitmapBlockPhys added in v1.0.7

type GbitmapBlockPhys struct {
	GbitmapBlockPhysT
	Field []uint64
}

GbitmapBlockPhys is a gbitmap_block_phys

type GbitmapBlockPhysT added in v1.0.7

type GbitmapBlockPhysT struct {
	Obj ObjPhysT
}

GbitmapBlockPhysT is a gbitmap_block_phys_t struct

type GbitmapPhys added in v1.0.7

type GbitmapPhys struct {
	Obj      ObjPhysT
	TreeOid  OidT
	BitCount uint64
	Flags    uint64
}

GbitmapPhys is a gbitmap_phys struct

type JDrecHashedKeyT

type JDrecHashedKeyT struct {
	// Hdr            JKeyT
	NameLenAndHash uint32
	Name           string

} // __attribute__((packed))

func (JDrecHashedKeyT) Hash

func (k JDrecHashedKeyT) Hash() uint32

func (JDrecHashedKeyT) Length

func (k JDrecHashedKeyT) Length() uint32

type JDrecVal

type JDrecVal struct {
	Xfields []Xfield
	// contains filtered or unexported fields
}

func (JDrecVal) String

func (v JDrecVal) String() string

type JDstreamT

type JDstreamT struct {
	Size              uint64
	AllocedSize       uint64
	DefaultCryptoID   uint64
	TotalBytesWritten uint64
	TotalBytesRead    uint64
}

func (JDstreamT) String

func (d JDstreamT) String() string

type JFileExtentKeyT added in v1.0.13

type JFileExtentKeyT struct {
	// Hdr         JKeyT
	LogicalAddr uint64
}

type JFileExtentValT added in v1.0.1

type JFileExtentValT struct {
	LenAndFlags  uint64
	PhysBlockNum uint64
	CryptoID     uint64
}

func (JFileExtentValT) Flags added in v1.0.1

func (v JFileExtentValT) Flags() uint64

func (JFileExtentValT) Length added in v1.0.1

func (v JFileExtentValT) Length() uint64

func (JFileExtentValT) String added in v1.0.1

func (v JFileExtentValT) String() string

type JInodeVal

type JInodeVal struct {
	Xfields []Xfield
	// contains filtered or unexported fields
}

func (JInodeVal) String

func (v JInodeVal) String() string

type JKeyT

type JKeyT struct {
	ObjIDAndType uint64

} // __attribute__((packed))

JKeyT is a j_key_t

func (JKeyT) GetID

func (j JKeyT) GetID() uint64

func (JKeyT) GetType

func (j JKeyT) GetType() j_obj_types

type JRecT

type JRecT struct {
	KeyLen uint16
	ValLen uint16
	Data   []byte
}

*

  • Custom data structure used to store a full file-system record (i.e. a single
  • key–value pair from a file-system root tree) alongside each other for easier
  • data access and manipulation. *
  • One can make use of an instance of this datatype by determining the strctures
  • contained within its `data` field by appealing to the `obj_id_and_type` field
  • of the `j_key_t` structure for the record, which is guaranteed to exist and
  • start at `data[0]`. That is, a pointer to this instance of `j_key_t` can be
  • obtained with `j_key_t* record_header = record->data`, where `record` is an
  • instance of this type, `j_rec_t`. *
  • key_len: Length of the file-system record's key-part, in bytes. *
  • val_len: Length of the file-system record's value-part, in bytes. *
  • data: Array of `key_len + val_len` bytes of data, of which,
  • index `0` through `key_len - 1` (inclusive) contain the
  • key-part data, and index `key_len` through `key_len + val_len - 1`
  • (inclusive) contain the value-part data.

type JXattrDstreamT added in v1.0.13

type JXattrDstreamT struct {
	XattrObjID uint64
	DStream    JDstreamT
}

func (JXattrDstreamT) String added in v1.0.13

func (d JXattrDstreamT) String() string

type JXattrKeyT added in v1.0.1

type JXattrKeyT struct {
	// Hdr     JKeyT
	NameLen uint16
	Name    string

} // __attribute__((packed))

type JXattrValT added in v1.0.1

type JXattrValT struct {
	Flags   j_xattr_flags // The extended attribute recordʼs flags.
	DataLen uint16        // The length of the extended attribute data.
	Data    interface{}   // The extended attribute data or the identifier of a data stream that contains the data.

} // __attribute__((packed))

func (JXattrValT) String added in v1.0.1

func (val JXattrValT) String() string

type KVLocT

type KVLocT struct {
	Key nloc_t
	Val nloc_t
}

KVLocT is a kvloc_t struct

type KVOffT

type KVOffT struct {
	Key uint16
	Val uint16
}

KVOffT is a kvoff_t struct

type NodeEntry

type NodeEntry struct {
	Offset interface{}
	Hdr    JKeyT
	Key    interface{}
	PAddr  uint64
	Val    interface{}
}

func (NodeEntry) String

func (ne NodeEntry) String() string

type NxEfiJumpstartT added in v1.0.7

type NxEfiJumpstartT struct {
	Obj        ObjPhysT   // The objectʼs header.
	Magic      magic      // A number that can be used to verify that youʼre reading an instance of nx_efi_jumpstart_t.
	Version    uint32     // The version of this data structure.
	EfiFileLen uint32     // The size, in bytes, of the embedded EFI driver.
	NumExtents uint32     // The number of extents in the array.
	Reserved   [16]uint64 // Reserved.

}

NxEfiJumpstartT is a nx_efi_jumpstart_t struct

type NxReapListPhysT added in v1.0.7

type NxReapListPhysT struct {
	Obj   ObjPhysT
	Next  OidT
	Flags uint32
	Max   uint32
	Count uint32
	First uint32
	Last  uint32
	Free  uint32
}

NxReapListPhysT is a nx_reap_list_phys_t struct

type NxReaperPhysT added in v1.0.7

type NxReaperPhysT struct {
	Obj             ObjPhysT
	NextReapID      uint64
	CompletedID     uint64
	Head            OidT
	Tail            OidT
	Flags           nrFlags
	RlCount         uint32
	Type            uint32 // TODO: this might be the "Volume Reaper States"
	Size            uint32
	FsOid           OidT
	Oid             OidT
	Xid             XidT
	NrleFlags       uint32
	StateBufferSize uint32
}

NxReaperPhysT is a nx_reaper_phys_t struct

type NxSuperblock

type NxSuperblock struct {
	NxSuperblockT

	OMap *Obj
	// contains filtered or unexported fields
}

type NxSuperblockT

type NxSuperblockT struct {
	// Obj        ObjPhysT
	Magic      magic
	BlockSize  uint32
	BlockCount uint64

	Features                   nxFeature
	ReadOnlyCompatibleFeatures uint64
	IncompatibleFeatures       nxIncompatFeature

	UUID UUID

	NextOid OidT
	NextXid XidT

	XpDescBlocks uint32
	XpDataBlocks uint32
	XpDescBase   uint64
	XpDataBase   uint64
	XpDescNext   uint32
	XpDataNext   uint32
	XpDescIndex  uint32
	XpDescLen    uint32
	XpDataIndex  uint32
	XpDataLen    uint32

	SpacemanOid OidT
	OmapOid     OidT
	ReaperOid   OidT

	TestType uint32

	MaxFileSystems      uint32
	FsOids              [NX_MAX_FILE_SYSTEMS]OidT
	Counters            [NX_NUM_COUNTERS]uint64
	BlockedOutPRange    prange
	EvictMappingTreeOid OidT
	Flags               nxContainerFlag
	EFIJumpstart        uint64
	FusionUUID          UUID
	Keylocker           prange
	EphemeralInfos      [NX_EPH_INFO_COUNT]uint64

	TestOid OidT

	FusionMtOid  OidT
	FusionWbcOid OidT
	FusionWbc    prange

	NewestMountedVersion uint64

	MkBLocker prange
}

NxSuperblockT nx_superblock_t struct

type OMap

type OMap struct {
	OMapPhysT

	Tree         *Obj
	SnapshotTree *Obj
	// contains filtered or unexported fields
}

type OMapEntry

type OMapEntry struct {
	Key OMapKey
	Val OMapVal
}

OMapEntry is a omap_entry_t struct Custom data structure used to store the key and value of an object map entry together.

type OMapKey

type OMapKey struct {
	Oid OidT
	Xid XidT
}

OMapKey is a omap_key_t struct

func (OMapKey) String

func (k OMapKey) String() string

type OMapNodeEntry

type OMapNodeEntry struct {
	Offset interface{}
	Key    OMapKey
	PAddr  uint64
	OMap   *Obj
	Val    OMapVal
}

func (OMapNodeEntry) String

func (one OMapNodeEntry) String() string

type OMapPhysT

type OMapPhysT struct {
	// Obj              ObjPhysT
	Flags            omapFlag
	SnapCount        uint32
	TreeType         objType
	SnapshotTreeType objType
	TreeOid          OidT
	SnapshotTreeOid  OidT
	MostRecentSnap   XidT
	PendingRevertMin XidT
	PendingRevertMax XidT
}

OMapPhysT is a omap_phys_t struct

type OMapSnapshotT

type OMapSnapshotT struct {
	Flags omapSnapshotFlag
	Pad   uint32
	Oid   OidT
}

OMapSnapshotT is a omap_snapshot_t

func (OMapSnapshotT) String

func (s OMapSnapshotT) String() string

type OMapVal

type OMapVal struct {
	Flags omapValFlag
	Size  uint32
	Paddr uint64
}

OMapVal is a omap_val_t struct

func (OMapVal) String

func (v OMapVal) String() string

type Obj

type Obj struct {
	Hdr  ObjPhysT
	Body interface{}
}

func ReadObj

func ReadObj(r io.ReaderAt, blockAddr uint64) (*Obj, error)

ReadObj returns a verified object or error if block does not verify

func (Obj) String

func (o Obj) String() string

type ObjPhysT

type ObjPhysT struct {
	Cksum   [MAX_CKSUM_SIZE]byte
	Oid     OidT
	Xid     XidT
	Type    objType
	Subtype objType
}

ObjPhysT is a obj_phys_t object

func (ObjPhysT) Checksum

func (o ObjPhysT) Checksum() uint64

func (ObjPhysT) GetFlag

func (o ObjPhysT) GetFlag() objFlag

func (ObjPhysT) GetSubType

func (o ObjPhysT) GetSubType() objType

func (ObjPhysT) GetType

func (o ObjPhysT) GetType() objType

type OidT

type OidT uint64

type OmapCleanupState added in v1.0.7

type OmapCleanupState struct {
	Cleaning  uint32  // A flag that indicates whether the structure has valid data in it.
	OmsFlags  uint32  // The flags for the snapshot being deleted.
	SxIDPrev  XidT    // The transaction identifier of the snapshot prior to the snapshots being deleted.
	SxIDStart XidT    // The transaction identifier of the first snapshot being deleted
	SxIDEnf   XidT    // The transaction identifier of the last snapshot being deleted.
	SxIDNext  XidT    // The transaction identifier of the snapshot after the snapshots being deleted.
	CurKey    OMapKey // The key of the next object mapping to consider for deletion.
}

OmapCleanupState is a omap_cleanup_state_t struct

type OmapReapState added in v1.0.7

type OmapReapState struct {
	Phase omapReapPhase // The current reaping phase.
	Ok    OMapKey       // The key of the most recently freed entry in the object map.
}

OmapReapState is a omap_reap_state_t struct

type Printer

type Printer interface {
	Print(FSTree) string
}

Printer is printer interface

type ReapListEntry added in v1.0.7

type ReapListEntry struct {
	Next  uint32
	Flags rlFlags
	Type  uint32
	Size  uint32
	FsOid OidT
	Oid   OidT
	Xid   XidT
}

ReapListEntry is a nx_reap_list_entry_t struct

type ReapListPhys added in v1.0.7

type ReapListPhys struct {
	NxReapListPhysT
	Entries []ReapListEntry
}

ReapListPhys is a nx_reap_list_phys struct

type ReaperPhys added in v1.0.7

type ReaperPhys struct {
	NxReaperPhysT
	StateBuffer []uint8
}

ReaperPhys is a nx_reaper_phys struct

type RegFile

type RegFile struct {
	Name       string
	Owner      uid_t
	Group      gid_t
	Mode       mode_t
	CreateTime EpochTime
	Size       uint64
}

func (RegFile) String

func (f RegFile) String() string

type SiblingKeyT

type SiblingKeyT struct {
	// Hdr       JKeyT
	SiblingID uint64

} // __attribute__((packed))

SiblingKeyT is a j_sibling_key_t object

type SiblingMapKeyT

type SiblingMapKeyT struct {
	Hdr JKeyT

} // __attribute__((packed))

SiblingMapKeyT is a j_sibling_map_key_t object

type SiblingMapValT

type SiblingMapValT struct {
	FileID uint64

} // __attribute__((packed))

SiblingMapValT is a j_sibling_map_val_t object

func (SiblingMapValT) String

func (v SiblingMapValT) String() string

type SiblingValT

type SiblingValT struct {
	ParentID uint64
	NameLen  uint16
	Name     string

} // __attribute__((packed))

SiblingValT is a j_sibling_val_t object

func (SiblingValT) String

func (v SiblingValT) String() string

type SpacemanFreeQueueNodeEntry

type SpacemanFreeQueueNodeEntry struct {
	Offset interface{}
	Key    spaceman_free_queue_key_t
	Val    spaceman_free_queue_val_t
}

func (SpacemanFreeQueueNodeEntry) String

type UUID added in v1.0.2

type UUID [16]byte

UUID is a uuid object

func (UUID) IsNull added in v1.0.2

func (u UUID) IsNull() bool

IsNull returns true if UUID is 00000000-0000-0000-0000-000000000000

func (UUID) String added in v1.0.2

func (u UUID) String() string

type Xfield

type Xfield struct {
	Field interface{}
	// contains filtered or unexported fields
}

func (Xfield) String

func (f Xfield) String() string

type XidT

type XidT uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL