From 64823b994df7f013d60fd71c4a446bc38fba57cd Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 4 Jan 2024 18:37:00 +0000 Subject: [PATCH] rename CreationMode to AccessPermission --- src/fd/mod.rs | 4 ++-- src/fs/fuse.rs | 6 +++--- src/fs/mem.rs | 6 +++--- src/fs/mod.rs | 18 +++++++++--------- src/fs/uhyve.rs | 6 +++--- src/syscalls/mod.rs | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/fd/mod.rs b/src/fd/mod.rs index 752ad03ded..018cf206f9 100644 --- a/src/fd/mod.rs +++ b/src/fd/mod.rs @@ -82,7 +82,7 @@ bitflags! { bitflags! { #[derive(Debug, Copy, Clone, Default)] - pub(crate) struct CreationMode: i32 { + pub(crate) struct AccessPermission: i32 { const S_IRUSR = 0o400; const S_IWUSR = 0o200; const S_IXUSR = 0o100; @@ -253,7 +253,7 @@ pub(crate) fn open(name: &str, flags: i32, mode: i32) -> Result, opt: OpenOption, - mode: CreationMode, + mode: AccessPermission, ) -> Result, IoError> { let path: String = if components.is_empty() { "/".to_string() @@ -1622,7 +1622,7 @@ impl VfsNode for FuseDirectory { fn traverse_mkdir( &self, components: &mut Vec<&str>, - mode: CreationMode, + mode: AccessPermission, ) -> Result<(), IoError> { let path: String = if components.is_empty() { "/".to_string() diff --git a/src/fs/mem.rs b/src/fs/mem.rs index 36fdd0999c..06ca4b3a12 100644 --- a/src/fs/mem.rs +++ b/src/fs/mem.rs @@ -21,7 +21,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use hermit_sync::{RwSpinLock, SpinMutex}; -use crate::fd::{CreationMode, DirectoryEntry, Dirent, IoError, ObjectInterface, OpenOption}; +use crate::fd::{AccessPermission, DirectoryEntry, Dirent, IoError, ObjectInterface, OpenOption}; use crate::fs::{FileAttr, NodeKind, VfsNode}; #[derive(Debug)] @@ -337,7 +337,7 @@ impl VfsNode for MemDirectory { fn traverse_mkdir( &self, components: &mut Vec<&str>, - mode: CreationMode, + mode: AccessPermission, ) -> Result<(), IoError> { if let Some(component) = components.pop() { let node_name = String::from(component); @@ -475,7 +475,7 @@ impl VfsNode for MemDirectory { &self, components: &mut Vec<&str>, opt: OpenOption, - mode: CreationMode, + mode: AccessPermission, ) -> Result, IoError> { if let Some(component) = components.pop() { let node_name = String::from(component); diff --git a/src/fs/mod.rs b/src/fs/mod.rs index cf77c5afc9..f850cae487 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -10,7 +10,7 @@ use alloc::vec::Vec; use hermit_sync::OnceCell; use mem::MemDirectory; -use crate::fd::{CreationMode, IoError, ObjectInterface, OpenOption}; +use crate::fd::{AccessPermission, IoError, ObjectInterface, OpenOption}; pub(crate) static FILESYSTEM: OnceCell = OnceCell::new(); @@ -37,7 +37,7 @@ pub(crate) trait VfsNode: core::fmt::Debug { fn traverse_mkdir( &self, _components: &mut Vec<&str>, - _mode: CreationMode, + _mode: AccessPermission, ) -> Result<(), IoError> { Err(IoError::ENOSYS) } @@ -84,7 +84,7 @@ pub(crate) trait VfsNode: core::fmt::Debug { &self, _components: &mut Vec<&str>, _option: OpenOption, - _mode: CreationMode, + _mode: AccessPermission, ) -> Result, IoError> { Err(IoError::ENOSYS) } @@ -107,7 +107,7 @@ impl Filesystem { &self, path: &str, opt: OpenOption, - mode: CreationMode, + mode: AccessPermission, ) -> Result, IoError> { debug!("Open file {} with {:?}", path, opt); let mut components: Vec<&str> = path.split('/').collect(); @@ -141,7 +141,7 @@ impl Filesystem { } /// Create directory given by path - pub fn mkdir(&self, path: &str, mode: CreationMode) -> Result<(), IoError> { + pub fn mkdir(&self, path: &str, mode: AccessPermission) -> Result<(), IoError> { debug!("Create directory {}", path); let mut components: Vec<&str> = path.split('/').collect(); @@ -265,17 +265,17 @@ pub(crate) fn init() { FILESYSTEM .get() .unwrap() - .mkdir("/tmp", CreationMode::from_bits(0o777).unwrap()) + .mkdir("/tmp", AccessPermission::from_bits(0o777).unwrap()) .expect("Unable to create /tmp"); FILESYSTEM .get() .unwrap() - .mkdir("/etc", CreationMode::from_bits(0o777).unwrap()) + .mkdir("/etc", AccessPermission::from_bits(0o777).unwrap()) .expect("Unable to create /tmp"); if let Ok(fd) = FILESYSTEM.get().unwrap().open( "/etc/hostname", OpenOption::O_CREAT | OpenOption::O_RDWR, - CreationMode::from_bits(0o666).unwrap(), + AccessPermission::from_bits(0o666).unwrap(), ) { let _ret = fd.write(b"Hermit"); fd.close(); @@ -283,7 +283,7 @@ pub(crate) fn init() { if let Ok(fd) = FILESYSTEM.get().unwrap().open( "/etc/version", OpenOption::O_CREAT | OpenOption::O_RDWR, - CreationMode::from_bits(0o666).unwrap(), + AccessPermission::from_bits(0o666).unwrap(), ) { let _ret = fd.write(VERSION.as_bytes()); fd.close(); diff --git a/src/fs/uhyve.rs b/src/fs/uhyve.rs index da3f346843..c9caa4ca92 100644 --- a/src/fs/uhyve.rs +++ b/src/fs/uhyve.rs @@ -14,7 +14,7 @@ use crate::arch::mm::{paging, PhysAddr, VirtAddr}; use crate::env::is_uhyve; use crate::fd::IoError; use crate::fs::{ - self, CreationMode, FileAttr, NodeKind, ObjectInterface, OpenOption, SeekWhence, VfsNode, + self, AccessPermission, FileAttr, NodeKind, ObjectInterface, OpenOption, SeekWhence, VfsNode, }; /// forward a request to the hypervisor uhyve @@ -263,7 +263,7 @@ impl VfsNode for UhyveDirectory { &self, components: &mut Vec<&str>, opt: OpenOption, - mode: CreationMode, + mode: AccessPermission, ) -> Result, IoError> { let path: String = if components.is_empty() { "/\0".to_string() @@ -308,7 +308,7 @@ impl VfsNode for UhyveDirectory { fn traverse_mkdir( &self, _components: &mut Vec<&str>, - _mode: CreationMode, + _mode: AccessPermission, ) -> Result<(), IoError> { Err(IoError::ENOSYS) } diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index ed94d6b54f..c845e42a9b 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -19,7 +19,7 @@ pub use self::tasks::*; pub use self::timer::*; use crate::env; use crate::fd::{ - dup_object, get_object, remove_object, CreationMode, DirectoryEntry, FileDescriptor, IoCtl, + dup_object, get_object, remove_object, AccessPermission, DirectoryEntry, FileDescriptor, IoCtl, }; use crate::fs::{self, FileAttr}; use crate::syscalls::interfaces::SyscallInterface; @@ -119,7 +119,7 @@ pub extern "C" fn sys_unlink(name: *const u8) -> i32 { extern "C" fn __sys_mkdir(name: *const u8, mode: i32) -> i32 { let name = unsafe { CStr::from_ptr(name as _) }.to_str().unwrap(); - let mode = if let Some(mode) = CreationMode::from_bits(mode) { + let mode = if let Some(mode) = AccessPermission::from_bits(mode) { mode } else { return -crate::errno::EINVAL;