From 6e8fbb8b5953d3977378fb849453900935bb0f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Nerma?= Date: Sat, 7 Oct 2023 10:24:27 +0200 Subject: [PATCH] Add enumeration kernel data type --- docs/specs/kernel/data-structures.md | 9 +++- docs/specs/services/system/fs.md | 71 ++++++++++++++-------------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/docs/specs/kernel/data-structures.md b/docs/specs/kernel/data-structures.md index d2e9f96..83df5b9 100644 --- a/docs/specs/kernel/data-structures.md +++ b/docs/specs/kernel/data-structures.md @@ -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 @@ -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). \ No newline at end of file diff --git a/docs/specs/services/system/fs.md b/docs/specs/services/system/fs.md index f16a357..e50b068 100644 --- a/docs/specs/services/system/fs.md +++ b/docs/specs/services/system/fs.md @@ -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 @@ -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)