fix some bugs

This commit is contained in:
Yuke Peng 2022-08-28 19:53:14 -07:00
parent 5359879499
commit d31d5f0bde
3 changed files with 4 additions and 5 deletions

View File

@ -48,9 +48,9 @@ impl VmSpace {
if options.perm.contains(VmPerm::W) {
flags.insert(PTFlags::WRITABLE);
}
if options.perm.contains(VmPerm::U) {
// if options.perm.contains(VmPerm::U) {
flags.insert(PTFlags::USER);
}
// }
if options.addr.is_none() {
return Err(Error::InvalidArgs);
}

View File

@ -70,8 +70,7 @@ pub fn sys_write(fd: u64, user_buf_ptr: u64, user_buf_len: u64) -> SyscallResult
let user_buffer =
copy_bytes_from_user(user_space, user_buf_ptr as usize, user_buf_len as usize)
.expect("read user buffer failed");
let content = CString::from_vec_with_nul(user_buffer).expect("read string failed");
// TODO: print content
let content = alloc::str::from_utf8(user_buffer.as_slice()).expect("Invalid content"); // TODO: print content
info!("Message from user mode: {:?}", content);
SyscallResult::Return(0)
} else {

View File

@ -3,7 +3,7 @@ global _start
section .text
_start:
mov rax, 64 ; syswrite
mov rax, 1 ; syswrite
mov rdi, 1 ; fd
mov rsi, msg ; "Hello, world!\n",
mov rdx, msglen ; sizeof("Hello, world!\n")