Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up commented code #91

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/interface/errnos.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(dead_code)]
// Error handling for SafePOSIX
use crate::interface;

use std::sync::OnceLock;
Expand Down
3 changes: 0 additions & 3 deletions src/interface/file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// // Author: Nicholas Renner
// //

use parking_lot::Mutex;
use std::fs::{self, canonicalize, File, OpenOptions};
use std::sync::Arc;
Expand Down
2 changes: 0 additions & 2 deletions src/interface/misc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Author: Nicholas Renner
//
// Misc functions for interface
// Random, locks, etc.
#![allow(dead_code)]
Expand Down
5 changes: 0 additions & 5 deletions src/interface/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Author: Nicholas Renner
//
// Module definitions for the SafePOSIX Rust interface
// this interface limits kernel access from Rust to the popular paths as defined in Lock-in-Pop

mod comm;
pub mod errnos;
mod file;
Expand Down
2 changes: 0 additions & 2 deletions src/interface/timer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Author: Nicholas Renner
//
// Timer functions for Rust interface.
#![allow(dead_code)]

Expand Down
147 changes: 0 additions & 147 deletions src/safeposix/cage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,23 @@
use crate::interface;
//going to get the datatypes and errnos from the cage file from now on
pub use crate::interface::errnos::{syscall_error, Errno};
// pub use crate::interface::types::{
// Arg, EpollEvent, FSData, IoctlPtrUnion, PipeArray, PollStruct, Rlimit, ShmidsStruct, StatData,
// };

pub use crate::interface::types::{
EpollEvent, IoctlPtrUnion, PipeArray, PollStruct,
};

use super::filesystem::normpath;
// use super::net::SocketHandle;
pub use super::syscalls::fs_constants::*;
pub use super::syscalls::net_constants::*;
pub use super::syscalls::sys_constants::*;

pub use crate::interface::CAGE_TABLE;

// #[derive(Debug, Clone)]
// pub enum FileDescriptor {
// File(FileDesc),
// Stream(StreamDesc),
// Socket(SocketDesc),
// Pipe(PipeDesc),
// Epoll(EpollDesc),
// }

// #[derive(Debug, Clone)]
// pub struct FileDesc {
// pub position: usize,
// pub inode: usize,
// pub flags: i32,
// pub advlock: interface::RustRfc<interface::AdvisoryLock>,
// }

// #[derive(Debug, Clone)]
// pub struct StreamDesc {
// pub position: usize,
// pub stream: i32, //0 for stdin, 1 for stdout, 2 for stderr
// pub flags: i32,
// pub advlock: interface::RustRfc<interface::AdvisoryLock>,
// }

// #[derive(Debug, Clone)]
// pub struct SocketDesc {
// pub flags: i32,
// pub domain: i32,
// pub rawfd: i32,
// pub handle: interface::RustRfc<interface::RustLock<SocketHandle>>,
// pub advlock: interface::RustRfc<interface::AdvisoryLock>,
// }

// #[derive(Debug, Clone)]
// pub struct PipeDesc {
// pub pipe: interface::RustRfc<interface::EmulatedPipe>,
// pub flags: i32,
// pub advlock: interface::RustRfc<interface::AdvisoryLock>,
// }

// #[derive(Debug, Clone)]
// pub struct EpollDesc {
// pub mode: i32,
// pub registered_fds: interface::RustHashMap<i32, EpollEvent>,
// pub advlock: interface::RustRfc<interface::AdvisoryLock>,
// pub errno: i32,
// pub flags: i32,
// }

// pub type FdTable = Vec<interface::RustRfc<interface::RustLock<Option<FileDescriptor>>>>;

