remove redundant sections

This commit is contained in:
Motiejus Jakštys 2022-03-13 14:22:49 +02:00 committed by Motiejus Jakštys
parent 3b2f135d5c
commit 2c4e61d0ed
2 changed files with 18 additions and 13 deletions

View File

@ -357,11 +357,11 @@ bdz_gid ? bdz(gid)
bdz_groupname ? bdz(groupname) bdz_groupname ? bdz(groupname)
bdz_uid ? bdz(uid) bdz_uid ? bdz(uid)
bdz_username ? bdz(username) bdz_username ? bdz(username)
idx_gid2group len(group)*29/8 bdz->offset Groups idx_gid2group len(group)*4 bdz->offset Groups
idx_groupname2group len(group)*29/8 bdz->offset Groups idx_groupname2group len(group)*4 bdz->offset Groups
idx_uid2user len(user)*29/8 bdz->offset Users idx_uid2user len(user)*4 bdz->offset Users
idx_name2user len(user)*29/8 bdz->offset Users idx_name2user len(user)*4 bdz->offset Users
idx_username2gids len(user)*29/8 bdz->offset UserGids idx_username2gids len(user)*4 bdz->offset UserGids
shellIndex len(shells)*2 shell index array shellIndex len(shells)*2 shell index array
shellBlob <= 4032 shell data blob (max 63*64 bytes) shellBlob <= 4032 shell data blob (max 63*64 bytes)
groups ? packed Group entries (8b padding) groups ? packed Group entries (8b padding)

View File

@ -22,6 +22,7 @@ const bdz = @import("bdz.zig");
const User = userImport.User; const User = userImport.User;
const Group = groupImport.Group; const Group = groupImport.Group;
const ShellSections = shellImport.ShellWriter.ShellSections; const ShellSections = shellImport.ShellWriter.ShellSections;
const ShellReader = shellImport.ShellReader;
const Corpus = struct { const Corpus = struct {
arena: std.heap.ArenaAllocator, arena: std.heap.ArenaAllocator,
@ -391,8 +392,7 @@ pub const AllSections = struct {
bdz_username: []const u8, bdz_username: []const u8,
users: UsersSection, users: UsersSection,
shell_sections: ShellSections, shell_sections: ShellSections,
shell_index: []const u8, shell_reader: ShellReader,
shell_blob: []const u8,
user_gids: UserGids, user_gids: UserGids,
group_members: GroupMembers, group_members: GroupMembers,
groups: GroupsSection, groups: GroupsSection,
@ -406,8 +406,6 @@ pub const AllSections = struct {
const bdz_uid = try bdzUid(allocator, corpus); const bdz_uid = try bdzUid(allocator, corpus);
const bdz_username = try bdzUsername(allocator, corpus); const bdz_username = try bdzUsername(allocator, corpus);
const shell_sections = try shellSections(allocator, corpus); const shell_sections = try shellSections(allocator, corpus);
const shell_index = shell_sections.index;
const shell_blob = shell_sections.blob;
const user_gids = try userGids(allocator, corpus); const user_gids = try userGids(allocator, corpus);
const users = try usersSection( const users = try usersSection(
allocator, allocator,
@ -425,6 +423,11 @@ pub const AllSections = struct {
corpus, corpus,
group_members.idx2offset, group_members.idx2offset,
); );
const shell_reader = shellImport.ShellReader.init(
mem.sliceAsBytes(shell_sections.index.constSlice()),
mem.sliceAsBytes(shell_sections.blob.constSlice()),
);
return AllSections{ return AllSections{
.allocator = allocator, .allocator = allocator,
.bdz_gid = bdz_gid, .bdz_gid = bdz_gid,
@ -432,8 +435,7 @@ pub const AllSections = struct {
.bdz_uid = bdz_uid, .bdz_uid = bdz_uid,
.bdz_username = bdz_username, .bdz_username = bdz_username,
.shell_sections = shell_sections, .shell_sections = shell_sections,
.shell_index = mem.sliceAsBytes(shell_index.constSlice()), .shell_reader = shell_reader,
.shell_blob = mem.sliceAsBytes(shell_blob.constSlice()),
.user_gids = user_gids, .user_gids = user_gids,
.users = users, .users = users,
.group_members = group_members, .group_members = group_members,
@ -583,8 +585,11 @@ test "test groups and group members" {
try testing.expectEqual(it.next(), null); try testing.expectEqual(it.next(), null);
} }
//var it = userImport.PackedUserHash.iterator(sections.groups.blob); var it = userImport.PackedUser.iterator(
//_ = it; sections.users.blob,
sections.shell_reader,
);
_ = it;
} }
test "userGids" { test "userGids" {