Change io crate & add a small shell
This commit is contained in:
6
user/agetty/Cargo.toml
Normal file
6
user/agetty/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "agetty"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
29
user/agetty/src/main.rs
Normal file
29
user/agetty/src/main.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
#![allow(unused)]
|
||||
#![feature(survos_std)]
|
||||
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Stdin, Write, stdin, stdout};
|
||||
use std::os::fd::FromRawFd;
|
||||
|
||||
fn main() {
|
||||
// Close descriptor 0
|
||||
let f = unsafe { File::from_raw_fd(0) };
|
||||
drop(f);
|
||||
|
||||
// Close descriptor 1
|
||||
let f = unsafe { File::from_raw_fd(1) };
|
||||
drop(f);
|
||||
|
||||
// Open new input and output
|
||||
let mut input = File::open("/dev/tty0");
|
||||
let mut tty = File::open("/dev/tty0");
|
||||
|
||||
std::process::Command::new("/usr/bin/shell")
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
std::thread::yield_now();
|
||||
}
|
||||
}
|
||||
7
user/fastfetch/Cargo.toml
Normal file
7
user/fastfetch/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "fastfetch"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
owo-colors = "4.3.0"
|
||||
21
user/fastfetch/src/main.rs
Normal file
21
user/fastfetch/src/main.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
// #![feature(survos_std)]
|
||||
|
||||
use owo_colors::OwoColorize;
|
||||
|
||||
fn main() {
|
||||
println!(
|
||||
"{}",
|
||||
r" ___ ___ ___ ___ ___
|
||||
/ /\ /__/\ / /\ ___ / /\ / /\
|
||||
/ /:/_ \ \:\ / /::\ /__/\ / /::\ / /:/_
|
||||
/ /:/ /\ \ \:\ / /:/\:\ \ \:\ / /:/\:\ / /:/ /\
|
||||
/ /:/ /::\ ___ \ \:\ / /:/~/:/ \ \:\ / /:/ \:\ / /:/ /::\
|
||||
/__/:/ /:/\:/__/\ \__\:/__/:/ /:/______ \__\:/__/:/ \__\:/__/:/ /:/\:\
|
||||
\ \:\/:/~/:\ \:\ / /:\ \:\/:::::/__/\ | |:\ \:\ / /:\ \:\/:/~/:/
|
||||
\ \::/ /:/ \ \:\ /:/ \ \::/~~~~\ \:\| |:|\ \:\ /:/ \ \::/ /:/
|
||||
\__\/ /:/ \ \:\/:/ \ \:\ \ \:\__|:| \ \:\/:/ \__\/ /:/
|
||||
/__/:/ \ \::/ \ \:\ \__\::::/ \ \::/ /__/:/
|
||||
\__\/ \__\/ \__\/ ~~~~ \__\/ \__\/ "
|
||||
.cyan()
|
||||
);
|
||||
}
|
||||
@@ -4,5 +4,4 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
# shared = { path = "../../crates/shared", features = ["user"] }
|
||||
# core = { path = "../../crates/std/crates/core" }
|
||||
winnow = "1.0.0"
|
||||
|
||||
@@ -1,11 +1,57 @@
|
||||
// use std::io::_print;
|
||||
// #![feature(survos_std)]
|
||||
|
||||
use std::io::{Read, Write, stdin, stdout};
|
||||
|
||||
fn main() {
|
||||
let a = std::env::args();
|
||||
for a in a {
|
||||
println!("Argument: {}", a);
|
||||
}
|
||||
println!(
|
||||
"Hello from PIC program loaded dynamically with custom std and a better justfile, and syscalls ! "
|
||||
);
|
||||
std::process::Command::new("fastfetch")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
|
||||
let mut current_command = String::new();
|
||||
|
||||
fn new_line() {
|
||||
print!("> ");
|
||||
stdout().flush().unwrap();
|
||||
}
|
||||
|
||||
new_line();
|
||||
|
||||
loop {
|
||||
let mut test = [0; 4];
|
||||
let len = stdin().read(&mut test).unwrap();
|
||||
let input = str::from_utf8(&test[..len as usize]).unwrap();
|
||||
|
||||
for c in input.chars() {
|
||||
if c == '\n' {
|
||||
println!();
|
||||
let mut args = current_command.split(" ");
|
||||
std::process::Command::new(args.next().unwrap())
|
||||
.args(args)
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
current_command.clear();
|
||||
new_line();
|
||||
} else {
|
||||
if if c == '\x08' {
|
||||
current_command.pop().is_some()
|
||||
} else {
|
||||
current_command.push_str(input);
|
||||
true
|
||||
} {
|
||||
print!("{}", input);
|
||||
}
|
||||
}
|
||||
}
|
||||
stdout().flush().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// fn parse_command(input: &mut &str) {}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "test_pic"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
# std = { path = "../../crates/std" }
|
||||
shared = { path = "../../crates/shared", features = ["user"] }
|
||||
io = { path = "../../crates/io" }
|
||||
bffs = { path = "../../crates/bffs" }
|
||||
@@ -1,23 +0,0 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
use shared::{fs::File, syscall};
|
||||
use std::io::{Read, Stdin, Write, stdin, stdout};
|
||||
|
||||
fn main() {
|
||||
syscall::close(0);
|
||||
let mut tty = unsafe { File::from_raw_fd(syscall::open("/dev/tty0")) };
|
||||
syscall::close(1);
|
||||
let _ = syscall::open("/dev/tty0");
|
||||
println!("test from test_pic");
|
||||
syscall::spawn("/usr/bin/shell");
|
||||
// panic!("explicit panic");
|
||||
// std::process::abort();
|
||||
// unsafe {core::arch::asm!("unimp")};
|
||||
loop {
|
||||
let mut test = [0; 4];
|
||||
let len = stdin().read(&mut test).unwrap();
|
||||
print!("{}", str::from_utf8(&test[..len as usize]).unwrap());
|
||||
stdout().flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user