From fe9a425ca12afbd6f59e268a6e34d9afffec9b86 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 28 Feb 2023 00:35:44 +0100 Subject: [PATCH] docs: documented USTAR implementation --- .wiki/Kernel-documentation.md | 50 +++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/.wiki/Kernel-documentation.md b/.wiki/Kernel-documentation.md index 8143f3d..f115dcf 100644 --- a/.wiki/Kernel-documentation.md +++ b/.wiki/Kernel-documentation.md @@ -304,6 +304,45 @@ This use of the vfs cache isn't a great solution and should be reworked. Copies **_size_** bytes from the files' cache to **_buffer_out_**. This won't copy more bytes than the allocated cache space is big. +### fs/ustar.h +The USTAR '_filesystem_' is probably more common known as **tar**-archive. +It is a really simple concept, where a file consists of a header block followed by data blocks. +These blocks are aligned at 512 bytes. + +OSDev Wiki: [USTAR](https://wiki.osdev.org/USTAR) + +#### `ustar_type_E` - enum +The types an entry can have: + - **File** + - **Hardlink** + - **Symlink** + - **Char Device** + - **Block Device** + - **Directory** + - **Pipe** + +#### `ustar_header_T` - struct [packed / 512B aligned] + +| Name | Type | Description | +|-------------------|-----------|------------------------------------------------------------------------------| +| name | char[100] | The name of the entry | +| mode | uint64_t | file mode (permissions, etc) | +| owner_id | uint64_t | The owners ID | +| group_id | uint64_t | The groups ID | +| size | char[12] | The size of the entry, represented as a string of an octal number (dafuq) | +| last_modification | char[12] | The unix-timestamp, when the entry was modified the last time | +| checksum | uint64_t | I think this is a weird checksum of the header | +| type | uint8_t | The type (`ustar_type_E`) of the entry, represented as ascii numbers (dafuq) | +| name_linked | char[100] | The path to the linked entry, if this is a link-entry | +| indicator | char[6] | This needs to be `ustar` | +| version | uint16_t | The version of the **tar** command, that created the archive | +| owner_user_name | char[32] | The name of the file owner | +| owner_group_name | char[32] | The name of the file group | +| device_major | uint64_t | The devices major number | +| device_minor | uint64_t | The devices minor number | +| name_prefix | char[155] | If this is not null, this acts as a prefix for _name_ | + + ### fs/vfs.h **VFS** stands for _Virtual File System_ and is an abstraction, @@ -434,6 +473,13 @@ Reads **_size_** bytes from **_file_** at **_position_** into **_buffer_out_**. **Warning:** the current ramfs implementation will ignore **_position_**! +#### `vfs_directory_create(filesystem, path)` - function (vfs_node_T*) +Creates a directory at **_path_** in **_filesystem_** and returns a pointer to it. +The directory in **_path_** needs to exist and the name of the new directory (after the last `/`) needs to not exist. + +#### `vfs_directory_delete(directory)` - function (void) [not implemented yet] +Deletes a directory. + #### `vfs_init(boot_info)` - function (void) Initializes the VFS. In future this will also unpack the initial ramdisk into the _temp_ directory. @@ -441,8 +487,8 @@ In future this will also unpack the initial ramdisk into the _temp_ directory. #### `vfs_resolve_path(filesystem, path)` - function (vfs_node_T*) Returns the node at **_path_** or NULL if **_path_** is invalid. -#### `vfs_unpack_archive_ustar(node, archive)` - function (void) [Not Implemented yet] -This will unpack a USTAR-archive (**_archive_**) at **_node_**. +#### `vfs_unpack_archive_ustar(filesystem, archive)` - function (void) +This will unpack a USTAR-archive (**_archive_**) at **_filesystem_**'s root. ### graphics/color.h