wip: getgr_max and getpw_max
This commit is contained in:
parent
130aea7cf5
commit
71f5284399
@ -119,6 +119,8 @@ pub fn fromCorpus(
|
||||
.nblocks_users = nblocks(u64, users.blob),
|
||||
.nblocks_groupmembers = nblocks(u64, groupmembers.blob),
|
||||
.nblocks_additional_gids = nblocks(u64, additional_gids.blob),
|
||||
.getgr_max = 0,
|
||||
.getpw_max = 0,
|
||||
};
|
||||
|
||||
return DB{
|
||||
@ -628,6 +630,7 @@ test "high-level API" {
|
||||
|
||||
var arena = ArenaAllocator.init(allocator);
|
||||
defer arena.deinit();
|
||||
// TODO: should accept a buffer instead of an allocator instead.
|
||||
const all = try db.getgrnam(arena.allocator(), "all");
|
||||
try testing.expect(all != null);
|
||||
try testing.expectEqual(all.?.gid, 9999);
|
||||
|
@ -44,6 +44,9 @@ pub const Header = packed struct {
|
||||
nblocks_users: u64,
|
||||
nblocks_groupmembers: u64,
|
||||
nblocks_additional_gids: u64,
|
||||
getgr_max: u64,
|
||||
getpw_max: u64,
|
||||
padding: [48]u8 = [1]u8{0} ** 48,
|
||||
|
||||
pub fn fromBytes(blob: *const [@sizeOf(Header)]u8) Invalid!*const Header {
|
||||
const self = mem.bytesAsValue(Header, blob);
|
||||
@ -67,8 +70,8 @@ test "Section length is a power of two" {
|
||||
try testing.expect(std.math.isPowerOfTwo(section_length));
|
||||
}
|
||||
|
||||
test "Header fits into a section" {
|
||||
try testing.expect(@sizeOf(Header) <= section_length);
|
||||
test "Header fits into two section" {
|
||||
try testing.expect(@sizeOf(Header) == 2 * section_length);
|
||||
}
|
||||
|
||||
test "bit header size is equal to @sizeOf(Header)" {
|
||||
@ -89,6 +92,8 @@ test "header pack and unpack" {
|
||||
.nblocks_users = 0,
|
||||
.nblocks_groupmembers = 0,
|
||||
.nblocks_additional_gids = 1,
|
||||
.getgr_max = 0,
|
||||
.getpw_max = 0,
|
||||
};
|
||||
|
||||
const bytes = mem.asBytes(&header1);
|
||||
|
Loading…
Reference in New Issue
Block a user