aboutsummaryrefslogtreecommitdiff
path: root/system.old/libraries/io/attachment.zig
blob: 4672fecef5fad7167c24dd5d605ec5902b643354 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Attachment operations

const sys = @import("sys");
const types = @import("types.zig");

const ERROR_RESULT: u64 = @bitCast(@as(i64, -1));

pub fn attach(location: []const u8, flags: u32) types.Error!types.Descriptor {
    const result = sys.syscall(.attach, .{ @intFromPtr(location.ptr), flags });
    if (result == ERROR_RESULT) {
        return types.Error.NotFound;
    }
    return @truncate(result);
}

pub fn seal(fd: types.Descriptor) void {
    _ = sys.syscall(.seal, .{fd});
}

pub fn viewstack(location: []const u8, entries: []types.StackEntry) types.Error!usize {
    const result = sys.syscall(.viewstack, .{
        @intFromPtr(location.ptr),
        location.len,
        @intFromPtr(entries.ptr),
        entries.len,
    });

    if (result == ERROR_RESULT) {
        return types.Error.InvalidLocation;
    }

    return @intCast(result);
}