1
Fork 0

document global structure better

main
Motiejus Jakštys 2022-02-13 10:42:40 +02:00 committed by Motiejus Jakštys
parent 0c33c27e56
commit b3446ef307
1 changed files with 31 additions and 34 deletions

View File

@ -71,49 +71,45 @@ CHM than with BDZ, eliminating the benefit of preserved ordering.
Full file structure Full file structure
------------------- -------------------
The file structure stars with magic and version number, followed by a list of The turbonss header looks like this:
User, Group records and their indices. All indices are number of bytes,
relative to the beginning of the file.
``` ```
const File = struct { OFFSET TYPE NAME DESCRIPTION
magic: [4]u8, 0 [4]u8 magic always 0xf09fa4b7
version: u4, 4 u8 version now `0`
padding: u4, 5 u2 padding
num_shells: u6, u6 num_shells see "SHELLS" section.
padding: u2, 6 u32 num_users number of passwd entries
num_users: u32, 10 u32 num_groups number of group entries
num_groups: u32, 14 u32 offset_cmph_gid2group
offset_cmph_gid2group: u26, 18 u32 offset_cmph_uid2user
offset_cmph_uid2user: u26, 22 u32 offset_cmph_groupname2group
offset_cmph_groupname2group: u26, 26 u32 offset_cmph_username2user
offset_cmph_username2user: u26, 30 u32 offset_sorted_groups
offset_sorted_groups: u26, 34 u32 offset_sorted_users
offset_sorted_users: u26, 38 u32 offset_groupmembers
offset_groupmembers: u26, 42 u32 offset_additional_gids
offset_additional_gids: u26,
}
``` ```
`magic` is 0xf09fa4b7, and `version` must be `0`. Offsets are indices to `magic` is 0xf09fa4b7, and `version` must be `0`. All integers are big-endian.
further sections of the file, with zero being the first block (the magic Offsets are indices to further sections of the file, with zero being the first
number). As all blobs are 64-byte aligned, the offsets are pointing to the block (the magic number). As all blobs are 64-byte aligned, the offsets are
beginning of the 64-byte "block" (thus u26). All numbers are little-endian. always pointing to the beginning of an 64-byte "block". Therefore, all
`offset_*` values could be `u26`. As `u32` is easier to visualize with xxd, and
As of writing the file header is 40 bytes. the File block fits to 64 bytes anyway, we are keeping them as u32 now.
Primitive types: Primitive types:
``` ```
const Group = struct { const Group = struct {
gid: u32, gid: u32,
// index to a separate structure with a list of members // index to a separate structure with a list of members. The memberlist is
members_offset: u29, // always 2^5-byte aligned, this is an index there.
padding: u3, members_offset: u27,
groupname_len: u8, groupname_len: u5,
// a variable-sized array that will be stored immediately after this // a groupname_len-sized string
// struct. groupname []u8;
stringdata []u8;
} }
const User = struct { const User = struct {
@ -125,7 +121,8 @@ const User = struct {
shell_here: u1, shell_here: u1,
shell_len_or_place: u6, shell_len_or_place: u6,
home_len: u6, home_len: u6,
username_len: u6, username_pos: u1,
username_len: u5,
gecos_len: u8, gecos_len: u8,
// a variable-sized array that will be stored immediately after this // a variable-sized array that will be stored immediately after this
// struct. // struct.