Require UTF-8 for context name
This commit is contained in:
+15
-10
@@ -1,10 +1,15 @@
|
||||
use alloc::sync::Arc;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::collections::VecDeque;
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::cmp::Ordering;
|
||||
use core::mem;
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
collections::VecDeque,
|
||||
string::String,
|
||||
sync::Arc,
|
||||
vec::Vec,
|
||||
};
|
||||
use core::{
|
||||
alloc::{GlobalAlloc, Layout},
|
||||
cmp::Ordering,
|
||||
mem,
|
||||
};
|
||||
use spin::{Mutex, RwLock};
|
||||
|
||||
use crate::arch::{interrupt::InterruptStack, paging::PAGE_SIZE};
|
||||
@@ -112,7 +117,7 @@ pub struct ContextSnapshot {
|
||||
pub syscall: Option<(usize, usize, usize, usize, usize, usize)>,
|
||||
// Clone fields
|
||||
//TODO: is there a faster way than allocation?
|
||||
pub name: Box<[u8]>,
|
||||
pub name: Box<str>,
|
||||
pub files: Vec<Option<FileDescription>>,
|
||||
// pub cwd: Box<[u8]>,
|
||||
}
|
||||
@@ -230,7 +235,7 @@ pub struct Context {
|
||||
/// User grants
|
||||
pub grants: Arc<Mutex<UserGrants>>,
|
||||
/// The name of the context
|
||||
pub name: Arc<RwLock<Box<[u8]>>>,
|
||||
pub name: Arc<RwLock<Box<str>>>,
|
||||
/// The current working directory
|
||||
pub cwd: Arc<Mutex<Vec<u8>>>,
|
||||
/// The open files in the scheme
|
||||
@@ -287,7 +292,7 @@ impl Context {
|
||||
sigstack: None,
|
||||
tls: None,
|
||||
grants: Arc::new(Mutex::new(UserGrants::default())),
|
||||
name: Arc::new(RwLock::new(Vec::new().into_boxed_slice())),
|
||||
name: Arc::new(RwLock::new(String::new().into_boxed_str())),
|
||||
cwd: Arc::new(Mutex::new(Vec::new())),
|
||||
files: Arc::new(Mutex::new(Vec::new())),
|
||||
actions: Arc::new(Mutex::new(vec![(
|
||||
|
||||
@@ -13,7 +13,7 @@ unsafe fn update(context: &mut Context, cpu_id: usize) {
|
||||
// Take ownership if not already owned
|
||||
if context.cpu_id == None {
|
||||
context.cpu_id = Some(cpu_id);
|
||||
// println!("{}: take {} {}", cpu_id, context.id, ::core::str::from_utf8_unchecked(&context.name.read()));
|
||||
// println!("{}: take {} {}", cpu_id, context.id, *context.name.read());
|
||||
}
|
||||
|
||||
// Restore from signal, must only be done from another context to avoid overwriting the stack!
|
||||
|
||||
Reference in New Issue
Block a user