@@ -10814,6 +10814,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
10814
10814
// ret == bytes read, or target error code
10815
10815
10816
10816
dirp = fdopendir (dir_fd );
10817
+ gemu_log ("\n\tgetdents fdopendir: %p\n" , dirp );
10817
10818
if (!dirp ) {
10818
10819
ret = - host_to_target_errno (errno );
10819
10820
goto fail ;
@@ -10824,29 +10825,28 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
10824
10825
ret = - TARGET_ENOMEM ;
10825
10826
goto fail ;
10826
10827
}
10828
+ gemu_log ("\n\tgetdents host_dirp: %p\n" , host_dirp );
10829
+
10827
10830
10828
10831
// collect readdir calls into getdents dirp * buffer
10829
10832
target_dirp = lock_user (VERIFY_WRITE , arg2 , count , 0 );
10830
10833
if (!target_dirp ) {
10831
10834
goto efault ;
10832
10835
}
10836
+ gemu_log ("\n\tgetdents target_dirp: %p\n" , target_dirp );
10837
+
10833
10838
10834
10839
struct dirent * de ;
10835
10840
struct target_dirent * tde = target_dirp ;
10836
10841
uint bytes_used = 0 ;
10837
10842
uint target_reclen ;
10838
10843
uint name_len ;
10839
10844
10840
- for (;;) {
10841
- de = readdir (dirp );
10842
- if (!de ) {
10843
- found_err = TRUE;
10844
- break ;
10845
- }
10845
+ while ((de = readdir (dirp ))) {
10846
10846
// check if new entry will overflow the target buffer
10847
10847
name_len = de -> d_namlen + 1 ;
10848
10848
target_reclen = target_dirent_len + name_len ;
10849
- // TODO -> QEMU_ALIGN_UP(target_reclen, alignof(struct target_dirent)) ?
10849
+ // is this the correct way to align this structure.. ?
10850
10850
target_reclen = QEMU_ALIGN_UP (target_reclen , __alignof(struct target_dirent ));
10851
10851
if (bytes_used + target_reclen > count ) {
10852
10852
break ;
@@ -10868,8 +10868,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
10868
10868
ret = bytes_used ;
10869
10869
}
10870
10870
unlock_user (target_dirp , arg2 , ret );
10871
- g_free (dirp );
10872
- // handle possible readdir errors here
10871
+ // Don't close the `DIR *` pointer, as that will close the fd
10872
+ // which was used in `fdopendir`
10873
+ // closedir(dirp);
10873
10874
}
10874
10875
// Old Linux code
10875
10876
// #ifdef __NR_getdents
@@ -14613,9 +14614,39 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
14613
14614
strncpy (target_buf , "Qemu" , arg3 - 1 );
14614
14615
break ;
14615
14616
14616
- case TARGET_NR_sysinfo_processors :
14617
+ case TARGET_NR_sysinfo_mips_vendor :
14618
+ strncpy (target_buf , "SGI" , arg3 - 1 );
14619
+ break ;
14620
+ case TARGET_NR_sysinfo_mips_osprovider :
14621
+ strncpy (target_buf , "Qemu" , arg3 - 1 );
14622
+ break ;
14623
+ case TARGET_NR_sysinfo_mips_osname :
14624
+ strncpy (target_buf , "IRIX" , arg3 - 1 );
14625
+ break ;
14626
+ case TARGET_NR_sysinfo_mips_hwname :
14627
+ strncpy (target_buf , "IP22" , arg3 - 1 );
14628
+ break ;
14629
+ case TARGET_NR_sysinfo_mips_numprocessor :
14630
+ strncpy (target_buf , "1" , arg3 - 1 );
14631
+ break ;
14632
+ case TARGET_NR_sysinfo_mips_hostid :
14633
+ strncpy (target_buf , "c01a4b05" , arg3 - 1 );
14634
+ break ;
14635
+ case TARGET_NR_sysinfo_mips_osrelmaj :
14636
+ strncpy (target_buf , "6" , arg3 - 1 );
14637
+ break ;
14638
+ case TARGET_NR_sysinfo_mips_osrelmin :
14639
+ strncpy (target_buf , "5" , arg3 - 1 );
14640
+ break ;
14641
+ case TARGET_NR_sysinfo_mips_osrelpatch :
14642
+ strncpy (target_buf , "0" , arg3 - 1 );
14643
+ break ;
14644
+ case TARGET_NR_sysinfo_mips_processors :
14617
14645
strncpy (target_buf , "R4000 3.0" , arg3 - 1 );
14618
14646
break ;
14647
+ case TARGET_NR_sysinfo_mips_availprocessors :
14648
+ strncpy (target_buf , "1" , arg3 - 1 );
14649
+ break ;
14619
14650
default :
14620
14651
gemu_log ("qemu: Unsupported syscall: sgisysinfo(%d)\n" , (int )arg1 );
14621
14652
ret = - TARGET_EINVAL ;
0 commit comments