Skip to main content

tg_syscall/
fs.rs

1use bitflags::bitflags;
2
3bitflags! {
4    /// 文件类型标志
5    pub struct StatMode: u32 {
6        const NULL  = 0;
7        /// directory
8        const DIR   = 0o040000;
9        /// ordinary regular file
10        const FILE  = 0o100000;
11    }
12}
13
14/// 文件状态信息
15#[repr(C)]
16#[derive(Debug, Clone, Copy)]
17pub struct Stat {
18    /// 文件所在磁盘驱动器号
19    pub dev: u64,
20    /// inode 编号
21    pub ino: u64,
22    /// 文件类型
23    pub mode: StatMode,
24    /// 硬链接数量
25    pub nlink: u32,
26    /// 填充字段
27    pad: [u64; 7],
28}
29
30impl Stat {
31    pub fn new() -> Self {
32        Self {
33            dev: 0,
34            ino: 0,
35            mode: StatMode::NULL,
36            nlink: 0,
37            pad: [0; 7],
38        }
39    }
40}