chore: monorepo inicial con arje + minga + yahweh absorbidos
Workspace en 4 ejes (core/modules/apps/shared):
- core/: 24 crates de arje (Init systemd-compatible: ente-card, ente-zero,
ente-kernel, ente-bus, ente-cas, ente-soma, ente-wasm, ente-snapshot,
ente-brain, ente-echo, ente-policy-provider, + 12 crates *-compat)
- modules/semantic_dht/: 5 crates de minga (minga-core con AST/CAS/MST,
minga-p2p con libp2p Kad, minga-store, minga-vfs, minga-cli)
- modules/ui_engine/: 11 crates de yahweh (libs/{core,theme,bus,providers},
widgets/{tree,splitter,tabs,tiled,container_core,text_input})
- apps/: 5 crates de yahweh (file_explorer, database_explorer, text_viewer,
image_viewer, yahweh-shell)
- shared_wit/protocol.wit: handshake/lifecycle inicial
Cargo.toml unificado: thiserror bumped a 2 (transparente para arje), tokio
"full", paths intra-workspace de yahweh redirigidos a su nueva ubicación.
cargo check --workspace: 0 errores, 17 warnings (dead code preexistente).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
//! Bootstrap del entorno kernel para PID 1: monta procfs/sysfs/devtmpfs/cgroup2
|
||||
//! y registra al proceso como subreaper para adoptar huérfanos.
|
||||
//!
|
||||
//! Idempotente: si los puntos de montaje ya existen (initramfs los montó),
|
||||
//! el segundo mount falla con EBUSY y simplemente lo ignoramos.
|
||||
|
||||
use anyhow::Context;
|
||||
use nix::mount::{mount, MsFlags};
|
||||
use tracing::debug;
|
||||
|
||||
/// Monta los pseudo-filesystems esenciales. Errores benignos (ya montados)
|
||||
/// se ignoran; errores serios se propagan.
|
||||
pub fn bootstrap_kernel_surface() -> anyhow::Result<()> {
|
||||
// Cada uno con sus flags estándar — NOSUID/NOEXEC/NODEV donde aplica.
|
||||
mount::<str, str, str, str>(
|
||||
Some("proc"), "/proc", Some("proc"),
|
||||
MsFlags::MS_NOSUID | MsFlags::MS_NOEXEC | MsFlags::MS_NODEV, None,
|
||||
).ok();
|
||||
mount::<str, str, str, str>(
|
||||
Some("sysfs"), "/sys", Some("sysfs"),
|
||||
MsFlags::MS_NOSUID | MsFlags::MS_NOEXEC | MsFlags::MS_NODEV, None,
|
||||
).ok();
|
||||
mount::<str, str, str, str>(
|
||||
Some("devtmpfs"), "/dev", Some("devtmpfs"),
|
||||
MsFlags::MS_NOSUID, None,
|
||||
).ok();
|
||||
mount::<str, str, str, str>(
|
||||
Some("cgroup2"), "/sys/fs/cgroup", Some("cgroup2"),
|
||||
MsFlags::MS_NOSUID | MsFlags::MS_NOEXEC | MsFlags::MS_NODEV, None,
|
||||
).ok();
|
||||
debug!("kernel surface bootstrap completo");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// PR_SET_CHILD_SUBREAPER: que adoptemos huérfanos del fractal.
|
||||
///
|
||||
/// En PID 1 esto es redundante (el kernel ya lo hace), pero se deja explícito
|
||||
/// para que ente-zero corriendo como sub-init en un container mantenga la
|
||||
/// misma semántica.
|
||||
pub fn become_child_subreaper() -> anyhow::Result<()> {
|
||||
let r = unsafe { libc::prctl(libc::PR_SET_CHILD_SUBREAPER, 1u64, 0u64, 0u64, 0u64) };
|
||||
if r != 0 {
|
||||
anyhow::bail!(
|
||||
"prctl PR_SET_CHILD_SUBREAPER falló: {}",
|
||||
std::io::Error::last_os_error()
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Cosechar zombis hasta vaciar la cola de niños muertos. Devuelve los
|
||||
/// PIDs cosechados con su estado, como tuplas.
|
||||
pub fn reap_all() -> Vec<ReapedChild> {
|
||||
use nix::errno::Errno;
|
||||
use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus};
|
||||
let mut out = Vec::new();
|
||||
loop {
|
||||
match waitpid(None, Some(WaitPidFlag::WNOHANG)) {
|
||||
Ok(WaitStatus::Exited(pid, code)) => {
|
||||
out.push(ReapedChild { pid: pid.as_raw(), status: ReapStatus::Exited(code) });
|
||||
}
|
||||
Ok(WaitStatus::Signaled(pid, sig, _core)) => {
|
||||
out.push(ReapedChild { pid: pid.as_raw(), status: ReapStatus::Signaled(sig as i32) });
|
||||
}
|
||||
Ok(WaitStatus::StillAlive) => return out,
|
||||
Err(Errno::ECHILD) => return out,
|
||||
Err(_) => return out,
|
||||
Ok(_) => continue, // Stopped/Continued — irrelevantes
|
||||
}
|
||||
}
|
||||
// unreachable, satisface al borrow checker
|
||||
#[allow(unreachable_code)]
|
||||
out
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReapedChild {
|
||||
pub pid: i32,
|
||||
pub status: ReapStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ReapStatus {
|
||||
Exited(i32),
|
||||
Signaled(i32),
|
||||
}
|
||||
Reference in New Issue
Block a user