forked from obhq/obliteration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69a6ab2
commit 39175cc
Showing
16 changed files
with
246 additions
and
66 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
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 |
---|---|---|
@@ -1,25 +1,74 @@ | ||
use thiserror::Error; | ||
|
||
use crate::{ | ||
errno::Errno, | ||
fs::{CharacterDevice, DeviceDriver, IoCmd}, | ||
fs::{ | ||
make_dev, CharacterDevice, DeviceDriver, DriverFlags, IoCmd, MakeDevError, MakeDevFlags, | ||
Mode, | ||
}, | ||
process::VThread, | ||
ucred::{Gid, Uid}, | ||
}; | ||
use std::sync::Arc; | ||
|
||
#[derive(Debug)] | ||
struct Dipsw {} | ||
|
||
impl Dipsw { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
impl DeviceDriver for Dipsw { | ||
#[allow(unused_variables)] | ||
fn ioctl( | ||
&self, | ||
dev: &Arc<CharacterDevice>, | ||
cmd: IoCmd, | ||
td: &VThread, | ||
td: Option<&VThread>, | ||
) -> Result<(), Box<dyn Errno>> { | ||
let td = td.unwrap(); | ||
|
||
if !td.cred().is_system() { | ||
todo!() | ||
} else { | ||
todo!() | ||
match cmd { | ||
// TODO: properly implement this | ||
IoCmd::DIPSWCHECK2(val) => *val = false as i32, | ||
_ => todo!(), | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
pub struct DipswManager { | ||
dipsw: Arc<CharacterDevice>, | ||
} | ||
|
||
impl DipswManager { | ||
pub fn new() -> Result<Arc<Self>, DipswInitError> { | ||
let dipsw = make_dev( | ||
Dipsw::new(), | ||
DriverFlags::from_bits_retain(0x80000004), | ||
0, | ||
"dipsw", | ||
Uid::ROOT, | ||
Gid::ROOT, | ||
Mode::new(0o644).unwrap(), | ||
None, | ||
MakeDevFlags::MAKEDEV_ETERNAL, | ||
)?; | ||
|
||
Ok(Arc::new(Self { dipsw })) | ||
} | ||
} | ||
|
||
/// Represents an error when [`TtyManager`] fails to initialize. | ||
#[derive(Debug, Error)] | ||
pub enum DipswInitError { | ||
#[error("cannot create dipsw device")] | ||
CreateConsoleFailed(#[from] MakeDevError), | ||
} |
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
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
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
Oops, something went wrong.