mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2026-05-24 08:55:20 -04:00
address review
This commit is contained in:
@@ -121,6 +121,10 @@ pub enum FsError {
|
||||
#[error("The directory is not empty.")]
|
||||
DirectoryNotEmpty,
|
||||
|
||||
/// The device or resource is busy.
|
||||
#[error("The device or resource is busy.")]
|
||||
Busy,
|
||||
|
||||
/// Invalid input parameters.
|
||||
#[error("Invalid input parameters.")]
|
||||
InvalidInput,
|
||||
|
||||
@@ -44,6 +44,7 @@ pub const ERANGE: isize = -34;
|
||||
pub const EWOULDBLOCK: isize = -EAGAIN;
|
||||
pub const ENAMETOOLONG: isize = -36;
|
||||
pub const ENOSYS: isize = -38;
|
||||
pub const ENOTEMPTY: isize = -39;
|
||||
pub const ELOOP: isize = -40;
|
||||
pub const EAFNOSUPPORT: isize = -97;
|
||||
pub const EOPNOTSUPP: isize = -95;
|
||||
@@ -63,7 +64,10 @@ pub fn kern_err_to_syscall(err: KernelError) -> isize {
|
||||
KernelError::Fs(FsError::IsADirectory) => EISDIR,
|
||||
KernelError::Fs(FsError::NotADirectory) => ENOTDIR,
|
||||
KernelError::Fs(FsError::AlreadyExists) => EEXIST,
|
||||
KernelError::Fs(FsError::DirectoryNotEmpty) => ENOTEMPTY,
|
||||
KernelError::Fs(FsError::Busy) => EBUSY,
|
||||
KernelError::Fs(FsError::InvalidInput) => EINVAL, // TODO: Is this right?
|
||||
KernelError::InUse => EBUSY,
|
||||
KernelError::Fs(FsError::PermissionDenied) => EACCES,
|
||||
KernelError::Fs(FsError::TooManyFiles) => EMFILE,
|
||||
KernelError::Fs(FsError::NoDevice) => ENODEV,
|
||||
|
||||
@@ -316,11 +316,11 @@ impl Inode for CgroupDirInode {
|
||||
let child = children.get(name).cloned().ok_or(FsError::NotFound)?;
|
||||
|
||||
if !child.children.lock_save_irq().is_empty() {
|
||||
return Err(FsError::DirectoryNotEmpty.into());
|
||||
return Err(FsError::Busy.into());
|
||||
}
|
||||
|
||||
if cgroupfs().has_live_processes_direct(&child) {
|
||||
return Err(FsError::DirectoryNotEmpty.into());
|
||||
return Err(FsError::Busy.into());
|
||||
}
|
||||
|
||||
children.remove(name);
|
||||
@@ -612,7 +612,7 @@ impl CgroupFs {
|
||||
fn new() -> Arc<Self> {
|
||||
Arc::new(Self {
|
||||
root: CgroupDirInode::new_root(),
|
||||
next_inode_id: AtomicU64::new(2),
|
||||
next_inode_id: AtomicU64::new(2 << 8),
|
||||
memberships: SpinLock::new(BTreeMap::new()),
|
||||
})
|
||||
}
|
||||
@@ -620,7 +620,7 @@ impl CgroupFs {
|
||||
fn alloc_inode_id(&self) -> InodeId {
|
||||
InodeId::from_fsid_and_inodeid(
|
||||
CGROUPFS_ID,
|
||||
self.next_inode_id.fetch_add(1, Ordering::SeqCst),
|
||||
self.next_inode_id.fetch_add(1 << 8, Ordering::Relaxed),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user