Skip to content

Commit 6e7371a

Browse files
committed
Sync apfs_raw.h with the fsck again
I've recently noticed a number of new flags and added them to the fsck. I heven't quite figured out most of them yet, but copy the information here anyway. Also add checks for the new incompatible features, so that they don't get accepted by default. Signed-off-by: Ernesto A. Fernández <[email protected]>
1 parent 2a10ca6 commit 6e7371a

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

apfs_raw.h

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ struct apfs_phys_ext_val {
268268
#define APFS_FILE_EXTENT_LEN_MASK 0x00ffffffffffffffULL
269269
#define APFS_FILE_EXTENT_FLAG_MASK 0xff00000000000000ULL
270270
#define APFS_FILE_EXTENT_FLAG_SHIFT 56
271+
#define APFS_FILE_EXTENT_CRYPTO_FLAG 0x01 /* Made-up name */
272+
#define APFS_FILE_EXTENT_PREALLOCATED 0x02 /* Made-up name */
273+
#define APFS_VALID_FILE_EXTENT_FLAGS (APFS_FILE_EXTENT_CRYPTO_FLAG \
274+
| APFS_FILE_EXTENT_PREALLOCATED)
271275

272276
/*
273277
* Put a bound on maximum file size so that a growing truncation will always
@@ -1051,13 +1055,19 @@ struct apfs_checkpoint_map_phys {
10511055
#define APFS_FS_SPILLEDOVER 0x00000010LL
10521056
#define APFS_FS_RUN_SPILLOVER_CLEANER 0x00000020LL
10531057
#define APFS_FS_ALWAYS_CHECK_EXTENTREF 0x00000040LL
1058+
#define APFS_FS_PREVIOUSLY_SEALED 0x00000080LL /* Made-up name */
1059+
#define APFS_FS_PFK 0x00000100LL /* Made-up name */
1060+
#define APFS_FS_UNKNOWN_200 0x00000200LL
10541061
#define APFS_FS_FLAGS_VALID_MASK (APFS_FS_UNENCRYPTED \
1055-
| APFS_FS_EFFACEABLE \
1056-
| APFS_FS_RESERVED_4 \
1057-
| APFS_FS_ONEKEY \
1058-
| APFS_FS_SPILLEDOVER \
1059-
| APFS_FS_RUN_SPILLOVER_CLEANER \
1060-
| APFS_FS_ALWAYS_CHECK_EXTENTREF)
1062+
| APFS_FS_EFFACEABLE \
1063+
| APFS_FS_RESERVED_4 \
1064+
| APFS_FS_ONEKEY \
1065+
| APFS_FS_SPILLEDOVER \
1066+
| APFS_FS_RUN_SPILLOVER_CLEANER \
1067+
| APFS_FS_ALWAYS_CHECK_EXTENTREF \
1068+
| APFS_FS_PREVIOUSLY_SEALED \
1069+
| APFS_FS_PFK \
1070+
| APFS_FS_UNKNOWN_200)
10611071

10621072
#define APFS_FS_CRYPTOFLAGS (APFS_FS_UNENCRYPTED \
10631073
| APFS_FS_EFFACEABLE \
@@ -1124,15 +1134,19 @@ struct apfs_checkpoint_map_phys {
11241134
#define APFS_INCOMPAT_NORMALIZATION_INSENSITIVE 0x00000008LL
11251135
#define APFS_INCOMPAT_INCOMPLETE_RESTORE 0x00000010LL
11261136
#define APFS_INCOMPAT_SEALED_VOLUME 0x00000020LL
1127-
#define APFS_INCOMPAT_RESERVED_40 0x00000040LL
1137+
#define APFS_INCOMPAT_PFK 0x00000040LL /* Made-up name */
1138+
#define APFS_INCOMPAT_EXTENT_PREALLOC_FLAG 0x00000080LL /* Made-up name */
1139+
#define APFS_INCOMPAT_SECONDARY_FSROOT 0x00000100LL /* Made-up name */
11281140

11291141
#define APFS_SUPPORTED_INCOMPAT_MASK (APFS_INCOMPAT_CASE_INSENSITIVE \
11301142
| APFS_INCOMPAT_DATALESS_SNAPS \
11311143
| APFS_INCOMPAT_ENC_ROLLED \
11321144
| APFS_INCOMPAT_NORMALIZATION_INSENSITIVE \
11331145
| APFS_INCOMPAT_INCOMPLETE_RESTORE \
11341146
| APFS_INCOMPAT_SEALED_VOLUME \
1135-
| APFS_INCOMPAT_RESERVED_40)
1147+
| APFS_INCOMPAT_PFK \
1148+
| APFS_INCOMPAT_EXTENT_PREALLOC_FLAG \
1149+
| APFS_INCOMPAT_SECONDARY_FSROOT)
11361150

