From c811947dd02a63a9802ce779dea3c1f853d9a3cf Mon Sep 17 00:00:00 2001 From: longjin Date: Wed, 2 Nov 2022 15:54:04 +0800 Subject: [PATCH] =?UTF-8?q?new:=20=E5=B0=86=E5=8F=AF=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=A7=BB=E5=8A=A8=E5=88=B0bin=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/process/process.c | 8 +++----- run.sh | 4 +++- user/apps/shell/cmd.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/process/process.c b/kernel/process/process.c index ca92e8e6..e8978121 100644 --- a/kernel/process/process.c +++ b/kernel/process/process.c @@ -155,7 +155,7 @@ struct vfs_file_t *process_open_exec_file(char *path) { struct vfs_dir_entry_t *dentry = NULL; struct vfs_file_t *filp = NULL; - + // kdebug("path=%s", path); dentry = vfs_path_walk(path, 0); if (dentry == NULL) @@ -191,7 +191,7 @@ static int process_load_elf_file(struct pt_regs *regs, char *path) if ((long)filp <= 0 && (long)filp >= -255) { - // kdebug("(long)filp=%ld", (long)filp); + kdebug("(long)filp=%ld", (long)filp); return (unsigned long)filp; } @@ -533,12 +533,10 @@ ul initial_kernel_thread(ul arg) current_pcb->flags = 0; // 将返回用户层的代码压入堆栈,向rdx传入regs的地址,然后jmp到do_execve这个系统调用api的处理函数 // 这里的设计思路和switch_proc类似 加载用户态程序:shell.elf - char init_path[] = "/shell.elf"; - uint64_t addr = (uint64_t)&init_path; __asm__ __volatile__("movq %1, %%rsp \n\t" "pushq %2 \n\t" "jmp do_execve \n\t" ::"D"(current_pcb->thread->rsp), - "m"(current_pcb->thread->rsp), "m"(current_pcb->thread->rip), "S"("/shell.elf"), "c"(NULL), + "m"(current_pcb->thread->rsp), "m"(current_pcb->thread->rip), "S"("/bin/shell.elf"), "c"(NULL), "d"(NULL) : "memory"); diff --git a/run.sh b/run.sh index e8a63485..7d93660f 100755 --- a/run.sh +++ b/run.sh @@ -108,8 +108,10 @@ if [ "${GENERATE_ISO}" == "1" ]; then mkdir -p ${boot_folder}/grub cp ${kernel} ${root_folder}/bin/disk_mount/boot # 拷贝用户程序到磁盘镜像 - cp -r ${root_folder}/bin/user/* ${root_folder}/bin/disk_mount + mkdir -p ${root_folder}/bin/disk_mount/bin mkdir -p ${root_folder}/bin/disk_mount/dev + + cp -r ${root_folder}/bin/user/* ${root_folder}/bin/disk_mount/bin touch ${root_folder}/bin/disk_mount/dev/keyboard.dev diff --git a/user/apps/shell/cmd.c b/user/apps/shell/cmd.c index e1efebab..071cc0ca 100644 --- a/user/apps/shell/cmd.c +++ b/user/apps/shell/cmd.c @@ -494,7 +494,7 @@ int shell_cmd_about(int argc, char **argv) unsigned char input_buffer[INPUT_BUFFER_SIZE] = {0}; - strcpy(input_buffer, "exec /about.elf\0"); + strcpy(input_buffer, "exec /bin/about.elf\0"); parse_command(input_buffer, &aac, &aav);