#![allow(non_camel_case_types)]
use crate::{c_long, c_uint, c_ulong};
#[doc = crate::_tags!(linux fs)]
#[doc = crate::_doc_location!("sys/os/linux")]
#[repr(C)]
#[derive(Debug, Default)]
pub struct LinuxStat {
pub st_dev: c_ulong,
pub st_ino: c_ulong,
pub st_mode: c_uint,
pub st_nlink: c_ulong,
pub st_uid: c_uint,
pub st_gid: c_uint,
pub st_rdev: c_ulong,
pub st_size: c_long,
pub st_blksize: c_long,
pub st_blocks: c_long,
pub st_atime: c_long,
pub st_atime_nsec: c_long,
pub st_mtime: c_long,
pub st_mtime_nsec: c_long,
pub st_ctime: c_long,
pub st_ctime_nsec: c_long,
_unused: [c_long; 3],
}
impl LinuxStat {
pub const fn is_file(&self) -> bool {
self.st_mode & LINUX_S_IFMT::TYPE_MASK == LINUX_S_IFMT::FILE
}
pub const fn is_dir(&self) -> bool {
self.st_mode & LINUX_S_IFMT::TYPE_MASK == LINUX_S_IFMT::DIRECTORY
}
pub const fn permissions(&self) -> u16 {
(self.st_mode & 0o777) as u16
}
}
#[doc = crate::_tags!(linux fs)]
#[doc = crate::_doc_location!("sys/os/linux")]
#[derive(Debug)]
pub struct LINUX_S_IFMT;
impl LINUX_S_IFMT {
pub const TYPE_MASK: c_uint = 0o170_000;
pub const FILE: c_uint = 0o100_000;
pub const DIRECTORY: c_uint = 0o040_000;
pub const CHAR_DEVICE: c_uint = 0o020_000;
pub const BLOCK_DEVICE: c_uint = 0o060_000;
pub const FIFO: c_uint = 0o010_000;
pub const SYMLINK: c_uint = 0o120_000;
pub const SOCKET: c_uint = 0o140_000;
pub const SET_UID: c_uint = 0o4_000;
pub const SET_GID: c_uint = 0o2_000;
pub const STICKY_BIT: c_uint = 0o1_000;
pub const USER_READ: c_uint = 0o400;
pub const USER_WRITE: c_uint = 0o200;
pub const USER_EXEC: c_uint = 0o100;
pub const GROUP_READ: c_uint = 0o040;
pub const GROUP_WRITE: c_uint = 0o020;
pub const GROUP_EXEC: c_uint = 0o010;
pub const OTHER_READ: c_uint = 0o004;
pub const OTHER_WRITE: c_uint = 0o002;
pub const OTHER_EXEC: c_uint = 0o001;
}