11371151
#define APFS_MODIFIED_NAMELEN 32
11381152

@@ -1162,6 +1176,18 @@ struct apfs_modified_by {
11621176
#define APFS_CRYPTO_RESERVED_5 5
11631177
#define APFS_UNASSIGNED_CRYPTO_ID (~0ULL)
11641178

1179+
/* Doc id index flags. I'm making up the names for now. */
1180+
#define APFS_DOC_ID_HAS_PREV_TREE 0x00000001
1181+
#define APFS_DOC_ID_UNKNOWN_02 0x00000002
1182+
#define APFS_DOC_ID_UNKNOWN_04 0x00000004
1183+
#define APFS_DOC_ID_UNKNOWN_08 0x00000008
1184+
#define APFS_DOC_ID_UNKNOWN_10 0x00000010
1185+
#define APFS_DOC_ID_VALID_FLAGS (APFS_DOC_ID_HAS_PREV_TREE \
1186+
| APFS_DOC_ID_UNKNOWN_02 \
1187+
| APFS_DOC_ID_UNKNOWN_04 \
1188+
| APFS_DOC_ID_UNKNOWN_08 \
1189+
| APFS_DOC_ID_UNKNOWN_10)
1190+
11651191
/*
11661192
* Structure used to store the encryption state
11671193
*/
@@ -1277,9 +1303,10 @@ enum {
12771303
APFS_XATTR_DATA_EMBEDDED = 0x00000002,
12781304
APFS_XATTR_FILE_SYSTEM_OWNED = 0x00000004,
12791305
APFS_XATTR_RESERVED_8 = 0x00000008,
1306+
APFS_XATTR_UNKNOWN_10 = 0x00000010,
12801307
};
12811308

1282-
#define APFS_XATTR_VALID_FLAGS 0x0000000f
1309+
#define APFS_XATTR_VALID_FLAGS 0x0000001f
12831310

12841311
/*
12851312
* Structure of the value of an extended attributes record

super.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,8 +1295,16 @@ static int apfs_check_vol_features(struct super_block *sb)
12951295
apfs_warn(sb, "incomplete restore is not supported");
12961296
return -EINVAL;
12971297
}
1298-
if (features & APFS_INCOMPAT_RESERVED_40) {
1299-
apfs_warn(sb, "reserved incompatible feature flag is set");
1298+
if (features & APFS_INCOMPAT_PFK) {
1299+
apfs_warn(sb, "PFK is not supported");
1300+
return -EINVAL;
1301+
}
1302+
if (features & APFS_INCOMPAT_EXTENT_PREALLOC_FLAG) {
1303+
apfs_warn(sb, "extent prealloc flag is not supported");
1304+
return -EINVAL;
1305+
}
1306+
if (features & APFS_INCOMPAT_SECONDARY_FSROOT) {
1307+
apfs_warn(sb, "secondary fsroot is not supported");
13001308
return -EINVAL;
13011309
}
13021310
if (features & APFS_INCOMPAT_SEALED_VOLUME) {

0 commit comments

Comments
 (0)