Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kernel/src/driver/virtio/transport_pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::driver::pci::pci::{

use crate::driver::pci::pci_irq::{IrqCommonMsg, IrqMsg, IrqSpecificMsg, PciInterrupt, IRQ};
use crate::include::bindings::bindings::pt_regs;
use crate::kdebug;

use crate::libs::volatile::{
volread, volwrite, ReadOnly, Volatile, VolatileReadable, VolatileWritable, WriteOnly,
};
Expand Down
11 changes: 7 additions & 4 deletions kernel/src/filesystem/vfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ impl File {

self.offset += 1;
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;
// 根据posix的规定,dirent中的d_name是一个不定长的数组,因此需要unsafe来拷贝数据
unsafe {
Expand All @@ -289,8 +287,13 @@ impl File {
}

// 计算dirent结构体的大小
return Ok((name_bytes.len() + ::core::mem::size_of::<Dirent>()
- ::core::mem::size_of_val(&dirent.d_name)) as u64);
let size = (name_bytes.len() + ::core::mem::size_of::<Dirent>()
- ::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> {
Expand Down
10 changes: 5 additions & 5 deletions kernel/src/process/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ impl ProcessManager {
let new_fd_table = current_pcb.basic().fd_table().unwrap().read().clone();
let new_fd_table = Arc::new(RwLock::new(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(());
}

Expand Down
6 changes: 3 additions & 3 deletions kernel/src/process/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub fn initial_kernel_thread() -> i32 {

/// 切换到用户态
fn switch_to_user() {
let path = String::from("/bin/shell.elf");
let argv = vec![String::from("/bin/shell.elf")];
let envp = vec![String::from("PATH=/bin")];
let path = String::from("/bin/DragonReach");
let argv = vec![String::from("/bin/DragonReach")];
let envp = vec![String::from("PATH=/")];

unsafe { arch_switch_to_user(path, argv, envp) };
}
7 changes: 4 additions & 3 deletions user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ current_CFLAGS := $(CFLAGS)

DADK_VERSION=$(shell dadk -V | awk 'END {print $$2}')
# 最小的DADK版本
MIN_DADK_VERSION = 0.1.2
MIN_DADK_VERSION = 0.1.3
DADK_CACHE_DIR = $(ROOT_PATH)/bin/dadk_cache

# 旧版的libc安装路径
Expand Down Expand Up @@ -57,8 +57,9 @@ dadk_run: install_dadk

.PHONY: dadk_clean
dadk_clean: install_dadk
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
# 不运行dadk clean的原因是,把clean的工作交给应用程序自己去做,这样可以节省编译时间
#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

Expand Down
29 changes: 29 additions & 0 deletions user/dadk/config/dragon_reach-0.1.0.dadk
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
3 changes: 1 addition & 2 deletions user/dadk/config/relibc-0.1.0.dadk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"BuildFromSource": {
"Git": {
"url": "https://git.mirrors.dragonos.org/DragonOS-Community/relibc.git",
"branch": "dragonos-relibc",
"revision": null
"revision": "26536e7fcd"
}
}
},
Expand Down
35 changes: 35 additions & 0 deletions user/dadk/target/x86_64-unknown-dragonos.json
Original file line number Diff line number Diff line change
@@ -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"
]
}