move CGroup to Group
This commit is contained in:
parent
be9bf3f51c
commit
9e80d6676b
@ -16,8 +16,8 @@ const pad = @import("padding.zig");
|
||||
const compress = @import("compress.zig");
|
||||
const PackedUser = @import("PackedUser.zig");
|
||||
const User = @import("User.zig");
|
||||
const CGroup = @import("cgroup.zig").CGroup;
|
||||
const Group = @import("Group.zig");
|
||||
const CGroup = Group.CGroup;
|
||||
const PackedGroup = @import("PackedGroup.zig");
|
||||
const GroupStored = PackedGroup.GroupStored;
|
||||
const ShellSections = @import("shell.zig").ShellWriter.ShellSections;
|
||||
|
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const ptr_size = @import("cgroup.zig").ptr_size;
|
||||
|
||||
const mem = std.mem;
|
||||
const meta = std.meta;
|
||||
@ -56,7 +55,8 @@ pub fn deinit(self: *Group, allocator: Allocator) void {
|
||||
self.* = undefined;
|
||||
}
|
||||
|
||||
// buffer size in bytes if all strings were zero-terminated.
|
||||
// suggested buffer size in bytes if all strings were zero-terminated
|
||||
// (for CGroup).
|
||||
pub fn strlenZ(self: *const Group) usize {
|
||||
var count: usize = 0;
|
||||
for (self.members) |member|
|
||||
@ -66,6 +66,20 @@ pub fn strlenZ(self: *const Group) usize {
|
||||
return count;
|
||||
}
|
||||
|
||||
// Name type should be 0-terminated, members should be null-terminated, but
|
||||
// sentinel is not part of the type (but is always there). Adding sentinel
|
||||
// crashes zig compiler in pre-0.10. https://github.com/ziglang/zig/issues/7517
|
||||
pub const CGroup = extern struct {
|
||||
gid: u32,
|
||||
// should be [*:0]const u8
|
||||
name: [*]const u8,
|
||||
// Should be [*:null]align(1) const ?[*:0]const u8
|
||||
members: [*]align(1) const ?[*:0]const u8,
|
||||
};
|
||||
|
||||
// size of the pointer to a single member.
|
||||
pub const ptr_size = @sizeOf(meta.Child(meta.fieldInfo(CGroup, .members).field_type));
|
||||
|
||||
const testing = std.testing;
|
||||
|
||||
test "Group.clone" {
|
||||
|
@ -1,15 +0,0 @@
|
||||
const meta = @import("std").meta;
|
||||
|
||||
// Name type should be 0-terminated, members should be null-terminated, but
|
||||
// sentinel is not part of the type (but is always there). Adding sentinel
|
||||
// crashes zig compiler in pre-0.10. https://github.com/ziglang/zig/issues/7517
|
||||
pub const CGroup = extern struct {
|
||||
gid: u32,
|
||||
// should be [*:0]const u8
|
||||
name: [*]const u8,
|
||||
// Should be [*:null]align(1) const ?[*:0]const u8
|
||||
members: [*]align(1) const ?[*:0]const u8,
|
||||
};
|
||||
|
||||
// size of the pointer to a single member.
|
||||
pub const ptr_size = @sizeOf(meta.Child(meta.fieldInfo(CGroup, .members).field_type));
|
@ -2,7 +2,7 @@ const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const math = std.math;
|
||||
const native_endian = @import("builtin").target.cpu.arch.endian();
|
||||
const ptr_size = @import("cgroup.zig").ptr_size;
|
||||
const ptr_size = @import("Group.zig").ptr_size;
|
||||
|
||||
const max_shells = @import("shell.zig").max_shells;
|
||||
const magic = [4]u8{ 0xf0, 0x9f, 0xa4, 0xb7 };
|
||||
|
Loading…
Reference in New Issue
Block a user