Skip to content
Browse files

Automagically create initfs from initfs directory, update redoxfs

  • Loading branch information...
1 parent f65703a commit 16495b8fc729b53f3af870be6003068c5ce8cf49 @jackpot51 jackpot51 committed
Showing with 27 additions and 16 deletions.
  1. +1 −0 .gitignore
  2. +18 −7 Makefile
  3. +1 −1 crates/redoxfs
  4. +3 −3 filesystem/etc/init.rc
  5. +4 −5 kernel/schemes/initfs.rs
View
1 .gitignore
@@ -18,6 +18,7 @@ libc/build/
setup/rust/
build
filesystem/bin/
+initfs/
target
*.swp
doc
View
25 Makefile
@@ -233,10 +233,6 @@ filesystem/bin/launcher: crates/orbutils/src/launcher/main.rs crates/orbutils/sr
$(RUSTC) $(RUSTCFLAGS) --crate-type bin -o $@ $<
-filesystem/bin/redoxfsd: crates/redoxfs/scheme/main.rs crates/redoxfs/scheme/*.rs $(BUILD)/crt0.o $(BUILD)/libstd.rlib $(BUILD)/libredoxfs.rlib
- mkdir -p filesystem/bin
- $(RUSTC) $(RUSTCFLAGS) --crate-type bin -o $@ $<
-
bins: \
coreutils \
extrautils \
@@ -251,7 +247,6 @@ bins: \
filesystem/bin/lua \
filesystem/bin/login \
filesystem/bin/orbital \
- filesystem/bin/redoxfsd \
filesystem/bin/sdl-test \
filesystem/bin/sdl-ttf-test \
filesystem/bin/sh \
@@ -260,6 +255,22 @@ bins: \
filesystem/bin/zfs
#TODO: binutils
+initfs/redoxfsd: crates/redoxfs/scheme/main.rs crates/redoxfs/scheme/*.rs $(BUILD)/crt0.o $(BUILD)/libstd.rlib $(BUILD)/libredoxfs.rlib
+ mkdir -p initfs/
+ $(RUSTC) $(RUSTCFLAGS) --crate-type bin -o $@ $<
+
+initfs: \
+ initfs/redoxfsd
+
+build/initfs.gen: initfs FORCE
+ echo 'use collections::BTreeMap;' > $@
+ echo 'pub fn gen() -> BTreeMap<&'"'"'static str, &'"'"'static [u8]> {' >> $@
+ echo ' let mut files: BTreeMap<&'"'"'static str, &'"'"'static [u8]> = BTreeMap::new();' >> $@
+ $(FIND) initfs -not -path '*/\.*' -type f -o -type l | $(CUT) -d '/' -f2- | $(SORT) \
+ | $(AWK) '{printf(" files.insert(\"%s\", include_bytes!(\"../initfs/%s\"));\n", $$0, $$0)}' \
+ >> $@
+ echo ' files' >> $@
+ echo '}' >> $@
test: kernel/main.rs \
rust/src/libtest/lib.rs \
@@ -270,7 +281,7 @@ test: kernel/main.rs \
$(RUSTC) $(RUSTCFLAGS) --test $<
clean:
- $(RM) -rf build doc filesystem/bin/ filesystem/apps/*/*.bin filesystem/apps/*/*.list
+ $(RM) -rf build doc filesystem/bin/ initfs/bin/ filesystem/apps/*/*.bin filesystem/apps/*/*.list
FORCE:
@@ -356,7 +367,7 @@ $(BUILD)/libsystem.rlib: crates/system/lib.rs crates/system/*.rs crates/system/*
$(BUILD)/libredoxfs.rlib: crates/redoxfs/src/lib.rs crates/redoxfs/src/*.rs $(BUILD)/libsystem.rlib $(BUILD)/liballoc.rlib $(BUILD)/libcollections.rlib
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
-$(BUILD)/kernel.rlib: kernel/main.rs kernel/*.rs kernel/*/*.rs kernel/*/*/*.rs $(BUILD)/libio.rlib $(BUILD)/libredoxfs.rlib filesystem/bin/redoxfsd
+$(BUILD)/kernel.rlib: kernel/main.rs kernel/*.rs kernel/*/*.rs kernel/*/*/*.rs $(BUILD)/libio.rlib build/initfs.gen
$(RUSTC) $(RUSTCFLAGS) -C lto -o $@ $<
$(BUILD)/kernel.bin: $(BUILD)/kernel.rlib kernel/kernel.ld
2 crates/redoxfs
@@ -1 +1 @@
-Subproject commit 51e037150c6c92d5535f49e23cc787c1e6c76866
+Subproject commit ff0106b212f6d67b30cf24fbf940f3a5a7b61ecd
View
6 filesystem/etc/init.rc
@@ -1,9 +1,9 @@
+# Redox FS, to be moved into initfs
+initfs:redoxfsd /etc/redoxfs.bin
+
# Example scheme
example
-# New file scheme
-redoxfsd /etc/redoxfs.bin
-
# Orbital scheme, handles displays
echo `orbital` to start GUI
View
9 kernel/schemes/initfs.rs
@@ -6,6 +6,9 @@ use fs::{KScheme, Resource, Url, VecResource};
use system::error::{Error, Result, ENOENT};
+#[path="../../build/initfs.gen"]
+pub mod gen;
+
/// A memory scheme
pub struct InitFsScheme {
pub files: BTreeMap<&'static str, &'static [u8]>
@@ -13,12 +16,8 @@ pub struct InitFsScheme {
impl InitFsScheme {
pub fn new() -> Box<InitFsScheme> {
- let mut files: BTreeMap<&'static str, &'static [u8]> = BTreeMap::new();
-
- files.insert("redoxfsd", include_bytes!("../../filesystem/bin/redoxfsd"));
-
Box::new(InitFsScheme {
- files: files
+ files: gen::gen()
})
}
}

0 comments on commit 16495b8

Please sign in to comment.
Something went wrong with that request. Please try again.