1
Fork 0

adding user

This commit is contained in:
Motiejus Jakštys 2022-02-18 17:34:50 +02:00 committed by Motiejus Jakštys
parent 411fb91fd1
commit 1fe23aa1e5
3 changed files with 21 additions and 27 deletions

View File

@ -2,4 +2,5 @@ test "turbonss test suite" {
_ = @import("main.zig"); _ = @import("main.zig");
_ = @import("shell.zig"); _ = @import("shell.zig");
_ = @import("header.zig"); _ = @import("header.zig");
_ = @import("user.zig");
} }

20
src/user.zig Normal file
View File

@ -0,0 +1,20 @@
const std = @import("std");
const PackedUserSize = @sizeOf(PackedUser);
const PackedUser = packed struct {
uid: u32,
gid: u32,
additional_gids_offset: u29,
shell_here: u1,
shell_len_or_place: u6,
homedir_len: u6,
username_is_a_suffix: u1,
username_offset_or_len: u5,
gecos_len: u8,
};
const testing = std.testing;
test "PackedUser is byte-aligned" {
//try testing.expectEqual(PackedUserSize * 8, @bitSizeOf(PackedUser));
}

View File

@ -1,34 +1,7 @@
const std = @import("std"); const std = @import("std");
const DB = struct {
users: std.StringHashMap(User),
groups: std.StringHashMap(Group),
};
const Group = struct { const Group = struct {
gid: u32, gid: u32,
name: []const u8, name: []const u8,
members: std.BufSet, members: std.BufSet,
}; };
const User = struct {
uid: u32,
gid: u32,
name: []const u8,
gecos: []const u8,
home: []const u8,
shell: []const u8,
groups: std.BufSet,
};
const PackedUser = packed struct {
uid: u32,
gid: u32,
additional_gids_offset: u29,
shell_here: u1,
shell_len_or_place: u6,
homedir_len: u6,
username_is_a_suffix: u1,
username_offset_or_len: u5,
gecos_len: u8,
};