1
Fork 0

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_uid ? bdz(uid)
bdz_username ? bdz(username)
idx_gid2group len(group)*29/8 bdz->offset Groups
idx_groupname2group len(group)*29/8 bdz->offset Groups
idx_uid2user len(user)*29/8 bdz->offset Users
idx_name2user len(user)*29/8 bdz->offset Users
idx_username2gids len(user)*29/8 bdz->offset UserGids
idx_gid2group len(group)*4 bdz->offset Groups
idx_groupname2group len(group)*4 bdz->offset Groups
idx_uid2user len(user)*4 bdz->offset Users
idx_name2user len(user)*4 bdz->offset Users
idx_username2gids len(user)*4 bdz->offset UserGids
shellIndex len(shells)*2 shell index array
shellBlob <= 4032 shell data blob (max 63*64 bytes)
groups ? packed Group entries (8b padding)

View File

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