Panic upon use of unsupported flags
This commit is contained in:
parent
6ad843184d
commit
0b2fd79816
|
@ -46,6 +46,10 @@ pub fn brk(address: usize) -> Result<usize> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const CLONE_VM: usize = 0x100;
|
||||||
|
pub const CLONE_FS: usize = 0x200;
|
||||||
|
pub const CLONE_FILES: usize = 0x400;
|
||||||
|
pub const CLONE_VFORK: usize = 0x4000;
|
||||||
pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
|
pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
|
||||||
//TODO: Implement flags
|
//TODO: Implement flags
|
||||||
//TODO: Copy on write?
|
//TODO: Copy on write?
|
||||||
|
@ -78,38 +82,42 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
|
||||||
kstack_option = Some(new_stack);
|
kstack_option = Some(new_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
for memory in context.image.iter() {
|
if flags & CLONE_VM == CLONE_VM {
|
||||||
let mut new_memory = context::memory::Memory::new(
|
panic!("unimplemented: CLONE_VM");
|
||||||
VirtualAddress::new(memory.start_address().get() + arch::USER_TMP_OFFSET),
|
} else {
|
||||||
memory.size(),
|
for memory in context.image.iter() {
|
||||||
entry::PRESENT | entry::NO_EXECUTE | entry::WRITABLE,
|
let mut new_memory = context::memory::Memory::new(
|
||||||
true,
|
VirtualAddress::new(memory.start_address().get() + arch::USER_TMP_OFFSET),
|
||||||
false
|
memory.size(),
|
||||||
);
|
entry::PRESENT | entry::NO_EXECUTE | entry::WRITABLE,
|
||||||
unsafe {
|
true,
|
||||||
arch::externs::memcpy(new_memory.start_address().get() as *mut u8,
|
false
|
||||||
memory.start_address().get() as *const u8,
|
);
|
||||||
memory.size());
|
unsafe {
|
||||||
|
arch::externs::memcpy(new_memory.start_address().get() as *mut u8,
|
||||||
|
memory.start_address().get() as *const u8,
|
||||||
|
memory.size());
|
||||||
|
}
|
||||||
|
new_memory.remap(memory.flags(), true);
|
||||||
|
image.push(new_memory);
|
||||||
}
|
}
|
||||||
new_memory.remap(memory.flags(), true);
|
|
||||||
image.push(new_memory);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(ref heap) = context.heap {
|
if let Some(ref heap) = context.heap {
|
||||||
let mut new_heap = context::memory::Memory::new(
|
let mut new_heap = context::memory::Memory::new(
|
||||||
VirtualAddress::new(arch::USER_TMP_HEAP_OFFSET),
|
VirtualAddress::new(arch::USER_TMP_HEAP_OFFSET),
|
||||||
heap.size(),
|
heap.size(),
|
||||||
entry::PRESENT | entry::NO_EXECUTE | entry::WRITABLE,
|
entry::PRESENT | entry::NO_EXECUTE | entry::WRITABLE,
|
||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
unsafe {
|
unsafe {
|
||||||
arch::externs::memcpy(new_heap.start_address().get() as *mut u8,
|
arch::externs::memcpy(new_heap.start_address().get() as *mut u8,
|
||||||
heap.start_address().get() as *const u8,
|
heap.start_address().get() as *const u8,
|
||||||
heap.size());
|
heap.size());
|
||||||
|
}
|
||||||
|
new_heap.remap(heap.flags(), true);
|
||||||
|
heap_option = Some(new_heap);
|
||||||
}
|
}
|
||||||
new_heap.remap(heap.flags(), true);
|
|
||||||
heap_option = Some(new_heap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref stack) = context.stack {
|
if let Some(ref stack) = context.stack {
|
||||||
|
@ -129,24 +137,28 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
|
||||||
stack_option = Some(new_stack);
|
stack_option = Some(new_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (fd, file_option) in context.files.iter().enumerate() {
|
if flags & CLONE_FILES == CLONE_FILES {
|
||||||
if let Some(file) = *file_option {
|
panic!("unimplemented: CLONE_FILES");
|
||||||
let result = {
|
} else {
|
||||||
let schemes = scheme::schemes();
|
for (fd, file_option) in context.files.iter().enumerate() {
|
||||||
let scheme_mutex = schemes.get(file.scheme).ok_or(Error::BadFile)?;
|
if let Some(file) = *file_option {
|
||||||
let result = scheme_mutex.lock().dup(file.number);
|
let result = {
|
||||||
result
|
let schemes = scheme::schemes();
|
||||||
};
|
let scheme_mutex = schemes.get(file.scheme).ok_or(Error::BadFile)?;
|
||||||
match result {
|
let result = scheme_mutex.lock().dup(file.number);
|
||||||
Ok(new_number) => {
|
result
|
||||||
files.push(Some(context::file::File { scheme: file.scheme, number: new_number }));
|
};
|
||||||
},
|
match result {
|
||||||
Err(err) => {
|
Ok(new_number) => {
|
||||||
println!("clone: failed to dup {}: {:?}", fd, err);
|
files.push(Some(context::file::File { scheme: file.scheme, number: new_number }));
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
println!("clone: failed to dup {}: {:?}", fd, err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
files.push(None);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
files.push(None);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
libstd
2
libstd
|
@ -1 +1 @@
|
||||||
Subproject commit eaad8f520ce853c15c2071eff08ed813e87118fa
|
Subproject commit 00920975234a9bc774ad6e33efd57a56a40c0ee8
|
Loading…
Reference in a new issue