Add filesystem syscall 70 wrapper and fs_demo example #10

Open
rajc6h6 wants to merge 4 commits from rajc6h6/Core:feat/fs-syscall into master
pull from: rajc6h6/Core:feat/fs-syscall
First-time contributor
  • 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
rajc6h6 added 1 commit 2026-03-10 17:31:47 +00:00
Sweetbread left a comment
Owner

The way you wrote a wrapper does not fit the project

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";
Owner

Use c"..." for c-strings

Use `c"..."` for c-strings
Sweetbread marked this conversation as resolved
@@ -0,0 +8,4 @@
#[no_mangle]
pub extern "C" fn _start() -> ! {
unsafe {
Owner

In examples should not be unsafes

In examples should not be `unsafe`s
Sweetbread marked this conversation as resolved
@@ -0,0 +22,4 @@
}
loop {}
}
Owner

Add the example into Cargo.toml

Add the example into `Cargo.toml`
Sweetbread marked this conversation as resolved
src/fs.rs Outdated
@@ -0,0 +9,4 @@
pub func: u32, // 0 = read, 1 = read folder, 2 = create/write
pub param1: u32, // offset (low)
pub param2: u32, // offset (high) or flags
pub param3: u32, // bytes to read/write
Owner

Em? Why not just name them istead of writing comment?

Em? Why not just name them istead of writing comment?
Sweetbread marked this conversation as resolved
src/fs.rs Outdated
@@ -0,0 +15,4 @@
}
/// Opens/reads a file on KolibriOS using syscall eax=70
/// Returns (eax_result, ebx_bytes_read)
Owner

That's too low-level. Those functions should be in src/sys.rs

That's too low-level. Those functions should be in `src/sys.rs`
Sweetbread marked this conversation as resolved
rajc6h6 added 1 commit 2026-03-21 07:18:10 +00:00
Author
First-time contributor

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!

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!
@@ -0,0 +4,4 @@
use kos::fs::fs_read;
#[no_mangle]
pub extern "C" fn _start() -> ! {
Owner

Look at other examples for start command

Look at other examples for start command
Sweetbread marked this conversation as resolved
src/sys.rs Outdated
@@ -71,0 +88,4 @@
in("ebx") req,
out("ebx") ebx_result,
options(nostack)
);
Owner

You still have this kind of wrappers we don't use in the project

You still have this kind of wrappers we don't use in the project
Sweetbread marked this conversation as resolved
rajc6h6 added 1 commit 2026-03-25 16:13:23 +00:00
src/syscalls.S Outdated
@@ -145,1 +146,4 @@
_fs_read:
push ebx
mov eax, 70
Owner

Magic number. Use const SF_FILE

Magic number. Use const `SF_FILE`
Sweetbread marked this conversation as resolved
Sweetbread left a comment
Owner

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
src/sys.rs Outdated
@@ -70,0 +80,4 @@
pub offset_hi: u32,
pub byte_count: u32,
pub buffer: *mut u8,
pub reserved: u8,
Owner

Why do you reserve it?

Why do you reserve it?
Sweetbread marked this conversation as resolved
rajc6h6 added 1 commit 2026-03-26 19:27:26 +00:00
Author
First-time contributor

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

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.
git fetch -u https://git.kolibrios.org/rajc6h6/Core feat/fs-syscall:rajc6h6-feat/fs-syscall
git checkout rajc6h6-feat/fs-syscall
Sign in to join this conversation.