Files
my-os-project2/ulib/system/ioctl.c

25 lines
751 B
C

#include <stdint.h>
#include <stddef.h>
#include <system/ioctl.h>
#include <sysdefs/ioctl.h>
#include <system/system.h>
int32_t ioctl_openfile(const char *path, uint64_t flags) {
IOCtlOF cfg = { .path = path, .flags = flags };
return ioctl(IOCTL_NOHANDLE, IOCTL_OPENF, &cfg);
}
int32_t ioctl_writefile(int32_t ioh, const uint8_t *const buffer, size_t len, size_t off) {
IOCtlWF cfg = { .buffer = buffer, .len = len, .off = off };
return ioctl(ioh, IOCTL_WRITE, &cfg);
}
int32_t ioctl_readfile(int32_t ioh, uint8_t *const buffer, size_t len, size_t off) {
IOCtlRF cfg = { .buffer = buffer, .len = len, off = off };
return ioctl(ioh, IOCTL_READ, &cfg);
}
int32_t ioctl_closefile(int32_t ioh) {
return ioctl(ioh, IOCTL_CLOSEF, NULL);
}