base: fix round-8 deferred stubs in initfs, randd, ptyd

initfs/tools: buffer inode table writes in memory and flush with a
  single write_all_at instead of one syscall per inode header.

randd: build a proper entropy pool using SHA-256 that mixes hardware RNG
  (RDRAND/RNDRRS) with timing-derived entropy. The pool is re-seeded
  every 4096 reads and on every write. User-supplied entropy from writes
  is added to the pool rather than directly replacing the PRNG state.

ptyd: VLNEXT now properly quotes the next input byte — sets a flag that
  causes the next byte to bypass all control-character processing and be
  pushed directly to the line buffer. VDISCARD now flushes the cooked
  input buffer instead of being a silent no-op.
This commit is contained in:
Red Bear OS
2026-07-27 09:16:33 +09:00
parent 4ba511830f
commit 7d40dff006
3 changed files with 116 additions and 73 deletions
+19 -6
View File
@@ -14,6 +14,7 @@ pub struct Pty {
pub mosi: VecDeque<Vec<u8>>,
pub timeout_count: u64,
pub timeout_character: Option<u64>,
pub lnext: bool,
}
impl Pty {
@@ -28,6 +29,7 @@ impl Pty {
mosi: VecDeque::new(),
timeout_count: 0,
timeout_character: None,
lnext: false,
}
}
@@ -65,6 +67,18 @@ impl Pty {
for &byte in buf.iter() {
let mut b = byte;
if self.lnext {
self.lnext = false;
if b != 0 {
if echo {
self.output(&[b]);
}
self.timeout_character = Some(self.timeout_count);
self.cooked.push(b);
}
continue;
}
// Input translation
if b == b'\n' {
if inlcr {
@@ -220,16 +234,15 @@ impl Pty {
}
if is_cc(b, VLNEXT) && iexten {
// VLNEXT quotes the next input byte so control characters
// can be entered literally. Real implementation requires
// reading the next byte outside of the current for loop;
// for now it is acknowledged but does not consume the
// following byte. Cross-referenced with POSIX termios(3).
self.lnext = true;
if echoe {
self.output(&[b]);
}
b = 0;
}
if is_cc(b, VDISCARD) && iexten {
// Toggle output flushing; not fully implemented in this PTY.
self.cooked.clear();
b = 0;
}