Plan directeur 14 phases / 5 ans (REDOX_COSMIC_XWAYLAND_RS_PLAN.md).
Phase 1 — Audit Redox (docs/existing-redox-gui.md, 486 lignes) :
- Orbital, graphics-ipc (API DRM compatible Linux subset KMS), inputd, vesad
- relibc support : AF_UNIX, SCM_RIGHTS, shm_open, mmap, poll
- 3 manques identifiés : memfd_create, keymap XKB, AT-SPI
Phase 2 — Validation primitives sur Redox via redoxer (5 tests + 1 POC) :
- test-unix-socket : SOCK_STREAM Wayland-shaped roundtrip
- test-fd-passing : SCM_RIGHTS mono-process (artefact kernel)
- test-fd-passing-fork : SCM_RIGHTS multi-process (validation Wayland critique)
- test-shm-open : shm_open + mmap + persistance + unlink
- test-poll-multifd : poll() multiplexing + POLLHUP
- poc-pixels : datapath shm + SCM_RIGHTS bout en bout (10000 pixels ARGB)
Phase 3 — wayland-rs sur Redox (compile + runtime) :
- wayland-{scanner,backend,server,client} compilent pour x86_64-unknown-redox
sans patch upstream (rustix supporte Redox via libc backend)
- test-handshake : server/client wl_registry handshake roundtrip
- test-shm-pipeline : pipeline complet (ListeningSocket Unix réel + fd passing
via wl_shm.create_pool + wl_shm_pool + wl_buffer + wl_surface + commit +
serveur lit pixels via fd reçu, validation pixel-perfect)
Verdict phase 3 : wayland-rs upstream est viable sur Redox out-of-the-box,
le port "Wayland sur Redox" est désormais un problème de compositor à écrire,
pas de stack à porter.
Prérequis build : redoxer (pas cargo direct, car CMSG_NXTHDR/CMSG_DATA
ne sont pas linkés autrement vers librelibc.a).
Leyoda 2026 – GPLv3
78 lines
2.7 KiB
Rust
78 lines
2.7 KiB
Rust
//! Test 1 — Unix socket SOCK_STREAM with Wayland-shaped messages.
|
|
//!
|
|
//! Wayland wire format (libwayland reference):
|
|
//! - Header: object_id (u32) + (size << 16 | opcode) (u32) = 8 bytes
|
|
//! - Payload: variable, 4-byte aligned
|
|
//!
|
|
//! This test:
|
|
//! 1. Creates a SOCK_STREAM socketpair (AF_UNIX)
|
|
//! 2. Side A sends a message with header + payload
|
|
//! 3. Side B reads it back, validates byte-for-byte
|
|
//! 4. Ensures partial reads don't corrupt the stream
|
|
|
|
use std::io::{Read, Write};
|
|
use std::os::unix::net::UnixStream;
|
|
use std::process::ExitCode;
|
|
|
|
const OBJECT_ID: u32 = 0x0000_0001;
|
|
const OPCODE: u16 = 0x000A;
|
|
const PAYLOAD: &[u8] = b"hello-wayland-on-redox-roundtrip";
|
|
|
|
fn main() -> ExitCode {
|
|
println!("[test-01] Unix socket SOCK_STREAM Wayland-shaped roundtrip");
|
|
|
|
let (mut a, mut b) = match UnixStream::pair() {
|
|
Ok(pair) => pair,
|
|
Err(e) => {
|
|
eprintln!("[test-01] FAIL: UnixStream::pair: {e}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
|
|
let payload_len = PAYLOAD.len();
|
|
let aligned_len = (payload_len + 3) & !3;
|
|
let total_size = 8 + aligned_len;
|
|
|
|
let mut msg = Vec::with_capacity(total_size);
|
|
msg.extend_from_slice(&OBJECT_ID.to_ne_bytes());
|
|
let size_op: u32 = ((total_size as u32) << 16) | (OPCODE as u32);
|
|
msg.extend_from_slice(&size_op.to_ne_bytes());
|
|
msg.extend_from_slice(PAYLOAD);
|
|
msg.resize(total_size, 0);
|
|
|
|
if let Err(e) = a.write_all(&msg) {
|
|
eprintln!("[test-01] FAIL: write_all: {e}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
println!("[test-01] sent {} bytes (header 8 + payload {} aligned to {})",
|
|
total_size, payload_len, aligned_len);
|
|
|
|
let mut header = [0u8; 8];
|
|
if let Err(e) = b.read_exact(&mut header) {
|
|
eprintln!("[test-01] FAIL: read header: {e}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
let recv_oid = u32::from_ne_bytes(header[0..4].try_into().unwrap());
|
|
let recv_so = u32::from_ne_bytes(header[4..8].try_into().unwrap());
|
|
let recv_size = (recv_so >> 16) as usize;
|
|
let recv_op = (recv_so & 0xFFFF) as u16;
|
|
|
|
if recv_oid != OBJECT_ID || recv_op != OPCODE || recv_size != total_size {
|
|
eprintln!("[test-01] FAIL: header mismatch oid={recv_oid:#x} op={recv_op:#x} size={recv_size}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
|
|
let mut buf = vec![0u8; aligned_len];
|
|
if let Err(e) = b.read_exact(&mut buf) {
|
|
eprintln!("[test-01] FAIL: read payload: {e}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
if &buf[..payload_len] != PAYLOAD {
|
|
eprintln!("[test-01] FAIL: payload mismatch");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
|
|
println!("[test-01] PASS: roundtrip OK, {} bytes recv, oid={:#x} op={:#x}",
|
|
total_size, recv_oid, recv_op);
|
|
ExitCode::SUCCESS
|
|
}
|