Nice wrappers around ioctl() syscall

This commit is contained in:
2025-09-05 23:00:57 +02:00
parent d399922de6
commit c31c00e8cd
3 changed files with 44 additions and 9 deletions

View File

@ -1,23 +1,22 @@
#include <system/system.h>
#include <stdint.h>
#include <sysdefs/ioctl.h>
#include <system/system.h>
#include <system/ioctl.h>
#include <string/string.h>
void main(void) {
debugprint("Hello world from userspace in C");
IOCtlOF ioctlof = { .path = "base:/hello.txt", .flags = IOCTL_F_WRITE | IOCTL_F_READ | IOCTL_F_MAKE };
int32_t ioh = ioctl(IOCTL_NOHANDLE, IOCTL_OPENF, &ioctlof);
int32_t ioh = ioctl_openfile("base:/hello.txt", IOCTL_F_WRITE | IOCTL_F_READ | IOCTL_F_MAKE);
char *text = "Write to a file";
IOCtlWF ioctlwf = { .buffer = text, .len = string_len(text), .off = 0 };
ioctl(ioh, IOCTL_WRITE, &ioctlwf);
char *text = "Hello from the filesystem";
ioctl_writefile(ioh, (const uint8_t *const)text, string_len(text), 0);
char buf[0x100];
IOCtlRF ioctlrf = { .buffer = buf, .len = string_len(text), .off = 0 };
ioctl(ioh, IOCTL_READ, &ioctlrf);
ioctl_readfile(ioh, (uint8_t *const)buf, string_len(text), 0);
debugprint(buf);
ioctl(ioh, IOCTL_CLOSEF, NULL);
ioctl_closefile(ioh);
}