@@ -46,10 +46,22 @@ int syscall_1_process_exec_lba_sc(int lba_start, int sector_count) {
4646 return process_exec (lba_start , sector_count );
4747}
4848
49- int syscall_1_process_spawn_fname (int user_ds , char * _us_filename ) {
49+ int syscall_1_process_spawn_fname (int user_ds , char * _us_filename , char * _us_argv [] ) {
5050 char filename [FS_FFS_FILENAME_LIMIT ];
51+ char argv_with_uspointer [PROCESS_MAX_ARGC ];
52+ char * argv_with_kspointer [PROCESS_MAX_ARGC ];
53+ char argv [PROCESS_MAX_ARGC ][PROCESS_MAX_ARG_LEN ]; // data store
5154 syscall_strncpy_user_to_kernel (user_ds , _us_filename , filename , sizeof (filename ));
52-
55+ syscall_strncpy_user_to_kernel (user_ds , _us_argv , argv_with_uspointer , sizeof (argv_with_uspointer ));
56+ // if src string is NULL, then dst should be null.
57+ for (int i = 0 ; i < PROCESS_MAX_ARGC ; i ++ ) {
58+ if (argv_with_uspointer [i ]== NULL ) {
59+ argv_with_kspointer [i ]= NULL ;
60+ break ;
61+ }
62+ syscall_strncpy_user_to_kernel (user_ds , argv [i ], argv_with_uspointer [i ], sizeof (argv [i ]));
63+ argv_with_kspointer [i ] = argv [i ];
64+ }
5365
5466 union FFSFileEntry entry ;
5567 int file_id = file_handler_find (filename , & entry );
@@ -58,6 +70,8 @@ int syscall_1_process_spawn_fname(int user_ds, char *_us_filename) {
5870
5971 int lba_start = resolve_abs_lba (FFS_UNIQUE_PARITION_ID , entry .content .start_block_id );
6072 int sector_count = (entry .content .filesize + FS_BLOCK_SIZE - 1 )/FS_BLOCK_SIZE ;
73+
74+ // TODO: process created should have argv pushed on top of stack.
6175 return syscall_1_process_spawn_lba_sc (lba_start , sector_count );
6276}
6377
@@ -71,7 +85,7 @@ int syscall_1_process(int operation, int a0, int a1, int a2, int a3, int user_ds
7185 case SYSCALL_PROCESS_SUB_EXEC_LBA_SC :
7286 return syscall_1_process_exec_lba_sc (a0 , a1 );
7387 case SYSCALL_PROCESS_SUB_SPAWN_FNAME :
74- return syscall_1_process_spawn_fname (user_ds , (char * )a0 );
88+ return syscall_1_process_spawn_fname (user_ds , (char * )a0 , ( char * * ) a1 );
7589 }
7690 return -1 ;
7791}
0 commit comments