Skip to content

Commit cbf2189

Browse files
committed
Without ice files
1 parent 1c94437 commit cbf2189

File tree

4 files changed

+65
-68
lines changed

4 files changed

+65
-68
lines changed

src/safeposix/syscalls/fs_calls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ impl Cage {
10991099
/// O_WRONLY flags.
11001100
/// There are generally two cases which occur when this syscall happens:
11011101
/// Case 1: If the file to be opened doesn't exist, then due to O_CREAT flag,
1102-
/// a new file is created at the given location and a new file descriptor is
1103-
/// created and returned.
1102+
/// a new file is created at the given location and a new file descriptor is
1103+
/// created and returned.
11041104
/// Case 2: If the file already exists, then due to O_TRUNC flag, the file
11051105
/// size gets reduced to 0, and the existing file descriptor is returned.
11061106
///

src/safeposix/syscalls/net_calls.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,56 +1511,56 @@ impl Cage {
15111511
}
15121512

15131513
/// ### Description
1514-
///
1514+
///
15151515
/// `listen_syscall` listen for connections on a socket
1516-
///
1516+
///
15171517
/// ### Arguments
1518-
///
1519-
/// it accepts two parameters:
1518+
///
1519+
/// it accepts two parameters:
15201520
/// * `sockfd` - a file descriptor that refers to a socket
1521-
/// of type SOCK_STREAM
1521+
/// of type SOCK_STREAM
15221522
/// Note, we do not implement sockets of type SOCK_SEQPACKET
15231523
/// * `backlog` - defines the maximum length to which the
15241524
/// queue of pending connections for sockfd may grow. If a
15251525
/// connection request arrives when the queue is full, the client may
15261526
/// receive an error with an indication of ECONNREFUSED or, if the
15271527
/// underlying protocol supports retransmission, the request may be
15281528
/// ignored so that a later reattempt at connection succeeds.
1529-
///
1529+
///
15301530
/// ### Returns
1531-
///
1531+
///
15321532
/// for a successful call, zero is returned. On error, -errno is
15331533
/// returned and errno is set to indicate the error
1534-
///
1534+
///
15351535
/// ### Errors
1536-
///
1536+
///
15371537
/// * EADDRINUSE - Another socket is already listening on the same port.
1538-
///
1538+
///
15391539
/// * EADDRINUSE - (Internet domain sockets) The socket referred to by sockfd
15401540
/// had not previously been bound to an address and, upon
15411541
/// attempting to bind it to an ephemeral port, it was
15421542
/// determined that all port numbers in the ephemeral port
15431543
/// range are currently in use. See the discussion of
15441544
/// /proc/sys/net/ipv4/ip_local_port_range in ip(7).
1545-
///
1545+
///
15461546
/// * EBADF - The argument sockfd is not a valid file descriptor.
1547-
///
1547+
///
15481548
/// * ENOTSOCK - The file descriptor sockfd does not refer to a socket.
1549-
///
1549+
///
15501550
/// * EOPNOTSUPP - The socket is not of a type that supports the listen()
15511551
/// operation.
1552-
///
1552+
///
15531553
/// ### Panics
1554-
///
1554+
///
15551555
/// * invalid or out-of-bounds file descriptor), calling unwrap() on it will cause a panic.
1556-
/// * unknown errno value from socket bind sys call from libc in the case
1556+
/// * unknown errno value from socket bind sys call from libc in the case
15571557
/// that the socket isn't assigned an address
15581558
/// * unknown errno value from socket listen sys call from libc
1559-
///
1560-
/// for more detailed description of all the commands and return values, see
1559+
///
1560+
/// for more detailed description of all the commands and return values, see
15611561
/// [listen(2)](https://linux.die.net/man/2/listen)
15621562
//
1563-
// TODO: We are currently ignoring backlog
1563+
// TODO: We are currently ignoring backlog
15641564
pub fn listen_syscall(&self, fd: i32, _backlog: i32) -> i32 {
15651565
//BUG:s
15661566
//If fd is out of range of [0,MAXFD], process will panic
@@ -1607,7 +1607,7 @@ impl Cage {
16071607
//If the given socket is not connected, it is ready
16081608
//to begin listening
16091609
ConnState::NOTCONNECTED => {
1610-
//If the given socket is not a TCP socket, then the
1610+
//If the given socket is not a TCP socket, then the
16111611
//socket can not listen for connections
16121612
if sockhandle.protocol != IPPROTO_TCP {
16131613
return syscall_error(
@@ -1676,8 +1676,8 @@ impl Cage {
16761676
panic!("Unknown errno value from socket listen returned!")
16771677
}
16781678
};
1679-
//Remove the tuple of the address, port, and
1680-
//port type from the set of listening ports
1679+
//Remove the tuple of the address, port, and
1680+
//port type from the set of listening ports
16811681
//as we are returning from an error
16821682
//** Why dont we use 'porttuple' as the argument for the key ?? */
16831683
NET_METADATA.listening_port_set.remove(&mux_port(
@@ -1692,14 +1692,14 @@ impl Cage {
16921692
return lr;
16931693
};
16941694

1695-
// Set the rawfd for select_syscall as we cannot implement the select
1696-
// logics for AF_INET socket right now, so we have to call the select
1697-
// syscall from libc, which takes the rawfd as the argument instead of
1695+
// Set the rawfd for select_syscall as we cannot implement the select
1696+
// logics for AF_INET socket right now, so we have to call the select
1697+
// syscall from libc, which takes the rawfd as the argument instead of
16981698
// the fake fd used by lind.
16991699
// The raw fd of the socket is the set to be the same as the fd set by the kernal in the libc connect call
17001700
sockfdobj.rawfd = sockhandle.innersocket.as_ref().unwrap().raw_sys_fd;
17011701

1702-
//If listening socket is not in the table of pending
1702+
//If listening socket is not in the table of pending
17031703
//connections, we must insert it as the key with
17041704
//an empty vector as the value
17051705
//We can now track incoming connections
@@ -1714,7 +1714,7 @@ impl Cage {
17141714
}
17151715
}
17161716

1717-
//Otherwise, the file descriptor refers to something other
1717+
//Otherwise, the file descriptor refers to something other
17181718
//than a socket, return with error
17191719
_ => {
17201720
return syscall_error(

src/safeposix/syscalls/sys_calls.rs

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ use crate::safeposix::filesystem::{decref_dir, metawalk, Inode, FS_METADATA};
4343
use crate::safeposix::net::NET_METADATA;
4444
use crate::safeposix::shm::SHM_METADATA;
4545

46-
47-
4846
impl Cage {
4947
fn unmap_shm_mappings(&self) {
5048
//unmap shm mappings on exit or exec
@@ -72,41 +70,41 @@ impl Cage {
7270
}
7371

7472
/// ### Description
75-
///
73+
///
7674
///'fork_syscall` creates a new process (cage object)
77-
/// The newly created child process is an exact copy of the
78-
/// parent process (the process that calls fork)
75+
/// The newly created child process is an exact copy of the
76+
/// parent process (the process that calls fork)
7977
/// apart from it's cage_id and the parent_id
80-
/// In this function we clone the mutex table, condition variables table,
81-
/// semaphore table and the file descriptors and create
82-
/// a new Cage object with these cloned tables.
83-
/// We also update the shared memory mappings - and create mappings
84-
/// from the new Cage object the the
85-
/// parent Cage object's memory mappings.
86-
///
78+
/// In this function we clone the mutex table, condition variables table,
79+
/// semaphore table and the file descriptors and create
80+
/// a new Cage object with these cloned tables.
81+
/// We also update the shared memory mappings - and create mappings
82+
/// from the new Cage object the the
83+
/// parent Cage object's memory mappings.
84+
///
8785
/// ### Arguments
88-
///
86+
///
8987
/// It accepts one parameter:
90-
///
88+
///
9189
/// * `child_cageid` : an integer representing the pid of the child process
92-
///
90+
///
9391
/// ### Errors
9492
///
9593
/// There are 2 scenarios where the call to `fork_syscall` might return an error
96-
///
94+
///
9795
/// * When the RawMutex::create() call fails to create a new Mutex object
9896
/// * When the RawCondvar::create() call fails to create a new Condition Variable object
99-
///
97+
///
10098
/// ### Returns
101-
///
99+
///
102100
/// On success it returns a value of 0, and the new child Cage object is added to Cagetable
103-
///
104-
/// ### Panics
105-
///
101+
///
102+
/// ### Panics
103+
///
106104
/// This system call has no scenarios where it panics
107-
///
105+
///
108106
/// To learn more about the syscall and possible error values, see
109-
/// [fork(2)](https://man7.org/linux/man-pages/man2/fork.2.html)
107+
/// [fork(2)](https://man7.org/linux/man-pages/man2/fork.2.html)
110108
111109
pub fn fork_syscall(&self, child_cageid: u64) -> i32 {
112110
//Create a new mutex table that replicates the mutex table of the parent (calling) Cage object
@@ -116,7 +114,7 @@ impl Cage {
116114
let mut new_mutex_table = vec![];
117115
//Loop through each element in the mutex table
118116
//Each entry in the mutex table represents a `lock` which the parent process holds
119-
//Copying them into the child's Cage exhibits the inheritance of the lock
117+
//Copying them into the child's Cage exhibits the inheritance of the lock
120118
for elem in mutextable.iter() {
121119
if elem.is_some() {
122120
//If the mutex is `Some` - we create a new mutex and store it in the child's mutex table
@@ -151,7 +149,7 @@ impl Cage {
151149
//Construct a replica of the condition variables table in the child cage object
152150
//This table stores condition variables - which are special variables that the process
153151
//uses to determine whether certain conditions have been met or not. Threads use condition variables
154-
//to stop or resume their operation depending on the value of these variables.
152+
//to stop or resume their operation depending on the value of these variables.
155153
//Read the CondVar table of the calling process
156154
let cvtable = self.cv_table.read();
157155
// Initialize the table for the child process
@@ -239,11 +237,11 @@ impl Cage {
239237
let sock_tmp = socket_filedesc_obj.handle.clone();
240238
let mut sockhandle = sock_tmp.write();
241239
let socket_type = sockhandle.domain;
242-
//Here we only increment the reference for AF_UNIX socket type
240+
//Here we only increment the reference for AF_UNIX socket type
243241
//Since these are the only sockets that have an inode associated with them
244242
if socket_type == AF_UNIX {
245243
//Increment the appropriate reference counter of the correct socket
246-
//Each socket has two pipes associated with them - a read and write pipe
244+
//Each socket has two pipes associated with them - a read and write pipe
247245
//Here we grab these two pipes and increment their references individually
248246
//And also increment the reference count of the socket as a whole
249247
if let Some(sockinfo) = &sockhandle.unix_info {
@@ -255,9 +253,9 @@ impl Cage {
255253
}
256254
if let Inode::Socket(ref mut sock) =
257255
*(FS_METADATA.inodetable.get_mut(&sockinfo.inode).unwrap())
258-
{
259-
sock.refcount += 1;
260-
}
256+
{
257+
sock.refcount += 1;
258+
}
261259
}
262260
}
263261
drop(sockhandle);
@@ -268,13 +266,12 @@ impl Cage {
268266
let newfdobj = filedesc_enum.clone();
269267
// Insert the file descriptor object into the new file descriptor table
270268
let _insertval = newfdtable[fd as usize].write().insert(newfdobj);
271-
272269
}
273270
}
274271

275272
//We read the current working directory of the parent Cage object
276273
let cwd_container = self.cwd.read();
277-
//We try to resolve the inode of the current working directory - if the
274+
//We try to resolve the inode of the current working directory - if the
278275
//resolution is successful we update the reference count of the current working directory
279276
//since the newly created Child cage object also references the same directory
280277
//If the resolution is not successful - the code panics since the cwd's inode cannot be resolved
@@ -291,10 +288,10 @@ impl Cage {
291288
panic!("We changed from a directory that was not a directory in chdir!");
292289
}
293290

294-
// We clone the parent cage's main threads and store them and index 0
295-
// This is done since there isn't a thread established for the child Cage object yet -
296-
// And there is no threadId to store it at.
297-
// The child Cage object can then initialize and store the sigset appropriately when it establishes its own
291+
// We clone the parent cage's main threads and store them and index 0
292+
// This is done since there isn't a thread established for the child Cage object yet -
293+
// And there is no threadId to store it at.
294+
// The child Cage object can then initialize and store the sigset appropriately when it establishes its own
298295
// main thread id.
299296
let newsigset = interface::RustHashMap::new();
300297
// Here we check if Lind is being run under the test suite or not
@@ -316,7 +313,7 @@ impl Cage {
316313
newsigset.insert(0, mainsigset);
317314
}
318315

319-
// Construct a new semaphore table in child cage which equals to the one in the parent cage
316+
// Construct a new semaphore table in child cage which equals to the one in the parent cage
320317
let semtable = &self.sem_table;
321318
let new_semtable: interface::RustHashMap<
322319
u32,

src/tests/networking_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ pub mod net_tests {
670670
lindrustfinalize();
671671
}
672672

673-
//We try to queue more than 5 connections, as the
673+
//We try to queue more than 5 connections, as the
674674
//backlog is set to 5. We expect only the first 5 queues to return
675675
//with success.
676676
//Currently, the 6th connection returns with EINPROGRESS, while
@@ -719,7 +719,7 @@ pub mod net_tests {
719719
assert_eq!(cage.connect_syscall(clientsockfd3, &socket), -115);
720720
assert_eq!(cage.connect_syscall(clientsockfd4, &socket), -115);
721721
assert_eq!(cage.connect_syscall(clientsockfd5, &socket), -115);
722-
assert_eq!(cage.connect_syscall(clientsockfd6, &socket), -111);
722+
assert_eq!(cage.connect_syscall(clientsockfd6, &socket), -111);
723723

724724
assert_eq!(cage.close_syscall(serversockfd), 0);
725725
assert_eq!(cage.close_syscall(clientsockfd1), 0);

0 commit comments

Comments
 (0)