@@ -43,8 +43,6 @@ use crate::safeposix::filesystem::{decref_dir, metawalk, Inode, FS_METADATA};
4343use crate :: safeposix:: net:: NET_METADATA ;
4444use crate :: safeposix:: shm:: SHM_METADATA ;
4545
46-
47-
4846impl 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 ,
0 commit comments