src/fs.rs: wrapper for filesystem syscall 70 via int 0x40
examples/fs_demo.rs: reads /rd/1/readme.txt into a buffer
Builds with no_std + i686-kolibri target
- src/fs.rs: wrapper for filesystem syscall 70 via int 0x40
- examples/fs_demo.rs: reads /rd/1/readme.txt into a buffer
- Builds with no_std + i686-kolibri target
Moved FileSystemRequest and raw syscall_fs to src/sys.rs
src/fs.rs now only has the safe fs_read API
Renamed struct fields properly instead of using comments
Switched to c"..." for C-strings
Removed all unsafe from the example
Added fs_demo to Cargo.toml
Let me know if there's anything else to fix!
Done! I've made all the changes you requested:
Moved FileSystemRequest and raw syscall_fs to src/sys.rs
src/fs.rs now only has the safe fs_read API
Renamed struct fields properly instead of using comments
Switched to c"..." for C-strings
Removed all unsafe from the example
Added fs_demo to Cargo.toml
Let me know if there's anything else to fix!
There are 10 subfuncs in syscall 70. You made too low-level wrapper with operation code in the struct. You shouldn't, because users of the library should not know any KOS's sysfuncs. So, I think, you should split it into 10 different Rust functions
There are 10 subfuncs in syscall 70. You made too low-level wrapper with operation code in the struct. You shouldn't, because users of the library should not know any KOS's sysfuncs. So, I think, you should split it into 10 different Rust functions
mov eax, 70 replaced with mov eax, SF_FILE in syscalls.S
Redesigned fs module — 10 separate public functions (read_file, write_file, create_file, delete, create_folder, etc.), FsBlock is now pub(crate) so no KOS internals are exposed to library users
_pad byte kept internally to match the kernel ABI
Fixed both issues:
mov eax, 70 replaced with mov eax, SF_FILE in syscalls.S
Redesigned fs module — 10 separate public functions (read_file, write_file, create_file, delete, create_folder, etc.), FsBlock is now pub(crate) so no KOS internals are exposed to library users
_pad byte kept internally to match the kernel ABI
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The way you wrote a wrapper does not fit the project
@@ -0,0 +3,4 @@use kos::fs::{FileInfo, fs_read};static FILENAME: &[u8] = b"/rd/1/readme.txt\0";Use
c"..."for c-strings@@ -0,0 +8,4 @@#[no_mangle]pub extern "C" fn _start() -> ! {unsafe {In examples should not be
unsafes@@ -0,0 +22,4 @@}loop {}}Add the example into
Cargo.toml@@ -0,0 +9,4 @@pub func: u32, // 0 = read, 1 = read folder, 2 = create/writepub param1: u32, // offset (low)pub param2: u32, // offset (high) or flagspub param3: u32, // bytes to read/writeEm? Why not just name them istead of writing comment?
@@ -0,0 +15,4 @@}/// Opens/reads a file on KolibriOS using syscall eax=70/// Returns (eax_result, ebx_bytes_read)That's too low-level. Those functions should be in
src/sys.rsDone! I've made all the changes you requested:
Moved FileSystemRequest and raw syscall_fs to src/sys.rs
src/fs.rs now only has the safe fs_read API
Renamed struct fields properly instead of using comments
Switched to c"..." for C-strings
Removed all unsafe from the example
Added fs_demo to Cargo.toml
Let me know if there's anything else to fix!
@@ -0,0 +4,4 @@use kos::fs::fs_read;#[no_mangle]pub extern "C" fn _start() -> ! {Look at other examples for start command
@@ -71,0 +88,4 @@in("ebx") req,out("ebx") ebx_result,options(nostack));You still have this kind of wrappers we don't use in the project
@@ -145,1 +146,4 @@_fs_read:push ebxmov eax, 70Magic number. Use const
SF_FILEThere are 10 subfuncs in syscall 70. You made too low-level wrapper with operation code in the struct. You shouldn't, because users of the library should not know any KOS's sysfuncs. So, I think, you should split it into 10 different Rust functions
@@ -70,0 +80,4 @@pub offset_hi: u32,pub byte_count: u32,pub buffer: *mut u8,pub reserved: u8,Why do you reserve it?
Fixed both issues:
mov eax, 70 replaced with mov eax, SF_FILE in syscalls.S
Redesigned fs module — 10 separate public functions (read_file, write_file, create_file, delete, create_folder, etc.), FsBlock is now pub(crate) so no KOS internals are exposed to library users
_pad byte kept internally to match the kernel ABI
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.