Modify the type of ino to u64

This commit is contained in:
LI Qing 2024-05-24 10:41:33 +08:00 committed by Tate, Hongliang Tian
parent ce2e0cee92
commit e210e68920
9 changed files with 17 additions and 20 deletions

View File

@ -27,9 +27,9 @@ mod slave;
const DEVPTS_MAGIC: u64 = 0x1cd1; const DEVPTS_MAGIC: u64 = 0x1cd1;
const BLOCK_SIZE: usize = 1024; const BLOCK_SIZE: usize = 1024;
const ROOT_INO: usize = 1; const ROOT_INO: u64 = 1;
const PTMX_INO: usize = 2; const PTMX_INO: u64 = 2;
const FIRST_SLAVE_INO: usize = 3; const FIRST_SLAVE_INO: u64 = 3;
/// The max number of pty pairs. /// The max number of pty pairs.
const MAX_PTY_NUM: usize = 4096; const MAX_PTY_NUM: usize = 4096;

View File

@ -22,7 +22,7 @@ impl PtySlaveInode {
pub fn new(device: Arc<PtySlave>, fs: Weak<DevPts>) -> Arc<Self> { pub fn new(device: Arc<PtySlave>, fs: Weak<DevPts>) -> Arc<Self> {
Arc::new(Self { Arc::new(Self {
metadata: RwLock::new(Metadata::new_device( metadata: RwLock::new(Metadata::new_device(
device.index() as usize + FIRST_SLAVE_INO, device.index() as u64 + FIRST_SLAVE_INO,
InodeMode::from_bits_truncate(0o620), InodeMode::from_bits_truncate(0o620),
super::BLOCK_SIZE, super::BLOCK_SIZE,
device.as_ref(), device.as_ref(),

View File

@ -1125,7 +1125,7 @@ impl Inode for ExfatInode {
Metadata { Metadata {
dev: 0, dev: 0,
ino: inner.ino as usize, ino: inner.ino,
size: inner.size, size: inner.size,
blk_size, blk_size,
blocks: (inner.size + blk_size - 1) / blk_size, blocks: (inner.size + blk_size - 1) / blk_size,

View File

@ -40,11 +40,8 @@ impl<D: DirOps> ProcDir<D> {
procfs.alloc_id() procfs.alloc_id()
}); });
let metadata = Metadata::new_dir( let metadata =
ino as _, Metadata::new_dir(ino, InodeMode::from_bits_truncate(0o555), super::BLOCK_SIZE);
InodeMode::from_bits_truncate(0o555),
super::BLOCK_SIZE,
);
Common::new(metadata, fs, is_volatile) Common::new(metadata, fs, is_volatile)
}; };
Arc::new_cyclic(|weak_self| Self { Arc::new_cyclic(|weak_self| Self {

View File

@ -22,7 +22,7 @@ impl<F: FileOps> ProcFile<F> {
let arc_fs = fs.upgrade().unwrap(); let arc_fs = fs.upgrade().unwrap();
let procfs = arc_fs.downcast_ref::<ProcFS>().unwrap(); let procfs = arc_fs.downcast_ref::<ProcFS>().unwrap();
let metadata = Metadata::new_file( let metadata = Metadata::new_file(
procfs.alloc_id() as _, procfs.alloc_id(),
InodeMode::from_bits_truncate(0o444), InodeMode::from_bits_truncate(0o444),
super::BLOCK_SIZE, super::BLOCK_SIZE,
); );

View File

@ -44,7 +44,7 @@ impl Common {
} }
pub fn ino(&self) -> u64 { pub fn ino(&self) -> u64 {
self.metadata.read().ino as _ self.metadata.read().ino
} }
pub fn type_(&self) -> InodeType { pub fn type_(&self) -> InodeType {

View File

@ -22,7 +22,7 @@ impl<S: SymOps> ProcSym<S> {
let arc_fs = fs.upgrade().unwrap(); let arc_fs = fs.upgrade().unwrap();
let procfs = arc_fs.downcast_ref::<ProcFS>().unwrap(); let procfs = arc_fs.downcast_ref::<ProcFS>().unwrap();
let metadata = Metadata::new_symlink( let metadata = Metadata::new_symlink(
procfs.alloc_id() as _, procfs.alloc_id(),
InodeMode::from_bits_truncate(0o777), InodeMode::from_bits_truncate(0o777),
super::BLOCK_SIZE, super::BLOCK_SIZE,
); );

View File

@ -120,7 +120,7 @@ impl InodeMode {
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Metadata { pub struct Metadata {
pub dev: u64, pub dev: u64,
pub ino: usize, pub ino: u64,
pub size: usize, pub size: usize,
pub blk_size: usize, pub blk_size: usize,
pub blocks: usize, pub blocks: usize,
@ -136,7 +136,7 @@ pub struct Metadata {
} }
impl Metadata { impl Metadata {
pub fn new_dir(ino: usize, mode: InodeMode, blk_size: usize) -> Self { pub fn new_dir(ino: u64, mode: InodeMode, blk_size: usize) -> Self {
Self { Self {
dev: 0, dev: 0,
ino, ino,
@ -155,7 +155,7 @@ impl Metadata {
} }
} }
pub fn new_file(ino: usize, mode: InodeMode, blk_size: usize) -> Self { pub fn new_file(ino: u64, mode: InodeMode, blk_size: usize) -> Self {
Self { Self {
dev: 0, dev: 0,
ino, ino,
@ -174,7 +174,7 @@ impl Metadata {
} }
} }
pub fn new_symlink(ino: usize, mode: InodeMode, blk_size: usize) -> Self { pub fn new_symlink(ino: u64, mode: InodeMode, blk_size: usize) -> Self {
Self { Self {
dev: 0, dev: 0,
ino, ino,
@ -192,7 +192,7 @@ impl Metadata {
rdev: 0, rdev: 0,
} }
} }
pub fn new_device(ino: usize, mode: InodeMode, blk_size: usize, device: &dyn Device) -> Self { pub fn new_device(ino: u64, mode: InodeMode, blk_size: usize, device: &dyn Device) -> Self {
Self { Self {
dev: 0, dev: 0,
ino, ino,
@ -211,7 +211,7 @@ impl Metadata {
} }
} }
pub fn new_socket(ino: usize, mode: InodeMode, blk_size: usize) -> Metadata { pub fn new_socket(ino: u64, mode: InodeMode, blk_size: usize) -> Metadata {
Self { Self {
dev: 0, dev: 0,
ino, ino,

View File

@ -90,7 +90,7 @@ pub struct Stat {
/// ID of device containing file /// ID of device containing file
st_dev: u64, st_dev: u64,
/// Inode number /// Inode number
st_ino: usize, st_ino: u64,
/// Number of hard links /// Number of hard links
st_nlink: usize, st_nlink: usize,
/// File type and mode /// File type and mode