mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2025-12-23 22:47:55 -05:00
formatting
This commit is contained in:
committed by
Ashwin Naren
parent
0a32eeaaa0
commit
9db6162414
@@ -512,7 +512,7 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::fs::{InodeId, FileType, attr::FilePermissions};
|
||||
use crate::fs::{FileType, InodeId, attr::FilePermissions};
|
||||
use crate::memory::{
|
||||
PAGE_SIZE,
|
||||
address::IdentityTranslator,
|
||||
@@ -654,7 +654,7 @@ mod tests {
|
||||
assert_eq!(read, 10);
|
||||
// "12345" + 5 zeros
|
||||
assert_eq!(&buf[..5], b"12345");
|
||||
assert_eq!(&buf[5..], &[0,0,0,0,0]);
|
||||
assert_eq!(&buf[5..], &[0, 0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -663,11 +663,14 @@ mod tests {
|
||||
let root = fs.root_inode().await.unwrap();
|
||||
|
||||
// Create a file
|
||||
let file_inode = root.create(
|
||||
"test_file.txt",
|
||||
FileType::File,
|
||||
FilePermissions::from_bits_retain(0),
|
||||
).await.expect("Create failed");
|
||||
let file_inode = root
|
||||
.create(
|
||||
"test_file.txt",
|
||||
FileType::File,
|
||||
FilePermissions::from_bits_retain(0),
|
||||
)
|
||||
.await
|
||||
.expect("Create failed");
|
||||
|
||||
// Lookup
|
||||
let found = root.lookup("test_file.txt").await.expect("Lookup failed");
|
||||
@@ -683,9 +686,13 @@ mod tests {
|
||||
let fs = setup_fs();
|
||||
let root = fs.root_inode().await.unwrap();
|
||||
|
||||
root.create("dup", FileType::File, FilePermissions::from_bits_retain(0)).await.unwrap();
|
||||
root.create("dup", FileType::File, FilePermissions::from_bits_retain(0))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let res = root.create("dup", FileType::File, FilePermissions::empty()).await;
|
||||
let res = root
|
||||
.create("dup", FileType::File, FilePermissions::empty())
|
||||
.await;
|
||||
assert!(res.is_err(), "Should not allow duplicate file creation");
|
||||
}
|
||||
|
||||
@@ -695,12 +702,16 @@ mod tests {
|
||||
let root = fs.root_inode().await.unwrap();
|
||||
|
||||
// Create /subdir
|
||||
let subdir = root.create("subdir", FileType::Directory, FilePermissions::empty())
|
||||
.await.unwrap();
|
||||
let subdir = root
|
||||
.create("subdir", FileType::Directory, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create /subdir/inner
|
||||
let inner = subdir.create("inner", FileType::File, FilePermissions::empty())
|
||||
.await.unwrap();
|
||||
let inner = subdir
|
||||
.create("inner", FileType::File, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Verify hierarchy
|
||||
let found_subdir = root.lookup("subdir").await.unwrap();
|
||||
@@ -714,9 +725,15 @@ mod tests {
|
||||
let root = fs.root_inode().await.unwrap();
|
||||
|
||||
// Create files in "random" order
|
||||
root.create("c.txt", FileType::File, FilePermissions::empty()).await.unwrap();
|
||||
root.create("a.txt", FileType::File, FilePermissions::empty()).await.unwrap();
|
||||
root.create("b.dir", FileType::Directory, FilePermissions::empty()).await.unwrap();
|
||||
root.create("c.txt", FileType::File, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
root.create("a.txt", FileType::File, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
root.create("b.dir", FileType::Directory, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut dir_stream = root.readdir(0).await.expect("Readdir failed");
|
||||
|
||||
@@ -738,8 +755,14 @@ mod tests {
|
||||
let fs = setup_fs();
|
||||
let root = fs.root_inode().await.unwrap();
|
||||
|
||||
let f1 = root.create("f1", FileType::File, FilePermissions::empty()).await.unwrap();
|
||||
let f2 = root.create("f2", FileType::File, FilePermissions::empty()).await.unwrap();
|
||||
let f1 = root
|
||||
.create("f1", FileType::File, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
let f2 = root
|
||||
.create("f2", FileType::File, FilePermissions::empty())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_ne!(f1.id(), f2.id());
|
||||
assert_ne!(f1.id(), root.id());
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
use crate::{arch::ArchImpl, drivers::Driver, fs::FilesystemDriver, memory::{PageOffsetTranslator, page::PgAllocGetter}};
|
||||
use crate::{
|
||||
arch::ArchImpl,
|
||||
drivers::Driver,
|
||||
fs::FilesystemDriver,
|
||||
memory::{PageOffsetTranslator, page::PgAllocGetter},
|
||||
};
|
||||
use alloc::{boxed::Box, sync::Arc};
|
||||
use async_trait::async_trait;
|
||||
use libkernel::{
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use crate::{process::fd_table::Fd, sched::current_task};
|
||||
use libkernel::{
|
||||
error::{KernelError, Result},
|
||||
};
|
||||
use libkernel::error::{KernelError, Result};
|
||||
|
||||
pub async fn sys_ftruncate(fd: Fd, new_size: usize) -> Result<usize> {
|
||||
let fd = current_task()
|
||||
|
||||
@@ -13,4 +13,5 @@ impl PageAllocGetter<ArchImpl> for PgAllocGetter {
|
||||
}
|
||||
}
|
||||
|
||||
pub type ClaimedPage = libkernel::memory::page::ClaimedPage<ArchImpl, PgAllocGetter, PageOffsetTranslator>;
|
||||
pub type ClaimedPage =
|
||||
libkernel::memory::page::ClaimedPage<ArchImpl, PgAllocGetter, PageOffsetTranslator>;
|
||||
|
||||
Reference in New Issue
Block a user