You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
531 B
Rust
21 lines
531 B
Rust
2 years ago
|
//! File and filesystem-related syscalls
|
||
|
|
||
|
use crate::print;
|
||
|
|
||
|
const FD_STDOUT: usize = 1;
|
||
|
|
||
|
/// write buf of length `len` to a file with `fd`
|
||
|
pub fn sys_write(fd: usize, buf: *const u8, len: usize) -> isize {
|
||
|
match fd {
|
||
|
FD_STDOUT => {
|
||
|
let slice = unsafe { core::slice::from_raw_parts(buf, len) };
|
||
|
let str = core::str::from_utf8(slice).unwrap();
|
||
|
print!("{}", str);
|
||
|
len as isize
|
||
|
}
|
||
|
_ => {
|
||
|
panic!("Unsupported fd in sys_write!");
|
||
|
}
|
||
|
}
|
||
|
}
|