Files
my-os-project2/user/init/main.c

24 lines
652 B
C

#include <system/system.h>
#include <sysdefs/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);
char *text = "Write to a file";
IOCtlWF ioctlwf = { .buffer = text, .len = string_len(text), .off = 0 };
ioctl(ioh, IOCTL_WRITE, &ioctlwf);
char buf[0x100];
IOCtlRF ioctlrf = { .buffer = buf, .len = string_len(text), .off = 0 };
ioctl(ioh, IOCTL_READ, &ioctlrf);
debugprint(buf);
ioctl(ioh, IOCTL_CLOSEF, NULL);
}