Commit 15bec20b00

Mahdi Khanalizadeh <mahdi@khanalizadeh.com>
2021-07-13 15:35:23
linux: add mknod and mknodat syscalls
1 parent f5d9d73
Changed files (1)
lib
std
lib/std/os/linux.zig
@@ -253,6 +253,18 @@ pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: u32) usize {
     return syscall3(.mkdirat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode);
 }
 
+pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize {
+    if (@hasField(SYS, "mknod")) {
+        return syscall3(.mknod, @ptrToInt(path), mode, dev);
+    } else {
+        return mknodat(AT_FDCWD, path, mode, dev);
+    }
+}
+
+pub fn mknodat(dirfd: i32, path: [*:0]const u8, mode: u32, dev: u32) usize {
+    return syscall4(.mknodat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, dev);
+}
+
 pub fn mount(special: [*:0]const u8, dir: [*:0]const u8, fstype: [*:0]const u8, flags: u32, data: usize) usize {
     return syscall5(.mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data);
 }