Skip to content

Commit

Permalink
Change extra_files delimiter to an exclamation mark ! (theseus-os…
Browse files Browse the repository at this point in the history
…#723)

* Ensures bootloader module filenames are compatible with
  the FAT filesystem, as needed for upcoming UEFI support.

Signed-off-by: Klim Tsoutsman <[email protected]>
  • Loading branch information
tsoutsman authored Dec 12, 2022
1 parent 8c79656 commit 8130dcf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,13 @@ limine:


### This target copies all extra files into the `ISOFILES` directory,
### collapsing their directory structure into a single file name with `?` as the directory delimiter.
### collapsing their directory structure into a single file name with `!` as the directory delimiter.
### The contents of the EXTRA_FILES directory will be available at runtime within Theseus's root fs, too.
### See the `README.md` in the `extra_files` directory for more info.
extra_files:
@mkdir -p $(OBJECT_FILES_BUILD_DIR)
@for f in $(shell cd $(EXTRA_FILES) && find * -type f); do \
ln -f $(EXTRA_FILES)/$${f} $(OBJECT_FILES_BUILD_DIR)/`echo -n $${f} | sed 's/\//?/g'` & \
ln -f $(EXTRA_FILES)/$${f} $(OBJECT_FILES_BUILD_DIR)/`echo -n $${f} | sed 's/\//!/g'` & \
done; wait


Expand Down
15 changes: 8 additions & 7 deletions extra_files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Examples include:

## How it works
All files and directories here will be copied as-is without modification into the `/extra_files/` directory within Theseus.
Directory hierarchies are preserved as well, but empty directories are ignored.
Directory hierarchies are preserved as well, but empty directories are ignored. Hierarchies are encoded using an exclamation
mark when creating the bootloader modules.

Here are some examples of how a hypothetical file in this directory will appear in Theseus at runtime:
```
./hello.txt --> /extra_files/hello.txt
./wasm/test.wasm --> /extra_files/wasm/test.wasm
./foo/bar/me.o --> /extra_files/foo/bar/me.o
```
Here are some examples of how file paths would work:
| Host machine | Bootloader module | Runtime path |
|------------------|----------------------------|-----------------------------|
| ./hello.txt | extra_files!hello.txt | /extra_files/hello.txt |
| ./wasm/test.wasm | extra_files!wasm!test.wasm | /extra_files/wasm/test.wasm |
| ./foo/bar/me.o | extra_files!foo!bar!me.o | /extra_files/foo/bar/me.o |
6 changes: 3 additions & 3 deletions kernel/mod_mgmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub const NAMESPACES_DIRECTORY_NAME: &'static str = "namespaces";

/// The name of the directory that contains all other "extra_files" contents.
pub const EXTRA_FILES_DIRECTORY_NAME: &'static str = "extra_files";
const EXTRA_FILES_DIRECTORY_DELIMITER: char = '?';
const EXTRA_FILES_DIRECTORY_DELIMITER: char = '!';

/// The initial `CrateNamespace` that all kernel crates are added to by default.
static INITIAL_KERNEL_NAMESPACE: Once<Arc<CrateNamespace>> = Once::new();
Expand Down Expand Up @@ -231,9 +231,9 @@ fn parse_bootloader_modules_into_files(
/// (files that exist as areas of pre-loaded memory).
///
/// Their file paths are encoded by flattening directory hierarchies into a the file name,
/// using `'?'` (question marks) to replace the directory delimiter `'/'`.
/// using `'!'` (exclamation marks) to replace the directory delimiter `'/'`.
///
/// Thus, for example, a file named `"foo?bar?me?test.txt"` will be placed at the path
/// Thus, for example, a file named `"foo!bar!me!test.txt"` will be placed at the path
/// `/extra_files/foo/bar/me/test.txt`.
fn parse_extra_file(
extra_file_name: &str,
Expand Down

0 comments on commit 8130dcf

Please sign in to comment.