@@ -508,8 +508,6 @@ static void fat32_short_name(const fat32_dir_entry_t* e, char* out, size_t out_s
508508}
509509
510510static int sys_getdents64 (uint64_t fd , char * buf , uint64_t buflen ) {
511- fd_table_init ();
512-
513511 if (!buf || buflen < sizeof (linux_dirent64_t ))
514512 return - LINUX_EINVAL ;
515513 if (!fd_valid ((int )fd ))
@@ -676,7 +674,6 @@ static int sys_getdents64(uint64_t fd, char* buf, uint64_t buflen) {
676674
677675static int64 sys_open_common (int dirfd , const char * path , int flags , int mode ) {
678676 (void )mode ;
679- fd_table_init ();
680677
681678 if (path == NULL )
682679 return - LINUX_EINVAL ;
@@ -696,8 +693,6 @@ static int64 sys_open_common(int dirfd, const char* path, int flags, int mode) {
696693}
697694
698695static int64 sys_close (uint64_t fd ) {
699- fd_table_init ();
700-
701696 if (!fd_valid ((int )fd ))
702697 return - LINUX_EBADF ;
703698
@@ -770,8 +765,6 @@ static int64 sys_statx(int dirfd, const char* path, int flags, unsigned int mask
770765}
771766
772767static int64 sys_read (uint64_t fd , char * buf , uint64_t count ) {
773- fd_table_init ();
774-
775768 if (buf == NULL || count == 0 )
776769 return 0 ;
777770
@@ -794,8 +787,6 @@ static int64 sys_read(uint64_t fd, char* buf, uint64_t count) {
794787}
795788
796789static int64 sys_write (uint64_t fd , const char * buf , uint64_t count ) {
797- fd_table_init ();
798-
799790 if (buf == NULL || count == 0 )
800791 return 0 ;
801792
@@ -874,7 +865,6 @@ static int64 sys_ioctl(uint64_t fd, uint64_t req, uint64_t arg) {
874865}
875866
876867static int64 sys_fcntl (uint64_t fd , uint64_t cmd , uint64_t arg ) {
877- fd_table_init ();
878868 if (!fd_valid ((int )fd ))
879869 return - LINUX_EBADF ;
880870
@@ -912,8 +902,6 @@ static int64 sys_access_common(int dirfd, const char* path, int mode) {
912902}
913903
914904static int64 sys_lseek (uint64_t fd , int64_t offset , uint64_t whence ) {
915- fd_table_init ();
916-
917905 if (!fd_valid ((int )fd ))
918906 return - LINUX_EBADF ;
919907
@@ -945,8 +933,6 @@ static int64 sys_lseek(uint64_t fd, int64_t offset, uint64_t whence) {
945933}
946934
947935static int64 sys_dup2 (uint64_t oldfd , uint64_t newfd ) {
948- fd_table_init ();
949-
950936 if (!fd_valid ((int )oldfd ))
951937 return - LINUX_EBADF ;
952938
@@ -958,8 +944,6 @@ static int64 sys_dup2(uint64_t oldfd, uint64_t newfd) {
958944}
959945
960946static int64 sys_dup (uint64_t oldfd ) {
961- fd_table_init ();
962-
963947 if (!fd_valid ((int )oldfd ))
964948 return - LINUX_EBADF ;
965949
@@ -1177,6 +1161,21 @@ static int64 sys_futex(uint32_t* uaddr, int op, uint32_t val,
11771161 }
11781162}
11791163
1164+ struct passwd {
1165+ char * pw_name ;
1166+ int pw_uid ;
1167+ };
1168+
1169+ struct passwd fake_root = {
1170+ .pw_name = "root" ,
1171+ .pw_uid = 0 ,
1172+ };
1173+
1174+ struct passwd * getpwuid (int uid ) {
1175+ if (uid == 0 )
1176+ return & fake_root ;
1177+ return NULL ;
1178+ }
11801179
11811180// THIS IS FOR INTERRUPT 0X80
11821181void int80_handler (InterruptFrame * frame )
@@ -1304,6 +1303,9 @@ uint64_t syscall_dispatch (
13041303 case LINUX_SYS_CHDIR :
13051304 return sys_chdir ((const char * )arg1 );
13061305
1306+ case LINUX_SYS_FORK :
1307+ return 0 ;
1308+
13071309 case LINUX_SYS_UNAME :
13081310 return sys_uname ((linux_utsname_t * )arg1 );
13091311
0 commit comments