Implement atomic wrapper for integer-like type

This commit is contained in:
jellllly420
2024-09-24 16:30:09 +08:00
committed by Tate, Hongliang Tian
parent a7cb71161d
commit 21fedd1b60
26 changed files with 437 additions and 241 deletions

View File

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
use super::SyscallReturn;
use crate::prelude::*;
use crate::{prelude::*, process::Gid};
pub fn sys_getegid(ctx: &Context) -> Result<SyscallReturn> {
let egid = ctx.posix_thread.credentials().egid();
Ok(SyscallReturn::Return(egid.as_u32() as _))
Ok(SyscallReturn::Return(<Gid as Into<u32>>::into(egid) as _))
}

View File

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
use super::SyscallReturn;
use crate::prelude::*;
use crate::{prelude::*, process::Uid};
pub fn sys_geteuid(ctx: &Context) -> Result<SyscallReturn> {
let euid = ctx.posix_thread.credentials().euid();
Ok(SyscallReturn::Return(euid.as_u32() as _))
Ok(SyscallReturn::Return(<Uid as Into<u32>>::into(euid) as _))
}

View File

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
use super::SyscallReturn;
use crate::prelude::*;
use crate::{prelude::*, process::Gid};
pub fn sys_getgid(ctx: &Context) -> Result<SyscallReturn> {
let gid = ctx.posix_thread.credentials().rgid();
Ok(SyscallReturn::Return(gid.as_u32() as _))
Ok(SyscallReturn::Return(<Gid as Into<u32>>::into(gid) as _))
}

View File

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
use super::SyscallReturn;
use crate::prelude::*;
use crate::{prelude::*, process::Uid};
pub fn sys_getuid(ctx: &Context) -> Result<SyscallReturn> {
let uid = ctx.posix_thread.credentials().ruid();
Ok(SyscallReturn::Return(uid.as_u32() as _))
Ok(SyscallReturn::Return(<Uid as Into<u32>>::into(uid) as _))
}

View File

@ -17,5 +17,7 @@ pub fn sys_setfsgid(gid: i32, ctx: &Context) -> Result<SyscallReturn> {
credentials.set_fsgid(fsgid)?
};
Ok(SyscallReturn::Return(old_fsgid.as_u32() as _))
Ok(SyscallReturn::Return(
<Gid as Into<u32>>::into(old_fsgid) as _
))
}

View File

@ -17,5 +17,7 @@ pub fn sys_setfsuid(uid: i32, ctx: &Context) -> Result<SyscallReturn> {
credentials.set_fsuid(fsuid)?
};
Ok(SyscallReturn::Return(old_fsuid.as_u32() as _))
Ok(SyscallReturn::Return(
<Uid as Into<u32>>::into(old_fsuid) as _
))
}

View File

@ -121,8 +121,8 @@ impl From<Metadata> for Stat {
st_ino: info.ino,
st_nlink: info.nlinks,
st_mode: info.type_ as u32 | info.mode.bits() as u32,
st_uid: info.uid.as_u32(),
st_gid: info.gid.as_u32(),
st_uid: info.uid.into(),
st_gid: info.gid.into(),
__pad0: 0,
st_rdev: info.rdev,
st_size: info.size as isize,