new: 将可执行文件移动到bin目录下

This commit is contained in:
longjin 2022-11-02 15:54:04 +08:00
parent 31b7b49d8c
commit c811947dd0
3 changed files with 7 additions and 7 deletions

View File

@ -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");

4
run.sh
View File

@ -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

View File

@ -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);