code wiki / (root) / fs.nx

fs.nx

buildroot/runtime/fs.nx

7280 B201 linesdepth 3pulls 4 transitivereach 2 importersview sourcekind librarytopic fs
docsdependenciesstructsconstsfunctions

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

syscalls.nx stdlib.nx fs.nx nxmake.nx tsv.nx

imports: syscalls.nxstdlib.nx

imported by: nxmake.nxtsv.nx

structs

none

consts

26const O_RDONLY: i64 = 0
27const O_WRONLY: i64 = 1
28const O_RDWR: i64 = 2
29const O_CREAT: i64 = 0x40
30const O_TRUNC: i64 = 0x200
31const O_APPEND: i64 = 0x400
33const SYS_FSTAT: i64 = 80
34const SYS_MKDIRAT: i64 = 34
35const SYS_RENAMEAT: i64 = 82

functions

58func fs_errno_to(e: i64) -> i64 {
75func fs_open_rd_raw(path: *u8) -> i64 {
79func fs_open_wr_raw(path: *u8, mode: i64) -> i64 {
84func fs_open_append_raw(path: *u8, mode: i64) -> i64 {
called by 1: fs_open_append
90func fs_open_rd(path: *u8) -> *Result<i64, FsError> {
called by 1: main calls 2: fs_open_rd_rawfs_errno_to
96func fs_open_wr(path: *u8, mode: i64) -> *Result<i64, FsError> {
102func fs_open_append(path: *u8, mode: i64) -> *Result<i64, FsError> {
110func fs_close(fd: i64) -> *Result<i64, FsError> {
calls 1: fs_errno_to
120func fs_read(fd: i64, buf: *u8, n: i64) -> *Result<i64, FsError> {
127func fs_write(fd: i64, buf: *u8, n: i64) -> *Result<i64, FsError> {
calls 1: fs_errno_to
138func fs_read_all(path: *u8, out_len: *i64) -> *u8 {
144func fs_write_all(path: *u8, buf: *u8, n: i64, mode: i64) -> *Result<i64, FsError> {
called by 1: main calls 2: fs_open_wr_rawfs_errno_to
167func fs_size(path: *u8) -> *Result<i64, FsError> {
181func fs_exists(path: *u8) -> i64 {
called by 2: mainmain calls 1: fs_open_rd_raw
190func fs_mkdir(path: *u8, mode: i64) -> *Result<i64, FsError> {
calls 1: fs_errno_to
196func fs_rename(old_path: *u8, new_path: *u8) -> *Result<i64, FsError> {
calls 1: fs_errno_to