Merge branch 'misc_changes' into 'main'
Couple of misc changes See merge request redox-os/base!226
This commit is contained in:
Generated
+39
-1
@@ -337,6 +337,17 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chacha20"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cpufeatures",
|
||||
"rand_core 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chashmap"
|
||||
version = "2.2.2"
|
||||
@@ -423,6 +434,15 @@ version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "3.4.0"
|
||||
@@ -883,6 +903,7 @@ dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"rand_core 0.10.1",
|
||||
"wasip2",
|
||||
"wasip3",
|
||||
]
|
||||
@@ -1124,7 +1145,7 @@ dependencies = [
|
||||
"daemon",
|
||||
"libc",
|
||||
"libredox",
|
||||
"rand 0.8.5",
|
||||
"rand 0.10.1",
|
||||
"redox-scheme",
|
||||
"redox_event",
|
||||
"redox_syscall 0.7.3",
|
||||
@@ -1643,6 +1664,17 @@ dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207"
|
||||
dependencies = [
|
||||
"chacha20",
|
||||
"getrandom 0.4.2",
|
||||
"rand_core 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
@@ -1693,6 +1725,12 @@ dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
||||
|
||||
[[package]]
|
||||
name = "randd"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -32,6 +32,6 @@ pub fn enable_msix(pcid_handle: &mut PciFunctionHandle) -> Result<File, Error> {
|
||||
|
||||
pcid_handle.enable_feature(PciFeature::MsiX);
|
||||
|
||||
log::info!("virtio: using MSI-X (interrupt_handle={interrupt_handle:?})");
|
||||
log::debug!("virtio: using MSI-X (interrupt_handle={interrupt_handle:?})");
|
||||
Ok(interrupt_handle)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ pub fn probe_device(pcid_handle: &mut PciFunctionHandle) -> Result<Device, Error
|
||||
assert!(has_msix, "virtio: device does not support MSI-X");
|
||||
let irq_handle = crate::arch::enable_msix(pcid_handle)?;
|
||||
|
||||
log::info!("virtio: using standard PCI transport");
|
||||
log::debug!("virtio: using standard PCI transport");
|
||||
|
||||
let device = Device {
|
||||
transport,
|
||||
|
||||
@@ -650,7 +650,7 @@ impl Transport for StandardTransport<'_> {
|
||||
&mut *(self.notify.add(offset as usize) as *mut AtomicU16)
|
||||
};
|
||||
|
||||
log::info!("virtio-core: enabled queue #{queue_index} (size={queue_size})");
|
||||
log::debug!("virtio-core: enabled queue #{queue_index} (size={queue_size})");
|
||||
|
||||
let queue = Queue::new(
|
||||
descriptor,
|
||||
|
||||
+1
-19
@@ -1,7 +1,6 @@
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use crate::InitConfig;
|
||||
use crate::script::Command;
|
||||
use crate::unit::{Unit, UnitId, UnitKind, UnitStore};
|
||||
|
||||
pub struct Scheduler {
|
||||
@@ -88,7 +87,7 @@ fn run(unit: &mut Unit, config: &mut InitConfig) {
|
||||
if config.log_debug {
|
||||
eprintln!("init: running: {cmd:?}");
|
||||
}
|
||||
run_command(cmd, config);
|
||||
cmd.run(config);
|
||||
}
|
||||
}
|
||||
UnitKind::Service { service } => {
|
||||
@@ -115,20 +114,3 @@ fn run(unit: &mut Unit, config: &mut InitConfig) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run_command(cmd: Command, config: &mut InitConfig) {
|
||||
match cmd {
|
||||
Command::Service(service) => {
|
||||
if config.skip_cmd.contains(&service.cmd) {
|
||||
eprintln!(
|
||||
"init: skipping '{} {}'",
|
||||
service.cmd,
|
||||
service.args.join(" ")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
service.spawn(&config.envs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-25
@@ -1,7 +1,7 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::collections::BTreeMap;
|
||||
use std::{env, io, iter};
|
||||
|
||||
use crate::service::{Service, ServiceType};
|
||||
use crate::InitConfig;
|
||||
use crate::unit::UnitId;
|
||||
|
||||
pub fn subst_env<'a>(arg: &str) -> String {
|
||||
@@ -39,8 +39,15 @@ impl Script {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Command {
|
||||
Service(Service),
|
||||
pub struct Command {
|
||||
process: Process,
|
||||
kind: CommandKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum CommandKind {
|
||||
Oneshot,
|
||||
OneshotAsync,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
@@ -59,35 +66,67 @@ impl Command {
|
||||
}
|
||||
"nowait" => {
|
||||
let process = Process::parse(args)?;
|
||||
|
||||
Ok(Some(Command::Service(Service {
|
||||
cmd: process.cmd,
|
||||
args: process.args,
|
||||
envs: process.envs,
|
||||
inherit_envs: BTreeSet::new(),
|
||||
type_: ServiceType::OneshotAsync,
|
||||
})))
|
||||
Ok(Some(Command {
|
||||
process,
|
||||
kind: CommandKind::OneshotAsync,
|
||||
}))
|
||||
}
|
||||
_ => {
|
||||
let process = Process::parse(iter::once(cmd).chain(args))?;
|
||||
|
||||
Ok(Some(Command::Service(Service {
|
||||
cmd: process.cmd,
|
||||
args: process.args,
|
||||
envs: process.envs,
|
||||
inherit_envs: BTreeSet::new(),
|
||||
type_: ServiceType::Oneshot,
|
||||
})))
|
||||
Ok(Some(Command {
|
||||
process,
|
||||
kind: CommandKind::Oneshot,
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(&self, config: &mut InitConfig) {
|
||||
let Command { process, kind } = self;
|
||||
|
||||
if config.skip_cmd.contains(&process.cmd) {
|
||||
eprintln!(
|
||||
"init: skipping '{} {}'",
|
||||
process.cmd,
|
||||
process.args.join(" ")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let mut command = std::process::Command::new(&process.cmd);
|
||||
command.args(process.args.iter().map(|arg| subst_env(arg)));
|
||||
command.env_clear();
|
||||
command.envs(&config.envs).envs(&process.envs);
|
||||
|
||||
let mut child = match command.spawn() {
|
||||
Ok(child) => child,
|
||||
Err(err) => {
|
||||
eprintln!("init: failed to execute {:?}: {}", command, err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
match kind {
|
||||
CommandKind::Oneshot => match child.wait() {
|
||||
Ok(exit_status) => {
|
||||
if !exit_status.success() {
|
||||
eprintln!("init: {command:?} failed with {exit_status}");
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("init: failed to wait for {:?}: {}", command, err)
|
||||
}
|
||||
},
|
||||
CommandKind::OneshotAsync => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Process {
|
||||
pub cmd: String,
|
||||
pub args: Vec<String>,
|
||||
pub envs: BTreeMap<String, String>,
|
||||
#[derive(Clone, Debug)]
|
||||
struct Process {
|
||||
cmd: String,
|
||||
args: Vec<String>,
|
||||
envs: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
impl Process {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ scheme-utils = { path = "../scheme-utils" }
|
||||
redox_event.workspace = true
|
||||
anyhow.workspace = true
|
||||
libc.workspace = true
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand = "0.10"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -8,7 +8,7 @@ use super::{
|
||||
use libc::{AF_UNIX, SO_DOMAIN, SO_PASSCRED};
|
||||
use libredox::protocol::SocketCall;
|
||||
use rand::rngs::SmallRng;
|
||||
use rand::{RngCore, SeedableRng};
|
||||
use rand::Rng;
|
||||
use redox_scheme::{
|
||||
scheme::SchemeSync, CallerCtx, OpenResult, RecvFdRequest, Response, SendFdRequest,
|
||||
SignalBehavior, Socket as SchemeSocket,
|
||||
@@ -151,7 +151,7 @@ impl<'sock> UdsDgramScheme<'sock> {
|
||||
0,
|
||||
)?
|
||||
},
|
||||
rng: SmallRng::from_entropy(),
|
||||
rng: rand::make_rng(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ impl<'sock> UdsStreamScheme<'sock> {
|
||||
0,
|
||||
)?
|
||||
},
|
||||
rng: SmallRng::from_entropy(),
|
||||
rng: rand::make_rng(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+8
-10
@@ -22,11 +22,15 @@ fn daemon(daemon: daemon::SchemeDaemon) -> ! {
|
||||
.next_request(SignalBehavior::Restart)
|
||||
.expect("logd: failed to read events from log scheme")
|
||||
{
|
||||
let request = match request.kind() {
|
||||
RequestKind::Call(call) => call,
|
||||
match request.kind() {
|
||||
RequestKind::Call(call) => {
|
||||
let response = call.handle_sync(&mut scheme, &mut state);
|
||||
socket
|
||||
.write_response(response, SignalBehavior::Restart)
|
||||
.expect("logd: failed to write responses to log scheme");
|
||||
}
|
||||
RequestKind::OnClose { id } => {
|
||||
scheme.on_close(id);
|
||||
continue;
|
||||
}
|
||||
RequestKind::SendFd(sendfd_request) => {
|
||||
let result = scheme.on_sendfd(&sendfd_request);
|
||||
@@ -34,15 +38,9 @@ fn daemon(daemon: daemon::SchemeDaemon) -> ! {
|
||||
socket
|
||||
.write_response(resp, SignalBehavior::Restart)
|
||||
.expect("logd: failed to write responses to log scheme");
|
||||
continue;
|
||||
}
|
||||
_ => continue,
|
||||
_ => {}
|
||||
};
|
||||
|
||||
let response = request.handle_sync(&mut scheme, &mut state);
|
||||
socket
|
||||
.write_response(response, SignalBehavior::Restart)
|
||||
.expect("logd: failed to write responses to log scheme");
|
||||
}
|
||||
process::exit(0);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ mod notifier;
|
||||
|
||||
use redox_scheme::{
|
||||
scheme::{register_scheme_inner, SchemeState, SchemeSync},
|
||||
CallerCtx, OpenResult, RequestKind, Response, SignalBehavior, Socket,
|
||||
CallerCtx, OpenResult, RequestKind, SignalBehavior, Socket,
|
||||
};
|
||||
use scheme_utils::HandleMap;
|
||||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address};
|
||||
@@ -386,33 +386,22 @@ impl NetCfgScheme {
|
||||
}
|
||||
};
|
||||
|
||||
let req = match request.kind() {
|
||||
RequestKind::Call(c) => c,
|
||||
match request.kind() {
|
||||
RequestKind::Call(c) => {
|
||||
let resp = c.handle_sync(&mut self.inner, &mut self.state);
|
||||
let _ = self
|
||||
.inner
|
||||
.scheme_file
|
||||
.write_response(resp, SignalBehavior::Restart)
|
||||
.map_err(|e| {
|
||||
Error::from_syscall_error(e.into(), "failed to write response")
|
||||
})?;
|
||||
}
|
||||
RequestKind::OnClose { id } => {
|
||||
self.inner.on_close(id);
|
||||
continue;
|
||||
}
|
||||
_ => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let caller = req.caller();
|
||||
let op = match req.op() {
|
||||
Ok(op) => op,
|
||||
Err(req) => {
|
||||
self.inner.scheme_file.write_response(
|
||||
Response::err(syscall::EOPNOTSUPP, req),
|
||||
SignalBehavior::Restart,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let resp = op.handle_sync(caller, &mut self.inner, &mut self.state);
|
||||
let _ = self
|
||||
.inner
|
||||
.scheme_file
|
||||
.write_response(resp, SignalBehavior::Restart)
|
||||
.map_err(|e| Error::from_syscall_error(e.into(), "failed to write response"))?;
|
||||
_ => {}
|
||||
}
|
||||
};
|
||||
self.inner.notify_scheduled_fds();
|
||||
Ok(result)
|
||||
|
||||
Reference in New Issue
Block a user