Skip to content

Commit

Permalink
Hierarchical Namespace Naming Update (#255)
Browse files Browse the repository at this point in the history
* Switch init to use new runtime.

* Cleanup tests.

* Reorg.

* Added secure gate naming library

* reverted changes

* refactored naming service

* removed changes in main

* did fmt

* removed unnecessary dependency

* updated naming service

* added naming support to etl system

* fixed bug with using twzid instead of path

* changed naming to twizzler vec

* Implement dynamic gate lookup.

* Implement dynamic gate calling.

* Move pager init and add pager dynamic gate lookup.

* Added runtime naming support

* Added std::fs support for etl_twizzler

* cargo fmt

* added preliminary changes for namespace

* namespaces v0.2

* namespace v0.3

* updated naming-srv

* weird bug in code

* removed warnings

* Added more tests

* Fix kernel dep, update ABI.

* Fix kernel dep, update ABI.

* Added create to runtime

* removed warnings

* finished naming?

* added api for initializing namespace from object

---------

Co-authored-by: Daniel Bittman <[email protected]>
  • Loading branch information
CPTforever and dbittman authored Jan 23, 2025
1 parent 6613dec commit b12a4d5
Show file tree
Hide file tree
Showing 19 changed files with 1,054 additions and 249 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ members = [
"src/bin/stdfs_demo",
"src/bin/virtio",
"src/bin/mnemosyne",
"src/bin/stdfs_demo",
"src/bin/virtio",
"src/kernel",
"src/lib/twizzler-queue-raw",
Expand Down Expand Up @@ -46,7 +45,8 @@ members = [
"src/srv/naming-srv",
"src/bin/naming-test",
"src/bin/object-store-test",
"src/lib/pager",
"src/lib/pager",
"src/bin/ls",
]

exclude = ["toolchain/src/rust"]
Expand All @@ -68,6 +68,7 @@ initrd = [
"crate:random_validation",
"crate:randtest",
"crate:genrandom",
"crate:ls",
"lib:naming-srv",
"crate:naming-test",
"crate:object-store-test",
Expand Down
39 changes: 24 additions & 15 deletions src/bin/init/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ fn initialize_pager() {
std::mem::forget(pager_comp);
}

fn initialize_namer() {
info!("starting namer");

let nmcomp: CompartmentHandle = CompartmentLoader::new(
"naming",
"libnaming_srv.so",
NewCompartmentFlags::EXPORT_GATES,
)
.args(&["naming"])
.load()
.expect("failed to initialize namer");
let mut flags = nmcomp.info().flags;
while !flags.contains(CompartmentFlags::READY) {
flags = nmcomp.wait(flags);
}
tracing::info!("naming ready");

let namer_start = unsafe { nmcomp.dynamic_gate::<(ObjID,), ()>("namer_start").unwrap() };
namer_start(ObjID::default());

std::mem::forget(nmcomp);
}

fn main() {
tracing::subscriber::set_global_default(
tracing_subscriber::fmt()
Expand All @@ -72,21 +95,6 @@ fn main() {
tracing::info!("logboi ready");
std::mem::forget(lbcomp);

let nmcomp: CompartmentHandle = CompartmentLoader::new(
"naming",
"libnaming_srv.so",
NewCompartmentFlags::EXPORT_GATES,
)
.args(&["naming"])
.load()
.unwrap();
let mut flags = nmcomp.info().flags;
while !flags.contains(CompartmentFlags::READY) {
flags = nmcomp.wait(flags);
}
tracing::info!("naming ready");
std::mem::forget(nmcomp);

let create = ObjectCreate::new(
BackingType::Normal,
LifetimeType::Volatile,
Expand Down Expand Up @@ -127,6 +135,7 @@ fn main() {
initialize_pager();
std::mem::forget(dev_comp);

initialize_namer();
run_tests("test_bins", false);
run_tests("bench_bins", true);

Expand Down
8 changes: 8 additions & 0 deletions src/bin/ls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "ls"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version = "4.5.26", features = ["derive"] }
naming = { path = "../../lib/naming" }
72 changes: 72 additions & 0 deletions src/bin/ls/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use std::{cmp::Ordering, path::PathBuf};

use clap::Parser;
use naming::{static_naming_factory, EntryType, StaticNamingHandle};

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long)]
recursive: bool,
path: Option<String>,
}

fn recurse(handle: &mut StaticNamingHandle, foo: &mut PathBuf) {
let mut names = handle.enumerate_names().unwrap();
names.sort_by(|a, b| {
if a.entry_type == EntryType::Namespace {
Ordering::Greater
} else if b.entry_type == EntryType::Namespace {
Ordering::Less
} else {
a.name.cmp(&b.name)
}
});

println!("{}:", foo.display());
for x in &names {
foo.push(x.name);
print!("{} ", x.name);
foo.pop();
}
println!("\n");
for x in &names {
if x.entry_type != EntryType::Namespace {
break;
}
foo.push(x.name);
handle.change_namespace(&x.name).unwrap();
recurse(handle, foo);
handle.change_namespace("..").unwrap();
foo.pop();
}
}

fn main() {
let args = Args::parse();

let mut namer = static_naming_factory().unwrap();

if args.recursive {
let mut path = PathBuf::new();
path.push(".");
recurse(&mut namer, &mut path);
} else {
let mut names = namer
.enumerate_names_relative(&args.path.unwrap_or("/".to_string()))
.unwrap();
names.sort_by(|a, b| {
if a.entry_type == EntryType::Namespace {
Ordering::Greater
} else if b.entry_type == EntryType::Namespace {
Ordering::Less
} else {
a.name.cmp(&b.name)
}
});
for x in &names {
print!("{} ", x.name);
}
println!("")
}
}
2 changes: 1 addition & 1 deletion src/bin/naming-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"

[dependencies]
naming = { path = "../../lib/naming" }
naming-core = { path = "../../lib/naming/naming-core" }
Loading

0 comments on commit b12a4d5

Please sign in to comment.