修改shell执行exec时传参错误问题 (#399)

* 修改shell执行exec时传参错误问题
This commit is contained in:
GnoCiYeH
2023-10-09 01:10:14 +08:00
committed by GitHub
parent b7b843bedd
commit 865f4ba4cd
3 changed files with 11 additions and 4 deletions

View File

@ -197,6 +197,7 @@ pub fn load_binary_file(param: &mut ExecParam) -> Result<BinaryLoaderResult, Sys
/// 程序初始化信息,这些信息会被压入用户栈中
#[derive(Debug)]
pub struct ProcInitInfo {
pub proc_name: String,
pub args: Vec<String>,
pub envs: Vec<String>,
pub auxv: BTreeMap<u8, usize>,
@ -205,6 +206,7 @@ pub struct ProcInitInfo {
impl ProcInitInfo {
pub fn new() -> Self {
Self {
proc_name: String::new(),
args: Vec::new(),
envs: Vec::new(),
auxv: BTreeMap::new(),
@ -222,7 +224,7 @@ impl ProcInitInfo {
ustack: &mut UserStack,
) -> Result<(VirtAddr, VirtAddr), SystemError> {
// 先把程序的名称压入栈中
self.push_str(ustack, self.args[0].as_str())?;
self.push_str(ustack, &self.proc_name)?;
// 然后把环境变量压入栈中
let envps = self

View File

@ -630,8 +630,8 @@ impl ProcessControlBlock {
}
/// 生成进程的名字
pub fn generate_name(_program_path: &str, args: &Vec<String>) -> String {
let mut name = "".to_string();
pub fn generate_name(program_path: &str, args: &Vec<String>) -> String {
let mut name = program_path.to_string();
for arg in args {
name.push_str(arg);
name.push(' ');