From 6b3f825144075659e91734763d838203a0890262 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Sat, 2 Nov 2024 18:52:09 +0100 Subject: [PATCH] Add info about how to create and read a dir --- doc/syscalls.md | 5 +++++ www/syscalls.html | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/doc/syscalls.md b/doc/syscalls.md index 69ee759f..b88e5d36 100644 --- a/doc/syscalls.md +++ b/doc/syscalls.md @@ -59,6 +59,11 @@ enum OpenFlag { } ``` +The flags `OpenFlag::Create | OpenFlag::Dir` can be used to create a directory. + +Reading a directory opened with `OpenFlag::Read | OpenFlag::Dir` will return a +list of `FileInfo`, one for each file in the directory. + ## CLOSE (0x06) ```rust diff --git a/www/syscalls.html b/www/syscalls.html index 6835ac2b..80ae5a44 100644 --- a/www/syscalls.html +++ b/www/syscalls.html @@ -18,26 +18,36 @@

EXIT (0x01)

fn exit(code: usize) -> usize
 
+

Terminate the calling process.

+

SPAWN (0x02)

-
fn spawn(path: &str) -> isize
+    
fn spawn(path: &str, args: &[&str]) -> isize
 
+

Spawn a process with the given list of arguments.

+

READ (0x03)

fn read(handle: usize, buf: &mut [u8]) -> isize
 
+

Read from a file handle to a buffer.

+

WRITE (0x04)

fn write(handle: usize, buf: &mut [u8]) -> isize
 
+

Write from a buffer to a file handle.

+

OPEN (0x05)

fn open(path: &str, flags: usize) -> isize
 
+

Open a file and return a file handle.

+

The flags can be one or more of the following:

enum OpenFlag {
@@ -51,16 +61,25 @@ 

OPEN (0x05)

}
+

The flags OpenFlag::Create | OpenFlag::Dir can be used to create a directory.

+ +

Reading a directory opened with OpenFlag::Read | OpenFlag::Dir will return a +list of FileInfo, one for each file in the directory.

+

CLOSE (0x06)

fn close(handle: usize)
 
+

Close a file handle.

+

INFO (0x07)

fn info(path: &str, info: &mut FileInfo) -> isize
 
+

Get informations on a file.

+

This syscall will set the following attributes of the given structure:

struct FileInfo {
@@ -76,11 +95,15 @@ 

DUP (0x08)

fn dup(old_handle: usize, new_handle: usize) -> isize
 
+

Duplicate a file handle.

+

DELETE (0x09)

fn delete(path: &str) -> isize
 
+

Delete a file.

+

STOP (0x0A)

fn stop(code: usize)
@@ -93,6 +116,8 @@ 

SLEEP (0x0B)

fn sleep(seconds: f64)
 
+

The system will sleep for the given amount of seconds.

+

POLL (0x0C)

fn poll(list: &[(usize, IO)]) -> isize
@@ -120,9 +145,9 @@ 

CONNECT (0x0D)

Connect a socket to an endpoint at the given IpAddress and port:

-
struct Ipv4Address(pub [u8; 4]);
+    
struct Ipv4Address([u8; 4]);
 
-struct Ipv6Address(pub [u8; 16]);
+struct Ipv6Address([u8; 16]);
 
 enum IpAddress {
     Ipv4(Ipv4Address),
@@ -137,21 +162,29 @@ 

LISTEN (0x0E)

fn listen(handle, usize, port: u16) -> isize
 
+

Listen for incoming connections on a socket.

+

ACCEPT (0x0F)

fn accept(handle, usize, addr: IpAddress) -> isize
 
+

Accept incoming connection on a socket.

+

ALLOC (0x10)

fn alloc(size: usize, align: usize) -> *mut u8
 
+

Allocate memory.

+

FREE (0x11)

fn free(ptr: *mut u8, size: usize, align: usize)
 
+

Free memory.

+

KIND (0x12)

fn kind(handle: usize) -> isize