1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
// Copyright (c) 2020 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
// Use of this source is governed by Apache-2.0 License that can be found
// in the LICENSE file.
//! From `include/linux/dirent.h`
#![allow(clippy::module_name_repetitions)]
use alloc::string::String;
use core::fmt;
use crate::{ino64_t, loff_t, PATH_MAX};
#[repr(C)]
#[derive(Clone)]
pub struct linux_dirent64_t {
/// 64-bit inode number.
pub d_ino: ino64_t,
/// 64-bit offset to next structure.
pub d_off: loff_t,
/// Size of this dirent.
pub d_reclen: u16,
/// File type.
pub d_type: u8,
/// Filename (null-terminated).
//pub d_name: [u8; 0],
pub d_name: [u8; PATH_MAX as usize],
}
impl fmt::Debug for linux_dirent64_t {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("linux_dirent64_t")
.field("d_ino", &self.d_ino)
.field("d_off", &self.d_off)
.field("d_reclen", &self.d_reclen)
.field("d_type", &self.d_type)
.field("d_name", &&self.d_name[0..32])
.finish()
}
}
#[repr(C)]
#[derive(Debug, Default, Clone)]
pub struct linux_dirent64_extern_t {
/// 64-bit inode number.
pub d_ino: ino64_t,
/// 64-bit offset to next structure.
pub d_off: loff_t,
/// File type.
pub d_type: u8,
// TODO(Shaohua): Replace String with CString
/// Filename.
pub d_name: String,
}