Skip to content

Commit

Permalink
Add enumeration kernel data type
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Oct 7, 2023
1 parent 3ed369d commit 6e8fbb8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 36 deletions.
9 changes: 8 additions & 1 deletion docs/specs/kernel/data-structures.md
Expand Up @@ -24,6 +24,7 @@ All contiguous data structures are made such as it is easy to delimit them by co
- [Length-first variant](#length-first-variant)
- [Tweaking the `NIE`](#tweaking-the-nie)
- [Unions](#unions)
- [Enumerations](#enumerations)

## Booleans

Expand Down Expand Up @@ -205,6 +206,12 @@ But also:

Unions allow to construct multiple types of data in a single one.

An union is made of a _type ID_ (1 byte) followed by the data.
It is made of a _type ID_ (1 byte) followed by the data.

For instance, if we want to store either a string or a list, we can associate type ID 0 to the former and type ID 1 to the latter, then append the actual string or list to it.

## Enumerations

Enumerations allow to switch between behaviours using a unified data type.

It is made of a _variant ID_ (1 byte) followed by the data (which can be of any fixed type).
71 changes: 36 additions & 35 deletions docs/specs/services/system/fs.md
Expand Up @@ -2,40 +2,41 @@

The `sys::fs` service is in charge of operations related to the [filesystems](../../filesystem.md).

- [Behaviour](#behaviour)
- [Operations and latency](#operations-and-latency)
- [List of natively supported filesystems](#list-of-natively-supported-filesystems)
- [Extending supported filesystems](#extending-supported-filesystems)
- [Filesystems detection](#filesystems-detection)
- [Methods](#methods)
- [`0x0001` IS\_FS\_MOUNTED](#0x0001-is_fs_mounted)
- [`0x0002` ENUM\_FS](#0x0002-enum_fs)
- [`0x0003` FS\_METADATA](#0x0003-fs_metadata)
- [`0x0004` FS\_MOUNT](#0x0004-fs_mount)
- [`0x0005` FS\_UNMOUNT](#0x0005-fs_unmount)
- [`0x0006` FS\_WATCH](#0x0006-fs_watch)
- [`0x0007` FS\_UNWATCH](#0x0007-fs_unwatch)
- [`0x1000` ITEM\_EXISTS](#0x1000-item_exists)
- [`0x1001` FEID\_TO\_SPLIT](#0x1001-feid_to_split)
- [`0x1002` ITEM\_METADATA](#0x1002-item_metadata)
- [`0x2000` RENAME\_ITEM](#0x2000-rename_item)
- [`0x2001` MOVE\_ITEM](#0x2001-move_item)
- [`0x2002` DELETE\_ITEM](#0x2002-delete_item)
- [`0x3000` CREATE\_DIRECTORY](#0x3000-create_directory)
- [`0x3001` READ\_DIRECTORY](#0x3001-read_directory)
- [`0x4000` OPEN\_FILE](#0x4000-open_file)
- [`0x4001` CLOSE\_FILE](#0x4001-close_file)
- [`0x4002` READ\_FILE](#0x4002-read_file)
- [`0x4002` WRITE\_FILE](#0x4002-write_file)
- [`0x5000` CREATE\_SYMLINK](#0x5000-create_symlink)
- [`0x5001` UPDATE\_SYMLINK](#0x5001-update_symlink)
- [`0x5002` READ\_SYMLINK](#0x5002-read_symlink)
- [`0xA000` WATCH\_ITEM](#0xa000-watch_item)
- [`0xA001` UNWATCH](#0xa001-unwatch)
- [`0xF000` FORMAT](#0xf000-format)
- [Notifications](#notifications)
- [`0x0006` FS\_CHANGED](#0x0006-fs_changed)
- [`0xA000` ITEM\_CHANGED](#0xa000-item_changed)
- [`sys::fs` service](#sysfs-service)
- [Behaviour](#behaviour)
- [Operations and latency](#operations-and-latency)
- [List of natively supported filesystems](#list-of-natively-supported-filesystems)
- [Extending supported filesystems](#extending-supported-filesystems)
- [Filesystems detection](#filesystems-detection)
- [Methods](#methods)
- [`0x0001` IS\_FS\_MOUNTED](#0x0001-is_fs_mounted)
- [`0x0002` ENUM\_FS](#0x0002-enum_fs)
- [`0x0003` FS\_METADATA](#0x0003-fs_metadata)
- [`0x0004` FS\_MOUNT](#0x0004-fs_mount)
- [`0x0005` FS\_UNMOUNT](#0x0005-fs_unmount)
- [`0x0006` FS\_WATCH](#0x0006-fs_watch)
- [`0x0007` FS\_UNWATCH](#0x0007-fs_unwatch)
- [`0x1000` ITEM\_EXISTS](#0x1000-item_exists)
- [`0x1001` FEID\_TO\_SPLIT](#0x1001-feid_to_split)
- [`0x1002` ITEM\_METADATA](#0x1002-item_metadata)
- [`0x2000` RENAME\_ITEM](#0x2000-rename_item)
- [`0x2001` MOVE\_ITEM](#0x2001-move_item)
- [`0x2002` DELETE\_ITEM](#0x2002-delete_item)
- [`0x3000` CREATE\_DIRECTORY](#0x3000-create_directory)
- [`0x3001` READ\_DIRECTORY](#0x3001-read_directory)
- [`0x4000` OPEN\_FILE](#0x4000-open_file)
- [`0x4001` CLOSE\_FILE](#0x4001-close_file)
- [`0x4002` READ\_FILE](#0x4002-read_file)
- [`0x4002` WRITE\_FILE](#0x4002-write_file)
- [`0x5000` CREATE\_SYMLINK](#0x5000-create_symlink)
- [`0x5001` UPDATE\_SYMLINK](#0x5001-update_symlink)
- [`0x5002` READ\_SYMLINK](#0x5002-read_symlink)
- [`0xA000` WATCH\_ITEM](#0xa000-watch_item)
- [`0xA001` UNWATCH](#0xa001-unwatch)
- [`0xF000` FORMAT](#0xf000-format)
- [Notifications](#notifications)
- [`0x0006` FS\_CHANGED](#0x0006-fs_changed)
- [`0xA000` ITEM\_CHANGED](#0xa000-item_changed)

## Behaviour

Expand Down Expand Up @@ -446,7 +447,7 @@ Note that read and write access can be enabled together.
**Arguments:**

- [FSID](../../filesystem.md#filesystem-unique-identifier) (40 bytes)
- [Union](../../kernel/data-structures.md#unions) (1 + ? bytes)
- [Enumeration](../../kernel/data-structures.md#enumerations) (1 + ? bytes)
- Type ID `0x00`: Existing [filesystem path](../integration/filesystem-interfaces.md#filesystem-paths) to open
- Type ID `0x01`: Existing [filesystem path](../integration/filesystem-interfaces.md#filesystem-paths) of the parent directory
- Enable read access (1 byte)
Expand Down

0 comments on commit 6e8fbb8

Please sign in to comment.