Remove common enum suffixes
This commit is contained in:
parent
09e7355d87
commit
b2f17d11c6
|
|
@ -14,7 +14,7 @@ pub struct Null;
|
|||
|
||||
impl Device for Null {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ impl Random {
|
|||
|
||||
impl Device for Random {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub struct TdxGuest;
|
|||
|
||||
impl Device for TdxGuest {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::MiscDevice
|
||||
DeviceType::Misc
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl Device for TtyDevice {
|
|||
}
|
||||
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ impl<D: TtyDriver> Terminal for Tty<D> {
|
|||
|
||||
impl<D: TtyDriver> Device for Tty<D> {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ impl Urandom {
|
|||
|
||||
impl Device for Urandom {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub struct Zero;
|
|||
|
||||
impl Device for Zero {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ impl Debug for dyn Device {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Device type
|
||||
#[derive(Debug)]
|
||||
pub enum DeviceType {
|
||||
CharDevice,
|
||||
BlockDevice,
|
||||
MiscDevice,
|
||||
Char,
|
||||
Block,
|
||||
Misc,
|
||||
}
|
||||
|
||||
/// A device ID, containing a major device number and a minor device number.
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ impl Inode for Ptmx {
|
|||
|
||||
impl Device for Inner {
|
||||
fn type_(&self) -> DeviceType {
|
||||
DeviceType::CharDevice
|
||||
DeviceType::Char
|
||||
}
|
||||
|
||||
fn id(&self) -> DeviceId {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl Inode for Ext2Inode {
|
|||
fn mknod(&self, name: &str, mode: InodeMode, type_: MknodType) -> Result<Arc<dyn Inode>> {
|
||||
let inode_type = type_.inode_type();
|
||||
let inode = match type_ {
|
||||
MknodType::CharDeviceNode(dev) | MknodType::BlockDeviceNode(dev) => {
|
||||
MknodType::CharDevice(dev) | MknodType::BlockDevice(dev) => {
|
||||
let inode = self.create(name, inode_type, mode.into())?;
|
||||
inode.set_device_id(dev.id().as_encoded_u64()).unwrap();
|
||||
inode
|
||||
|
|
|
|||
|
|
@ -1435,7 +1435,7 @@ mod tests {
|
|||
let d1 = root.lookup("d1").unwrap();
|
||||
d1.set_mode(mode).unwrap();
|
||||
assert_ne!(f1.ino(), d1.ino());
|
||||
d1.mknod("dev", mode, MknodType::NamedPipeNode).unwrap();
|
||||
d1.mknod("dev", mode, MknodType::NamedPipe).unwrap();
|
||||
|
||||
let link = d1.create("link", InodeType::SymLink, mode).unwrap();
|
||||
let link_str = "link_to_somewhere";
|
||||
|
|
|
|||
|
|
@ -712,16 +712,14 @@ impl Inode for RamInode {
|
|||
}
|
||||
|
||||
let new_inode = match type_ {
|
||||
MknodType::CharDeviceNode(device) | MknodType::BlockDeviceNode(device) => {
|
||||
RamInode::new_device(
|
||||
&self.fs.upgrade().unwrap(),
|
||||
mode,
|
||||
Uid::new_root(),
|
||||
Gid::new_root(),
|
||||
device,
|
||||
)
|
||||
}
|
||||
MknodType::NamedPipeNode => RamInode::new_named_pipe(
|
||||
MknodType::CharDevice(device) | MknodType::BlockDevice(device) => RamInode::new_device(
|
||||
&self.fs.upgrade().unwrap(),
|
||||
mode,
|
||||
Uid::new_root(),
|
||||
Gid::new_root(),
|
||||
device,
|
||||
),
|
||||
MknodType::NamedPipe => RamInode::new_named_pipe(
|
||||
&self.fs.upgrade().unwrap(),
|
||||
mode,
|
||||
Uid::new_root(),
|
||||
|
|
|
|||
|
|
@ -79,9 +79,9 @@ impl InodeType {
|
|||
impl From<DeviceType> for InodeType {
|
||||
fn from(type_: DeviceType) -> InodeType {
|
||||
match type_ {
|
||||
DeviceType::CharDevice => InodeType::CharDevice,
|
||||
DeviceType::BlockDevice => InodeType::BlockDevice,
|
||||
DeviceType::MiscDevice => InodeType::CharDevice,
|
||||
DeviceType::Char => InodeType::CharDevice,
|
||||
DeviceType::Block => InodeType::BlockDevice,
|
||||
DeviceType::Misc => InodeType::CharDevice,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -328,17 +328,17 @@ impl Metadata {
|
|||
}
|
||||
|
||||
pub enum MknodType {
|
||||
NamedPipeNode,
|
||||
CharDeviceNode(Arc<dyn Device>),
|
||||
BlockDeviceNode(Arc<dyn Device>),
|
||||
NamedPipe,
|
||||
CharDevice(Arc<dyn Device>),
|
||||
BlockDevice(Arc<dyn Device>),
|
||||
}
|
||||
|
||||
impl MknodType {
|
||||
pub fn inode_type(&self) -> InodeType {
|
||||
match self {
|
||||
MknodType::NamedPipeNode => InodeType::NamedPipe,
|
||||
MknodType::CharDeviceNode(_) => InodeType::CharDevice,
|
||||
MknodType::BlockDeviceNode(_) => InodeType::BlockDevice,
|
||||
MknodType::NamedPipe => InodeType::NamedPipe,
|
||||
MknodType::CharDevice(_) => InodeType::CharDevice,
|
||||
MknodType::BlockDevice(_) => InodeType::BlockDevice,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -347,8 +347,8 @@ impl From<Arc<dyn Device>> for MknodType {
|
|||
fn from(device: Arc<dyn Device>) -> Self {
|
||||
let inode_type: InodeType = device.type_().into();
|
||||
match inode_type {
|
||||
InodeType::CharDevice => Self::CharDeviceNode(device),
|
||||
InodeType::BlockDevice => Self::BlockDeviceNode(device),
|
||||
InodeType::CharDevice => Self::CharDevice(device),
|
||||
InodeType::BlockDevice => Self::BlockDevice(device),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub fn sys_mknodat(
|
|||
let _ = dir_path.mknod(&name, inode_mode, device_inode.into())?;
|
||||
}
|
||||
InodeType::NamedPipe => {
|
||||
let _ = dir_path.mknod(&name, inode_mode, MknodType::NamedPipeNode)?;
|
||||
let _ = dir_path.mknod(&name, inode_mode, MknodType::NamedPipe)?;
|
||||
}
|
||||
InodeType::Socket => {
|
||||
return_errno_with_message!(Errno::EINVAL, "unsupported file types")
|
||||
|
|
|
|||
Loading…
Reference in New Issue