Skip to content

Commit 1677256

Browse files
authored
Merge pull request #2389 from fogti/factor-root-fs-big-leap
refactor(fs): Prepare root filesystem in big leap before applying it globally
2 parents ff4d8aa + 8140a12 commit 1677256

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/fs/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,17 @@ pub(crate) fn init() {
304304
const VERSION: &str = env!("CARGO_PKG_VERSION");
305305
const UTC_BUILT_TIME: &str = build_time::build_time_utc!();
306306

307-
FILESYSTEM.set(Filesystem::new()).unwrap();
308-
FILESYSTEM
309-
.get()
310-
.unwrap()
307+
let root_filesystem = Filesystem::new();
308+
309+
root_filesystem
311310
.mkdir("/tmp", AccessPermission::from_bits(0o777).unwrap())
312311
.expect("Unable to create /tmp");
313-
FILESYSTEM
314-
.get()
315-
.unwrap()
312+
root_filesystem
316313
.mkdir("/proc", AccessPermission::from_bits(0o777).unwrap())
317314
.expect("Unable to create /proc");
318315

316+
FILESYSTEM.set(root_filesystem).unwrap();
317+
319318
if let Ok(mut file) = File::create("/proc/version") {
320319
if write!(file, "Hermit version {VERSION} # UTC {UTC_BUILT_TIME}").is_err() {
321320
error!("Unable to write in /proc/version");
@@ -324,12 +323,11 @@ pub(crate) fn init() {
324323
error!("Unable to create /proc/version");
325324
}
326325

327-
let mut cwd = WORKING_DIRECTORY.lock();
328-
*cwd = Some("/tmp".to_owned());
329-
drop(cwd);
326+
*WORKING_DIRECTORY.lock() = Some("/tmp".to_owned());
330327

331328
#[cfg(feature = "virtio-fs")]
332329
virtio_fs::init();
330+
333331
if crate::env::is_uhyve() {
334332
uhyve::init();
335333
}

0 commit comments

Comments
 (0)