pluto icon indicating copy to clipboard operation
pluto copied to clipboard

Filesystem syscalls

Open SamTebbs33 opened this issue 4 years ago • 2 comments

Now that we have user mode implemented, we need some syscalls that will allow programs to interact with the filesystem.

openFile(path: [*]const u8, path_len: usize, create: bool) usize
openDir(path: [*]const u8, path_len: usize, create: bool) usize
openSymlink(path: [*]const u8, path_len: usize, target: [*]const u8, target_len: usize, create: bool) usize
read(handle: usize, buffer: [*]u8, buffer_len: usize) usize
write(handle: usize, buffer: [*]const u8, buffer_len: usize) usize
close(handle: usize)

The open functions return an integer representing a handle to that file. That integer will be used to refer to the file once it is opened. File handles are unique to each process.

Slices must be passed as a pointer and size separately since syscalls use the CPU registers which cannot store complex types. such as slices.

SamTebbs33 avatar Nov 19 '20 22:11 SamTebbs33

Couldn't the syscall function do the conversion from slice to pointer and length

DrDeano avatar Nov 20 '20 08:11 DrDeano

Couldn't the syscall function do the conversion from slice to pointer and length

If you're referring to the function that starts the syscall, then sure that can take a slice, but the actual transaction between the process and kernel have to use the two raw values. The things that look like functions in the description aren't actually functions, they're just descriptions of the syscall interface and the arguments each takes.

SamTebbs33 avatar Nov 20 '20 09:11 SamTebbs33