fs.nx
buildroot/runtime/fs.nx
about
fs.nx -- file I/O stdlib (Phase G1 in the roadmap).
Typed wrappers around Linux / NishiOS file syscalls. Every fallible
operation returns `*Result<i64, FsError>`. Callers match on the
variant -- the `-errno` sentinel convention is gone from the public
API. Raw-errno helpers remain as `fs_*_raw` for the rare case
where a caller wants the bare syscall return.
Syscall numbers (Linux RV64, NishiOS matches):
56 openat
57 close
63 read
64 write
80 fstat
34 mkdirat
82 renameat
AT_FDCWD = -100 is the "current working directory" magic fd used by
the *at syscalls when the path is relative.
dependencies 2 imports · 2 importers
imports: syscalls.nxstdlib.nx
structs
| none |
consts
| 26 | const O_RDONLY: i64 = 0 |
| 27 | const O_WRONLY: i64 = 1 |
| 28 | const O_RDWR: i64 = 2 |
| 29 | const O_CREAT: i64 = 0x40 |
| 30 | const O_TRUNC: i64 = 0x200 |
| 31 | const O_APPEND: i64 = 0x400 |
| 33 | const SYS_FSTAT: i64 = 80 |
| 34 | const SYS_MKDIRAT: i64 = 34 |
| 35 | const SYS_RENAMEAT: i64 = 82 |
functions
| 58 | func fs_errno_to(e: i64) -> i64 { |
| 75 | func fs_open_rd_raw(path: *u8) -> i64 { |
| 79 | func fs_open_wr_raw(path: *u8, mode: i64) -> i64 { |
| 84 | func fs_open_append_raw(path: *u8, mode: i64) -> i64 {
called by 1: fs_open_append |
| 90 | func fs_open_rd(path: *u8) -> *Result<i64, FsError> { |
| 96 | func fs_open_wr(path: *u8, mode: i64) -> *Result<i64, FsError> { |
| 102 | func fs_open_append(path: *u8, mode: i64) -> *Result<i64, FsError> { |
| 110 | func fs_close(fd: i64) -> *Result<i64, FsError> {
calls 1: fs_errno_to |
| 120 | func fs_read(fd: i64, buf: *u8, n: i64) -> *Result<i64, FsError> { |
| 127 | func fs_write(fd: i64, buf: *u8, n: i64) -> *Result<i64, FsError> {
calls 1: fs_errno_to |
| 138 | func fs_read_all(path: *u8, out_len: *i64) -> *u8 { |
| 144 | func fs_write_all(path: *u8, buf: *u8, n: i64, mode: i64) -> *Result<i64, FsError> { |
| 167 | func fs_size(path: *u8) -> *Result<i64, FsError> { |
| 181 | func fs_exists(path: *u8) -> i64 { |
| 190 | func fs_mkdir(path: *u8, mode: i64) -> *Result<i64, FsError> {
calls 1: fs_errno_to |
| 196 | func fs_rename(old_path: *u8, new_path: *u8) -> *Result<i64, FsError> {
calls 1: fs_errno_to |