跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

types.go

126 行 · 3.4 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4// Package apfs provides minimal APFS disk image manipulation.
5// It reads on-disk structures at known byte offsets per the Apple APFS
6// Reference and modifies inode UID/GID fields directly, bypassing
7// the kernel VFS.
8package apfs
9
10// Magic numbers.
11const (
12 nxMagic = 0x4253584E // "NXSB"
13 apfsMagic = 0x42535041 // "APSB"
14)
15
16// Object types (lower 16 bits of o_type).
17const (
18 objectTypeNXSuperblock = 0x01
19 objectTypeCheckpointMap = 0x0C
20 objectTypeOmap = 0x0B
21 objectTypeBTreeNode = 0x02
22 objectTypeFS = 0x0D
23 objectTypeFSTree = 0x0E
24 objectTypeBlockRefTree = 0x0F
25 objectTypeOmapSnapshot = 0x10
26 objectTypeNXReaperFS = 0x12
27 objectTypeNXReaperListKey = 0x13
28)
29
30// Object storage classes (upper 16 bits of o_type, shifted).
31const (
32 objPhysical = 0x00000000
33 objEphemeral = 0x80000000
34 objVirtual = 0x00000000
35 objTypeMask = 0x0000FFFF
36 objFlagsMask = 0xFFFF0000
37)
38
39// B-tree node flags.
40const (
41 btnodeRoot = 0x0001
42 btnodeLeaf = 0x0002
43 btnodeFixedKVSize = 0x0004
44)
45
46// Filesystem object types (upper 4 bits of j_key_t.obj_id_and_type).
47const (
48 apfsTypeInode = 3
49 apfsTypeDirRec = 9
50)
51
52// Filesystem key masks.
53const (
54 objIDMask = 0x0FFFFFFFFFFFFFFF
55 objTypeShift = 60
56)
57
58// Well-known inode numbers.
59const (
60 rootDirInodeNum = 2
61)
62
63// noownersPlaceholderID is the on-disk UID and GID that APFS stores
64// for files on volumes mounted with the noowners option.
65const noownersPlaceholderID = 99
66
67// VolRoleData is the APFS volume role for "Data" volumes.
68const VolRoleData = 0x0040 // APFS_VOL_ROLE_DATA (shifted representation: (1 << 2) << 4)
69
70// Container superblock (nx_superblock_t) field offsets from block start.
71const (
72 nxMagicOff = 32 // uint32
73 nxBlockSizeOff = 36 // uint32
74 nxXPDescBlocksOff = 104 // uint32 (mask 0x7FFFFFFF for count)
75 nxXPDescBaseOff = 112 // uint64 (physical block address)
76 nxXPDescIndexOff = 136 // uint32
77 nxXPDescLenOff = 140 // uint32
78 nxOmapOIDOff = 160 // uint64 (physical)
79 nxFSOIDOff = 184 // uint64[100] (virtual OIDs)
80 nxMaxFileSystems = 100
81 nxXPDescBlocksMask = 0x7FFFFFFF
82)
83
84// Object header (obj_phys_t) field offsets.
85const (
86 objChecksumOff = 0 // uint64
87 objOIDOff = 8 // uint64
88 objXIDOff = 16 // uint64
89 objTypeOff = 24 // uint32
90 objSubtypeOff = 28 // uint32
91 objHeaderSize = 32
92)
93
94// Volume superblock (apfs_superblock_t) field offsets from block start.
95const (
96 apfsMagicOff = 32 // uint32
97 apfsOmapOIDOff = 128 // uint64 (physical)
98 apfsRootTreeOIDOff = 136 // uint64 (virtual)
99 apfsVolNameOff = 704 // 256 bytes UTF-8
100 apfsRoleOff = 964 // uint16
101)
102
103// Object map (omap_phys_t) field offsets from block start.
104const (
105 omapTreeOIDOff = 48 // uint64 (physical)
106)
107
108// B-tree node (btree_node_phys_t) field offsets from block start.
109const (
110 btnFlagsOff = 32 // uint16
111 btnLevelOff = 34 // uint16
112 btnNKeysOff = 36 // uint32
113 btnTableSpaceOff = 40 // nloc_t: off uint16 + len uint16
114 btnDataOff = 56 // start of btn_data[]
115)
116
117// btree_info_t size (sits at end of root node block).
118const btreeInfoSize = 40
119
120// j_inode_val_t field offsets (from start of value data).
121const (
122 inodeParentIDOff = 0 // uint64
123 inodePrivateIDOff = 8 // uint64
124 inodeOwnerOff = 72 // uint32
125 inodeGroupOff = 76 // uint32
126)