-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements sysctl kern.proc.ptc and kern.sched.cpusetsize (#410)
- Loading branch information
1 parent
9a1cba6
commit 5bdc59e
Showing
5 changed files
with
129 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::errno::{ENOENT, ENOSYS, ESRCH}; | ||
use crate::info; | ||
use crate::process::{VProc, VThread}; | ||
use crate::syscalls::{SysErr, SysIn, SysOut, Syscalls}; | ||
use std::sync::Arc; | ||
|
||
/// An implementation of budget system on the PS4. | ||
pub struct Budget { | ||
vp: Arc<VProc>, | ||
} | ||
|
||
impl Budget { | ||
pub fn new(vp: &Arc<VProc>, sys: &mut Syscalls) -> Arc<Self> { | ||
let budget = Arc::new(Self { vp: vp.clone() }); | ||
|
||
sys.register(610, &budget, Self::sys_budget_get_ptype); | ||
|
||
budget | ||
} | ||
|
||
fn sys_budget_get_ptype(self: &Arc<Self>, i: &SysIn) -> Result<SysOut, SysErr> { | ||
// Check if PID is our process. | ||
let pid: i32 = i.args[0].try_into().unwrap(); | ||
let td = VThread::current(); | ||
|
||
info!("Getting budget process type for process {pid}."); | ||
|
||
if td.cred().is_system() || pid == -1 || pid == self.vp.id().get() { | ||
if pid == -1 || pid == self.vp.id().get() { | ||
// TODO: Invoke id_rlock. Not sure why return ENOENT is working here. | ||
Err(SysErr::Raw(ENOENT)) | ||
} else { | ||
Err(SysErr::Raw(ESRCH)) | ||
} | ||
} else { | ||
Err(SysErr::Raw(ENOSYS)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters