使用DragonReach启动shell,修改getdents (#391)

* 使用DragonReach启动shell,修改getdents

* 更改关闭pipe时断言报错问题,以及DragonReach启动shell阶段版本

* 修改目录结构

* update

* 解决小问题

* 调整dragon reach版本号

* 设置make clean的时候不清空应用程序的缓存。
指定relibc版本号

---------

Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
GnoCiYeH 2023-09-30 16:36:06 +08:00 committed by GitHub
parent 0dd8ff4332
commit bb0e4d4131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 85 additions and 18 deletions

View File

@ -7,7 +7,7 @@ use crate::driver::pci::pci::{
use crate::driver::pci::pci_irq::{IrqCommonMsg, IrqMsg, IrqSpecificMsg, PciInterrupt, IRQ}; use crate::driver::pci::pci_irq::{IrqCommonMsg, IrqMsg, IrqSpecificMsg, PciInterrupt, IRQ};
use crate::include::bindings::bindings::pt_regs; use crate::include::bindings::bindings::pt_regs;
use crate::kdebug;
use crate::libs::volatile::{ use crate::libs::volatile::{
volread, volwrite, ReadOnly, Volatile, VolatileReadable, VolatileWritable, WriteOnly, volread, volwrite, ReadOnly, Volatile, VolatileReadable, VolatileWritable, WriteOnly,
}; };

View File

@ -277,8 +277,6 @@ impl File {
self.offset += 1; self.offset += 1;
dirent.d_ino = sub_inode.metadata().unwrap().inode_id.into() as u64; dirent.d_ino = sub_inode.metadata().unwrap().inode_id.into() as u64;
dirent.d_off = 0;
dirent.d_reclen = 0;
dirent.d_type = sub_inode.metadata().unwrap().file_type.get_file_type_num() as u8; dirent.d_type = sub_inode.metadata().unwrap().file_type.get_file_type_num() as u8;
// 根据posix的规定dirent中的d_name是一个不定长的数组因此需要unsafe来拷贝数据 // 根据posix的规定dirent中的d_name是一个不定长的数组因此需要unsafe来拷贝数据
unsafe { unsafe {
@ -289,8 +287,13 @@ impl File {
} }
// 计算dirent结构体的大小 // 计算dirent结构体的大小
return Ok((name_bytes.len() + ::core::mem::size_of::<Dirent>() let size = (name_bytes.len() + ::core::mem::size_of::<Dirent>()
- ::core::mem::size_of_val(&dirent.d_name)) as u64); - ::core::mem::size_of_val(&dirent.d_name)) as u64;
dirent.d_reclen = size as u16;
dirent.d_off += dirent.d_reclen as i64;
return Ok(size);
} }
pub fn inode(&self) -> Arc<dyn IndexNode> { pub fn inode(&self) -> Arc<dyn IndexNode> {

View File

@ -182,13 +182,13 @@ impl ProcessManager {
let new_fd_table = current_pcb.basic().fd_table().unwrap().read().clone(); let new_fd_table = current_pcb.basic().fd_table().unwrap().read().clone();
let new_fd_table = Arc::new(RwLock::new(new_fd_table)); let new_fd_table = Arc::new(RwLock::new(new_fd_table));
new_pcb.basic_mut().set_fd_table(Some(new_fd_table)); new_pcb.basic_mut().set_fd_table(Some(new_fd_table));
} else {
// 如果共享文件描述符表,则直接拷贝指针
new_pcb
.basic_mut()
.set_fd_table(current_pcb.basic().fd_table().clone());
} }
// 如果共享文件描述符表,则直接拷贝指针
new_pcb
.basic_mut()
.set_fd_table(current_pcb.basic().fd_table().clone());
return Ok(()); return Ok(());
} }

View File

@ -36,9 +36,9 @@ pub fn initial_kernel_thread() -> i32 {
/// 切换到用户态 /// 切换到用户态
fn switch_to_user() { fn switch_to_user() {
let path = String::from("/bin/shell.elf"); let path = String::from("/bin/DragonReach");
let argv = vec![String::from("/bin/shell.elf")]; let argv = vec![String::from("/bin/DragonReach")];
let envp = vec![String::from("PATH=/bin")]; let envp = vec![String::from("PATH=/")];
unsafe { arch_switch_to_user(path, argv, envp) }; unsafe { arch_switch_to_user(path, argv, envp) };
} }

View File

@ -14,7 +14,7 @@ current_CFLAGS := $(CFLAGS)
DADK_VERSION=$(shell dadk -V | awk 'END {print $$2}') DADK_VERSION=$(shell dadk -V | awk 'END {print $$2}')
# 最小的DADK版本 # 最小的DADK版本
MIN_DADK_VERSION = 0.1.2 MIN_DADK_VERSION = 0.1.3
DADK_CACHE_DIR = $(ROOT_PATH)/bin/dadk_cache DADK_CACHE_DIR = $(ROOT_PATH)/bin/dadk_cache
# 旧版的libc安装路径 # 旧版的libc安装路径
@ -57,8 +57,9 @@ dadk_run: install_dadk
.PHONY: dadk_clean .PHONY: dadk_clean
dadk_clean: install_dadk dadk_clean: install_dadk
dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean src # 不运行dadk clean的原因是把clean的工作交给应用程序自己去做这样可以节省编译时间
dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean target #dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean src
#dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean target
$(user_sub_dirs): ECHO sys_api_lib $(user_sub_dirs): ECHO sys_api_lib

View File

@ -0,0 +1,29 @@
{
"name": "DragonReach",
"version": "0.1.0",
"description": "init程序",
"task_type": {
"BuildFromSource": {
"Git": {
"url" : "https://git.mirrors.dragonos.org/DragonOS-Community/DragonReach.git",
"revision": "4aac1004fa"
}
}
},
"depends": [],
"build": {
"build_command": "make install"
},
"clean": {
"clean_command": "make clean"
},
"install": {
"in_dragonos_path": "/"
},
"envs": [
{
"key": "TARGET",
"value": "${ROOT_PATH}/user/dadk/target/x86_64-unknown-dragonos.json"
}
]
}

View File

@ -6,8 +6,7 @@
"BuildFromSource": { "BuildFromSource": {
"Git": { "Git": {
"url": "https://git.mirrors.dragonos.org/DragonOS-Community/relibc.git", "url": "https://git.mirrors.dragonos.org/DragonOS-Community/relibc.git",
"branch": "dragonos-relibc", "revision": "26536e7fcd"
"revision": null
} }
} }
}, },

View File

@ -0,0 +1,35 @@
{
"arch": "x86_64",
"code-model": "kernel",
"cpu": "x86-64",
"os": "dragonos",
"target-endian": "little",
"target-pointer-width": "64",
"target-family": [
"unix"
],
"env": "musl",
"target-c-int-width": "32",
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
"disable-redzone": true,
"features": "-3dnow,-3dnowa,-avx,-avx2",
"linker": "rust-lld",
"linker-flavor": "ld.lld",
"llvm-target": "x86_64-unknown-none",
"max-atomic-width": 64,
"panic-strategy": "abort",
"position-independent-executables": true,
"relro-level": "full",
"stack-probes": {
"kind": "inline-or-call",
"min-llvm-version-for-inline": [
16,
0,
0
]
},
"static-position-independent-executables": true,
"supported-sanitizers": [
"kcfi"
]
}