Skip to content

Commit

Permalink
udpate to nightly-2023-12-01; fix several outdated code
Browse files Browse the repository at this point in the history
  • Loading branch information
scPointer committed Jun 6, 2024
1 parent e66b48c commit 989b541
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 21 deletions.
3 changes: 1 addition & 2 deletions kernel/src/file/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ type FsFile = fatfs::File<'static, FsIO, FsTP, FsOCC>;
type FATFileSystem = FileSystem<FsIO, FsTP, FsOCC>;

use base_file::{File, OpenFlags};
pub use fat_dir::FatDir;
pub use fat_file::FatFile;
pub use fd_dir::FdDir;
pub use link::FileDisc;
pub use link::{
get_link_count, mount_fat_fs, read_link, try_add_link, try_add_rev_link, try_remove_link,
get_link_count, mount_fat_fs, read_link, try_add_link, try_remove_link,
umount_fat_fs,
};
pub use stat::get_fs_stat as origin_fs_stat;
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/file/vfs/virt_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl VirtDir {
let entry: Vec<DirEntry> = self
.entry
.lock()
.drain_filter(|e| e.name == *file_name)
.extract_if(|e| e.name == *file_name)
.collect();
if entry.len() == 0 {
//没找到文件
Expand Down
8 changes: 2 additions & 6 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#![feature(panic_info_message)]
#![feature(naked_functions, asm_const)]
// MemorySet 处理相交的 VmArea 时需要
#![feature(btree_drain_filter)]
#![feature(btree_extract_if)]
// test.rs 输入 argv 需要
#![feature(drain_filter)]
#![feature(extract_if)]

#[macro_use]
extern crate log;
Expand Down Expand Up @@ -43,10 +43,6 @@ extern crate fatfs;
extern crate fscommon;
extern crate lock;

mod fsio {
pub use fscommon::{Read, Seek, Write};
}

core::arch::global_asm!(include_str!("fs.S"));

use alloc::sync::Arc;
Expand Down
8 changes: 4 additions & 4 deletions kernel/src/syscall/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn sys_bind(fd: usize, addr: *const u8, addr_len: usize) -> SysResult {
}
let fd_manager = task.fd_manager.lock();
if let Ok(file) = fd_manager.get_file(fd) {
let sock = file.as_any().downcast_ref::<Socket>().unwrap().clone();
let sock = file.as_any().downcast_ref::<Socket>().unwrap();
if let Some(_p) = sock.set_endpoint(addr, false) {
Ok(0)
} else {
Expand All @@ -133,7 +133,7 @@ pub fn sys_listen(fd: usize, backlog: usize) -> SysResult {
let task = get_current_task().unwrap();
let fd_manager = task.fd_manager.lock();
if let Ok(file) = fd_manager.get_file(fd) {
let sock = file.as_any().downcast_ref::<Socket>().unwrap().clone();
let sock = file.as_any().downcast_ref::<Socket>().unwrap();
sock.set_listening(true);
Ok(0)
} else {
Expand All @@ -152,7 +152,7 @@ pub fn sys_connect(fd: usize, addr: *const u8, addr_len: usize) -> SysResult {

let fd_manager = task.fd_manager.lock();
if let Ok(file) = fd_manager.get_file(fd) {
let sock = file.as_any().downcast_ref::<Socket>().unwrap().clone();
let sock = file.as_any().downcast_ref::<Socket>().unwrap();
let laddr = IpAddr {
family: 2,
port: 0,
Expand Down Expand Up @@ -238,7 +238,7 @@ pub fn sys_accept4(fd: usize, addr: *mut u8, addr_len: *mut u32, flags: i32) ->
}

//设置好远程endpoint
let sock = file.as_any().downcast_ref::<Socket>().unwrap().clone();
let sock = file.as_any().downcast_ref::<Socket>().unwrap();
sock.set_endpoint(addr, true).unwrap_or(0);

// New Socket
Expand Down
4 changes: 2 additions & 2 deletions kernel/src/testcases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[allow(dead_code)]
pub const TESTCASES: &[&str] = &[
//"busybox sh",
"busybox sh",

// 运行 redis 示例(不是在这里打开,而是在 busybox sh 的终端中输入)
//"./redis-server /redis.conf --loglevel verbose &", // 打开 redis 服务端,后台运行
Expand All @@ -22,7 +22,7 @@ pub const TESTCASES: &[&str] = &[
//"busybox hexdump -C 2.o",

// 测 lua 或者 busybox 的时候**不要**打开 base_info,内核输出非常多
"busybox sh lua_testcode.sh", // lua 测例
//"busybox sh lua_testcode.sh", // lua 测例
//"busybox sh busybox_testcode.sh", // busybox 测例
//"busybox sh lmbench_testcode.sh", // lmbench 测例(见下)

Expand Down
2 changes: 1 addition & 1 deletion modified_dependencies/rust-fatfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ default = ["chrono", "std", "alloc", "lfn", "unicode", "log_level_trace"]

[dependencies]
bitflags = "1.0"
log = "0.4"
log = { path = "../../dependencies/log", version = "0.4" }
chrono = { version = "0.4", optional = true }
lock = { path = "../../dependencies/kernel-sync" }
fscommon = { path = "../fscommon", version = "0.1.1"}
Expand Down
2 changes: 1 addition & 1 deletion modules/range-action-map/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "range-action-map"
version = "0.1.6"
version = "0.2.0"
authors = ["scpointer <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions modules/range-action-map/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
//!
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(btree_drain_filter)]
#![feature(btree_extract_if)]

#[cfg(feature = "std")]
mod external {
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<SegmentType: Segment> RangeActionMap<SegmentType> {
// 所以如果仅相交而不需要删除,就需要放回 self.areas
let areas_to_be_modified: Vec<RangeArea<SegmentType>> = self
.segments
.drain_filter(|_, area| area.is_overlap_with(start, end))
.extract_if(|_, area| area.is_overlap_with(start, end))
.map(|(_, v)| v)
.collect();
for mut area in areas_to_be_modified {
Expand All @@ -284,7 +284,7 @@ impl<SegmentType: Segment> RangeActionMap<SegmentType> {
// 所以如果仅相交而不需要删除,就需要放回 self.areas
let areas_to_be_modified: Vec<RangeArea<SegmentType>> = self
.segments
.drain_filter(|_, area| area.is_overlap_with(start, end))
.extract_if(|_, area| area.is_overlap_with(start, end))
.map(|(_, v)| v)
.collect();
for mut area in areas_to_be_modified {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
profile = "minimal"
channel = "nightly-2023-03-07"
channel = "nightly-2023-12-01"
components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"]
targets = ["riscv64imac-unknown-none-elf"]

0 comments on commit 989b541

Please sign in to comment.