Skip to content

Commit

Permalink
stat: Fill modification/creation time and access mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalmiel committed Oct 22, 2023
1 parent fddf5f8 commit 29a61c3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
20 changes: 10 additions & 10 deletions cykusz-rs/src/drivers/tty/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,16 @@ impl OutputBuffer {

let bytes = str.as_bytes();

log4!("[tty in]: ");
for b in bytes {
let c = *b as char;
if c.is_ascii_alphabetic() || c.is_ascii_punctuation() {
log4!("{}", c);
} else {
log4!("{}", *b);
}
}
log4!("\n");
//log4!("[tty in]: ");
//for b in bytes {
// let c = *b as char;
// if c.is_ascii_alphabetic() || c.is_ascii_punctuation() {
// log4!("{}", c);
// } else {
// log4!("{}", *b);
// }
//}
//log4!("\n");

for c in bytes.iter() {
self.state.advance(&mut performer, *c);
Expand Down
4 changes: 4 additions & 0 deletions cykusz-rs/src/kernel/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ impl CachedBlockDev for BlockDevice {

logln!("Syncing... finished");
}

fn id(&self) -> usize {
self.id
}
}

pub fn sync_all() {
Expand Down
4 changes: 4 additions & 0 deletions cykusz-rs/src/kernel/fs/ext2/disk/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ impl INode {
let mask = 0b1111_1111_1111;
self.type_and_perm = (self.type_and_perm & !mask) | (perm & mask);
}
pub fn perm(&self) -> u16 {
let mask = 0b1111_1111_1111;
self.type_and_perm & mask
}
pub fn user_id(&self) -> u16 {
self.user_id
}
Expand Down
18 changes: 13 additions & 5 deletions cykusz-rs/src/kernel/fs/ext2/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl LockedExt2INode {
*inner = disk::inode::INode::default();

inner.set_ftype(typ.into());
inner.set_perm(0o755);
inner.set_perm(0o644);
inner.set_user_id(0);
inner.set_group_id(0);

Expand Down Expand Up @@ -534,12 +534,19 @@ impl INode for LockedExt2INode {
let inode = self.read_debug(28);

stat.st_ino = inode.id as u64;
//stat.st_dev = self.device().unwrap().id() as u64;
stat.st_dev = self.ext2_fs().dev().id() as u64;
stat.st_nlink = inode.d_inode.hl_count() as u32;
stat.st_blksize = self.ext2_fs().superblock().block_size() as u64;
stat.st_blocks = inode.d_inode.sector_count() as u64;
stat.st_size = inode.d_inode.size_lower() as i64;

stat.st_atim =
syscall_defs::time::Timespec::from_secs(inode.d_inode.last_access() as usize);
stat.st_mtim =
syscall_defs::time::Timespec::from_secs(inode.d_inode.last_modification() as usize);
stat.st_ctim =
syscall_defs::time::Timespec::from_secs(inode.d_inode.creation_time() as usize);

let ftype = inode.ftype();
if ftype == FileType::File {
stat.st_mode.insert(syscall_defs::stat::Mode::IFREG);
Expand All @@ -551,9 +558,10 @@ impl INode for LockedExt2INode {
stat.st_mode.insert(syscall_defs::stat::Mode::IFCHR);
}

stat.st_mode.insert(syscall_defs::stat::Mode::IRWXU);
stat.st_mode.insert(syscall_defs::stat::Mode::IRWXG);
stat.st_mode.insert(syscall_defs::stat::Mode::IRWXO);
stat.st_mode
.insert(syscall_defs::stat::Mode::from_bits_truncate(
inode.d_inode.perm() as u32,
));

Ok(stat)
}
Expand Down
1 change: 1 addition & 0 deletions cykusz-rs/src/kernel/fs/ext2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloc::sync::{Arc, Weak};
use crate::kernel::block::BlockDev;
use spin::Once;
use uuid::Uuid;
use crate::kernel::device::Device;

use crate::kernel::fs::dirent::{DirEntry, DirEntryItem};
use crate::kernel::fs::ext2::buf_block::{BufBlock, SliceBlock};
Expand Down
2 changes: 2 additions & 0 deletions cykusz-rs/src/kernel/fs/pcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ pub trait CachedBlockDev: CachedAccess {
fn notify_dirty_inode(&self, _page: &PageCacheItemArc);
fn notify_clean_inode(&self, _page: &PageCacheItem);
fn sync_all(&self);

fn id(&self) -> usize;
}

pub enum MMapPage {
Expand Down

0 comments on commit 29a61c3

Please sign in to comment.