#[derive(Debug)]
pub struct Cage {
pub cageid: u64,
pub cwd: interface::RustLock<interface::RustRfc<interface::RustPathBuf>>,
pub parent: u64,
// pub filedescriptortable: FdTable,
pub cancelstatus: interface::RustAtomicBool,
pub getgid: interface::RustAtomicI32,
pub getuid: interface::RustAtomicI32,
Expand All @@ -94,38 +37,6 @@ pub struct Cage {
}

impl Cage {
// pub fn get_next_fd(
// &self,
// startfd: Option<i32>,
// ) -> (
// i32,
// Option<interface::RustLockWriteGuard<Option<FileDescriptor>>>,
// ) {
// let start = match startfd {
// Some(startfd) => startfd,
// None => STARTINGFD,
// };

// // let's get the next available fd number. The standard says we need to return the lowest open fd number.
// for fd in start..MAXFD {
// let fdguard = self.filedescriptortable[fd as usize].try_write();
// if let Some(ref fdopt) = fdguard {
// // we grab the lock here and if there is no occupied cage, we return the fdno and guard while keeping the fd slot locked
// if fdopt.is_none() {
// return (fd, fdguard);
// }
// }
// }
// return (
// syscall_error(
// Errno::ENFILE,
// "get_next_fd",
// "no available file descriptor number could be found",
// ),
// None,
// );
// }

pub fn changedir(&self, newdir: interface::RustPathBuf) {
let newwd = interface::RustRfc::new(normpath(newdir, self));
let mut cwdbox = self.cwd.write();
Expand All @@ -151,62 +62,4 @@ impl Cage {
}
}
}

// pub fn get_filedescriptor(
// &self,
// fd: i32,
// ) -> Result<interface::RustRfc<interface::RustLock<Option<FileDescriptor>>>, ()> {
// if (fd < 0) || (fd >= MAXFD) {
// Err(())
// } else {
// Ok(self.filedescriptortable[fd as usize].clone())
// }
// }
}

// pub fn init_fdtable() -> FdTable {
// let mut fdtable = Vec::new();
// // load lower handle stubs
// let stdin = interface::RustRfc::new(interface::RustLock::new(Some(FileDescriptor::Stream(
// StreamDesc {
// position: 0,
// stream: 0,
// flags: O_RDONLY,
// advlock: interface::RustRfc::new(interface::AdvisoryLock::new()),
// },
// ))));
// let stdout = interface::RustRfc::new(interface::RustLock::new(Some(FileDescriptor::Stream(
// StreamDesc {
// position: 0,
// stream: 1,
// flags: O_WRONLY,
// advlock: interface::RustRfc::new(interface::AdvisoryLock::new()),
// },
// ))));
// let stderr = interface::RustRfc::new(interface::RustLock::new(Some(FileDescriptor::Stream(
// StreamDesc {
// position: 0,
// stream: 2,
// flags: O_WRONLY,
// advlock: interface::RustRfc::new(interface::AdvisoryLock::new()),
// },
// ))));
// fdtable.push(stdin);
// fdtable.push(stdout);
// fdtable.push(stderr);

// for _fd in 3..MAXFD as usize {
// fdtable.push(interface::RustRfc::new(interface::RustLock::new(None)));
// }
// fdtable
// }

// pub fn create_unix_sockpipes() -> (
// interface::RustRfc<interface::EmulatedPipe>,
// interface::RustRfc<interface::EmulatedPipe>,
// ) {
// let pipe1 = interface::RustRfc::new(interface::new_pipe(UDSOCK_CAPACITY));
// let pipe2 = interface::RustRfc::new(interface::new_pipe(UDSOCK_CAPACITY));

// (pipe1, pipe2)
// }
7 changes: 0 additions & 7 deletions src/safeposix/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ macro_rules! get_onearg {
};
}

// the following "quick" functions are implemented for research purposes
// to increase I/O performance by bypassing the dispatcher and type checker

#[no_mangle]
pub extern "C" fn rustposix_thread_init(cageid: u64, signalflag: u64) {
let cage = interface::cagetable_getref(cageid);
Expand Down Expand Up @@ -925,9 +922,6 @@ pub fn lind_syscall_api(
GETSOCKNAME_SYSCALL => {
let fd = arg1 as i32;

// let addrlen = arg3 as u32;
// let mut addr = interface::get_sockaddr(start_address + arg2), addrlen).unwrap();

let mut addr = interface::GenSockaddr::V4(interface::SockaddrV4::default()); //value doesn't matter

if interface::arg_nullity(arg2) || interface::arg_nullity(arg3) {
Expand Down Expand Up @@ -1127,7 +1121,6 @@ pub fn lindrustinit(verbosity: isize) {
cageid: 1,
cwd: interface::RustLock::new(interface::RustRfc::new(interface::RustPathBuf::from("/"))),
parent: 1,
// filedescriptortable: init_fdtable(),
cancelstatus: interface::RustAtomicBool::new(false),
getgid: interface::RustAtomicI32::new(-1),
getuid: interface::RustAtomicI32::new(-1),
Expand Down
Loading
Loading