Use file as default scheme from the start
This removes one piece of state that init has to manage for the processes it spawns. This also allows getting rid of the concept of a default scheme from relibc if we want.
This commit is contained in:
@@ -90,7 +90,7 @@ pub fn main() -> ! {
|
||||
// from this point, this_thr_fd is no longer valid
|
||||
|
||||
const CWD: &[u8] = b"/scheme/initfs";
|
||||
const DEFAULT_SCHEME: &[u8] = b"initfs";
|
||||
const DEFAULT_SCHEME: &[u8] = b"file";
|
||||
let extrainfo = ExtraInfo {
|
||||
cwd: Some(CWD),
|
||||
default_scheme: Some(DEFAULT_SCHEME),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Various daemons that relibc needs to function as well as a bunch of env vars
|
||||
# that should be set for every program.
|
||||
export PATH /bin
|
||||
export PATH /scheme/initfs/bin
|
||||
export RUST_BACKTRACE 1
|
||||
rtcd
|
||||
nulld
|
||||
@@ -34,7 +34,6 @@ redoxfs --uuid $REDOXFS_UUID file $REDOXFS_BLOCK
|
||||
unset REDOXFS_UUID REDOXFS_BLOCK REDOXFS_PASSWORD_ADDR REDOXFS_PASSWORD_SIZE
|
||||
|
||||
# Exit initfs
|
||||
set-default-scheme file
|
||||
cd /
|
||||
export PATH /usr/bin
|
||||
run.d /usr/lib/init.d /etc/init.d
|
||||
|
||||
+1
-38
@@ -1,33 +1,12 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::env;
|
||||
use std::ffi::CString;
|
||||
use std::fs::{read_dir, File};
|
||||
use std::io::{BufRead, BufReader, Result};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use libredox::error::Error as OsError;
|
||||
|
||||
use libredox::flag::{O_RDONLY, O_WRONLY};
|
||||
|
||||
fn set_default_scheme(scheme: &str) -> std::result::Result<(), OsError> {
|
||||
use std::ffi::{c_char, c_int};
|
||||
|
||||
extern "C" {
|
||||
fn set_default_scheme(scheme: *const c_char) -> c_int;
|
||||
}
|
||||
|
||||
let cstr =
|
||||
CString::new(scheme.as_bytes()).expect(&format!("init: invalid default scheme {}", scheme));
|
||||
|
||||
let res = unsafe { set_default_scheme(cstr.as_ptr()) };
|
||||
|
||||
match res {
|
||||
0 => Ok(()),
|
||||
error_code => Err(OsError::new(error_code)),
|
||||
}
|
||||
}
|
||||
|
||||
fn switch_stdio(stdio: &str) -> Result<()> {
|
||||
let stdin = libredox::Fd::open(stdio, O_RDONLY, 0)?;
|
||||
let stdout = libredox::Fd::open(stdio, O_WRONLY, 0)?;
|
||||
@@ -66,18 +45,6 @@ pub fn run(file: &Path) -> Result<()> {
|
||||
println!("init: failed to cd: no argument");
|
||||
}
|
||||
}
|
||||
"set-default-scheme" => {
|
||||
if let Some(scheme) = args.next() {
|
||||
if let Err(err) = set_default_scheme(&scheme) {
|
||||
println!(
|
||||
"init: failed to set default scheme to '{}': {}",
|
||||
scheme, err
|
||||
);
|
||||
}
|
||||
} else {
|
||||
println!("init: failed to set default scheme: no argument");
|
||||
}
|
||||
}
|
||||
"echo" => {
|
||||
if let Some(arg) = args.next() {
|
||||
print!("{}", arg);
|
||||
@@ -224,11 +191,7 @@ pub fn run(file: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
if let Err(err) = set_default_scheme("initfs") {
|
||||
println!("init: failed to set default scheme: {}", err);
|
||||
}
|
||||
|
||||
let config = "/etc/init.rc";
|
||||
let config = "/scheme/initfs/etc/init.rc";
|
||||
if let Err(err) = run(&Path::new(config)) {
|
||||
println!("init: failed to run {}: {}", config, err);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
ps2d us
|
||||
hwd
|
||||
pcid-spawner /etc/pcid/initfs.toml
|
||||
pcid-spawner /scheme/initfs/etc/pcid/initfs.toml
|
||||
|
||||
Reference in New Issue
Block a user