@@ -10,8 +10,8 @@ use std::path::PathBuf;
1010use std:: sync:: atomic:: { AtomicI32 , AtomicU64 , Ordering :: * } ;
1111use std:: sync:: Arc ;
1212use sysdefs:: constants:: {
13- EXIT_SUCCESS , FDKIND_KERNEL , RAWPOSIX_CAGEID , STDERR_FILENO , STDIN_FILENO , STDOUT_FILENO ,
14- THREEI_CAGEID , VERBOSE ,
13+ EXIT_SUCCESS , FDKIND_KERNEL , INIT_CAGEID , MAIN_THREADID , RAWPOSIX_CAGEID , STDERR_FILENO ,
14+ STDIN_FILENO , STDOUT_FILENO , THREEI_CAGEID , UNUSED_ARG , UNUSED_ID , VERBOSE ,
1515} ;
1616use threei:: {
1717 copy_data_between_cages, copy_handler_table_to_cage, register_handler,
@@ -65,20 +65,20 @@ pub fn register_rawposix_syscall(self_cageid: u64) -> i32 {
6565 let impl_fn_ptr = func as * const ( ) as u64 ;
6666 // Register to handler table in 3i
6767 ret = register_handler (
68- 0 ,
68+ UNUSED_ID ,
6969 RAWPOSIX_CAGEID , // target cageid for this syscall handler
7070 self_cageid, // cage to modify: current cageid
7171 sysno, // target callnum
7272 RUNTIME_TYPE_WASMTIME , // runtime id
7373 RAWPOSIX_CAGEID , // handler function is in the RawPOSIX
7474 impl_fn_ptr,
75- 0 ,
76- 0 ,
77- 0 ,
78- 0 ,
79- 0 ,
80- 0 ,
81- 0 ,
75+ UNUSED_ID ,
76+ UNUSED_ARG ,
77+ UNUSED_ID ,
78+ UNUSED_ARG ,
79+ UNUSED_ID ,
80+ UNUSED_ARG ,
81+ UNUSED_ID ,
8282 ) ;
8383 if ret != 0 {
8484 panic ! (
@@ -116,58 +116,58 @@ pub fn register_threei_syscall(self_cageid: u64) -> i32 {
116116 // Register `register_handler` syscall for this cage
117117 let fp_register = register_handler as * const ( ) as usize as u64 ;
118118 let register_ret = register_handler (
119- 0 ,
119+ UNUSED_ID ,
120120 THREEI_CAGEID , // target cageid for this syscall handler
121121 self_cageid, // cage to modify: current cageid
122122 REGISTER_HANDLER_SYSCALL ,
123123 RUNTIME_TYPE_WASMTIME , // runtime id
124124 THREEI_CAGEID , // handler function is in the 3i
125125 fp_register,
126- 0 ,
127- 0 ,
128- 0 ,
129- 0 ,
130- 0 ,
131- 0 ,
132- 0 ,
126+ UNUSED_ID ,
127+ UNUSED_ARG ,
128+ UNUSED_ID ,
129+ UNUSED_ARG ,
130+ UNUSED_ID ,
131+ UNUSED_ARG ,
132+ UNUSED_ID ,
133133 ) ;
134134
135135 // Register `copy_data_between_cages` syscall for this cage
136136 let fp_copy_data = copy_data_between_cages as * const ( ) as usize as u64 ;
137137 let copy_data_ret = register_handler (
138- 0 ,
138+ UNUSED_ID ,
139139 THREEI_CAGEID , // target cageid for this syscall handler
140140 self_cageid, // cage to modify: current cageid
141141 COPY_DATA_BETWEEN_CAGES_SYSCALL ,
142142 RUNTIME_TYPE_WASMTIME , // runtime id
143143 THREEI_CAGEID , // handler function is in the 3i
144144 fp_copy_data,
145- 0 ,
146- 0 ,
147- 0 ,
148- 0 ,
149- 0 ,
150- 0 ,
151- 0 ,
145+ UNUSED_ID ,
146+ UNUSED_ARG ,
147+ UNUSED_ID ,
148+ UNUSED_ARG ,
149+ UNUSED_ID ,
150+ UNUSED_ARG ,
151+ UNUSED_ID ,
152152 ) ;
153153
154154 // Register `copy_handler_table_to_cage` syscall for this cage
155155 let fp_copy_handler_table = copy_handler_table_to_cage as * const ( ) as usize as u64 ;
156156 let copy_handler_table_ret = register_handler (
157- 0 ,
157+ UNUSED_ID ,
158158 THREEI_CAGEID , // target cageid for this syscall handler
159159 self_cageid, // cage to modify: current cageid
160160 COPY_HANDLER_TABLE_TO_CAGE_SYSCALL ,
161161 RUNTIME_TYPE_WASMTIME , // runtime id
162162 THREEI_CAGEID , // handler function is in the 3i
163163 fp_copy_handler_table,
164- 0 ,
165- 0 ,
166- 0 ,
167- 0 ,
168- 0 ,
169- 0 ,
170- 0 ,
164+ UNUSED_ID ,
165+ UNUSED_ARG ,
166+ UNUSED_ID ,
167+ UNUSED_ARG ,
168+ UNUSED_ID ,
169+ UNUSED_ARG ,
170+ UNUSED_ID ,
171171 ) ;
172172
173173 // Check registration results and panic if either fails
@@ -208,13 +208,11 @@ pub fn rawposix_start(verbosity: isize) {
208208 fdtables:: register_close_handlers ( FDKIND_KERNEL , fdtables:: NULL_FUNC , kernel_close) ;
209209
210210 // register syscalls for init cage
211- register_rawposix_syscall ( 1 ) ;
211+ register_rawposix_syscall ( INIT_CAGEID ) ;
212212
213- register_threei_syscall ( 1 ) ;
213+ register_threei_syscall ( INIT_CAGEID ) ;
214214
215215 // Set up standard file descriptors for the init cage
216- // TODO:
217- // Replace the hardcoded values with variables (possibly by adding a LIND-specific constants file)
218216 let dev_null = CString :: new ( "/dev/null" ) . unwrap ( ) ;
219217
220218 // Make sure that the standard file descriptors (stdin, stdout, stderr) are always valid
@@ -229,12 +227,12 @@ pub fn rawposix_start(verbosity: isize) {
229227
230228 //init cage is its own parent
231229 let initcage = Cage {
232- cageid : 1 ,
230+ cageid : INIT_CAGEID ,
233231 cwd : RwLock :: new ( Arc :: new ( PathBuf :: from ( "/" ) ) ) ,
234- parent : 1 ,
232+ parent : INIT_CAGEID ,
235233 rev_shm : Mutex :: new ( Vec :: new ( ) ) ,
236234 main_threadid : RwLock :: new ( 0 ) ,
237- interval_timer : IntervalTimer :: new ( 1 ) ,
235+ interval_timer : IntervalTimer :: new ( INIT_CAGEID ) ,
238236 epoch_handler : DashMap :: new ( ) ,
239237 signalhandler : DashMap :: new ( ) ,
240238 pending_signals : RwLock :: new ( vec ! [ ] ) ,
@@ -246,16 +244,16 @@ pub fn rawposix_start(verbosity: isize) {
246244
247245 // Add cage to cagetable
248246 add_cage (
249- 1 , // cageid
247+ INIT_CAGEID , // cageid
250248 initcage,
251249 ) ;
252250
253- // init fdtables for cageid 1
254- fdtables:: init_empty_cage ( 1 ) ;
251+ // init fdtables for init cage
252+ fdtables:: init_empty_cage ( INIT_CAGEID ) ;
255253 // Set the first 3 fd to STDIN / STDOUT / STDERR
256254 // STDIN
257255 fdtables:: get_specific_virtual_fd (
258- 1 ,
256+ INIT_CAGEID ,
259257 STDIN_FILENO as u64 ,
260258 FDKIND_KERNEL ,
261259 STDIN_FILENO as u64 ,
@@ -265,7 +263,7 @@ pub fn rawposix_start(verbosity: isize) {
265263 . unwrap ( ) ;
266264 // STDOUT
267265 fdtables:: get_specific_virtual_fd (
268- 1 ,
266+ INIT_CAGEID ,
269267 STDOUT_FILENO as u64 ,
270268 FDKIND_KERNEL ,
271269 STDOUT_FILENO as u64 ,
@@ -275,7 +273,7 @@ pub fn rawposix_start(verbosity: isize) {
275273 . unwrap ( ) ;
276274 // STDERR
277275 fdtables:: get_specific_virtual_fd (
278- 1 ,
276+ INIT_CAGEID ,
279277 STDERR_FILENO as u64 ,
280278 FDKIND_KERNEL ,
281279 STDERR_FILENO as u64 ,
@@ -301,7 +299,7 @@ pub fn rawposix_shutdown() {
301299 cageid as u64 , // target cageid
302300 EXIT_SUCCESS as u64 , // status arg
303301 cageid as u64 , // status arg's cageid
304- 1 , // always main thread
302+ MAIN_THREADID , // always main thread
305303 0 ,
306304 0 ,
307305 0 ,
0 commit comments