Commit b03c60f35194db4ba1f53673ab02ade29f54701e

Authored by bellard
1 parent 9de5e440

more syscalls


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@43 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 96 additions and 6 deletions
1 - optimize translated cache chaining (DLL PLT-like system) 1 - optimize translated cache chaining (DLL PLT-like system)
2 -- more syscalls (in particular all 64 bit ones, IPCs, fix 64 bit issues) 2 +- more syscalls (in particular all 64 bit ones, IPCs, fix 64 bit
  3 + issues, fix 16 bit uid issues)
3 - finish signal handing (fp87 state, more siginfo conversions) 4 - finish signal handing (fp87 state, more siginfo conversions)
4 - verify thread support (clone() and various locks) 5 - verify thread support (clone() and various locks)
5 - vm86 syscall support 6 - vm86 syscall support
linux-user/syscall.c
@@ -103,6 +103,10 @@ extern int personality(int); @@ -103,6 +103,10 @@ extern int personality(int);
103 extern int flock(int, int); 103 extern int flock(int, int);
104 extern int setfsuid(int); 104 extern int setfsuid(int);
105 extern int setfsgid(int); 105 extern int setfsgid(int);
  106 +extern int setresuid(int,int,int);
  107 +extern int getresuid(int *,int *,int *);
  108 +extern int setresgid(int,int,int);
  109 +extern int getresgid(int *,int *,int *);
106 110
107 static inline long get_errno(long ret) 111 static inline long get_errno(long ret)
108 { 112 {
@@ -809,6 +813,10 @@ int do_fork(CPUX86State *env, unsigned int flags, unsigned long newsp) @@ -809,6 +813,10 @@ int do_fork(CPUX86State *env, unsigned int flags, unsigned long newsp)
809 813
810 #endif 814 #endif
811 815
  816 +#define high2lowuid(x) (x)
  817 +#define high2lowgid(x) (x)
  818 +#define low2highuid(x) (x)
  819 +#define low2highgid(x) (x)
812 820
813 void syscall_init(void) 821 void syscall_init(void)
814 { 822 {
@@ -913,7 +921,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -913,7 +921,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
913 ret = get_errno(umount((const char *)arg1)); 921 ret = get_errno(umount((const char *)arg1));
914 break; 922 break;
915 case TARGET_NR_setuid: 923 case TARGET_NR_setuid:
916 - ret = get_errno(setuid(arg1)); 924 + ret = get_errno(setuid(low2highuid(arg1)));
917 break; 925 break;
918 case TARGET_NR_getuid: 926 case TARGET_NR_getuid:
919 ret = get_errno(getuid()); 927 ret = get_errno(getuid());
@@ -984,7 +992,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -984,7 +992,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
984 case TARGET_NR_prof: 992 case TARGET_NR_prof:
985 goto unimplemented; 993 goto unimplemented;
986 case TARGET_NR_setgid: 994 case TARGET_NR_setgid:
987 - ret = get_errno(setgid(arg1)); 995 + ret = get_errno(setgid(low2highgid(arg1)));
988 break; 996 break;
989 case TARGET_NR_getgid: 997 case TARGET_NR_getgid:
990 ret = get_errno(getgid()); 998 ret = get_errno(getgid());
@@ -1727,14 +1735,41 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1727,14 +1735,41 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1727 } 1735 }
1728 } 1736 }
1729 break; 1737 break;
1730 -  
1731 case TARGET_NR_setresuid: 1738 case TARGET_NR_setresuid:
  1739 + ret = get_errno(setresuid(low2highuid(arg1),
  1740 + low2highuid(arg2),
  1741 + low2highuid(arg3)));
  1742 + break;
1732 case TARGET_NR_getresuid: 1743 case TARGET_NR_getresuid:
  1744 + {
  1745 + int ruid, euid, suid;
  1746 + ret = get_errno(getresuid(&ruid, &euid, &suid));
  1747 + if (!is_error(ret)) {
  1748 + *(uint16_t *)arg1 = tswap16(high2lowuid(ruid));
  1749 + *(uint16_t *)arg2 = tswap16(high2lowuid(euid));
  1750 + *(uint16_t *)arg3 = tswap16(high2lowuid(suid));
  1751 + }
  1752 + }
  1753 + break;
  1754 + case TARGET_NR_setresgid:
  1755 + ret = get_errno(setresgid(low2highgid(arg1),
  1756 + low2highgid(arg2),
  1757 + low2highgid(arg3)));
  1758 + break;
  1759 + case TARGET_NR_getresgid:
  1760 + {
  1761 + int rgid, egid, sgid;
  1762 + ret = get_errno(getresgid(&rgid, &egid, &sgid));
  1763 + if (!is_error(ret)) {
  1764 + *(uint16_t *)arg1 = high2lowgid(tswap16(rgid));
  1765 + *(uint16_t *)arg2 = high2lowgid(tswap16(egid));
  1766 + *(uint16_t *)arg3 = high2lowgid(tswap16(sgid));
  1767 + }
  1768 + }
  1769 + break;
1733 case TARGET_NR_vm86: 1770 case TARGET_NR_vm86:
1734 case TARGET_NR_query_module: 1771 case TARGET_NR_query_module:
1735 case TARGET_NR_nfsservctl: 1772 case TARGET_NR_nfsservctl:
1736 - case TARGET_NR_setresgid:  
1737 - case TARGET_NR_getresgid:  
1738 case TARGET_NR_prctl: 1773 case TARGET_NR_prctl:
1739 case TARGET_NR_pread: 1774 case TARGET_NR_pread:
1740 case TARGET_NR_pwrite: 1775 case TARGET_NR_pwrite:
@@ -1789,26 +1824,80 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1789,26 +1824,80 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1789 break; 1824 break;
1790 1825
1791 case TARGET_NR_lchown32: 1826 case TARGET_NR_lchown32:
  1827 + ret = get_errno(lchown((const char *)arg1, arg2, arg3));
  1828 + break;
1792 case TARGET_NR_getuid32: 1829 case TARGET_NR_getuid32:
  1830 + ret = get_errno(getuid());
  1831 + break;
1793 case TARGET_NR_getgid32: 1832 case TARGET_NR_getgid32:
  1833 + ret = get_errno(getgid());
  1834 + break;
1794 case TARGET_NR_geteuid32: 1835 case TARGET_NR_geteuid32:
  1836 + ret = get_errno(geteuid());
  1837 + break;
1795 case TARGET_NR_getegid32: 1838 case TARGET_NR_getegid32:
  1839 + ret = get_errno(getegid());
  1840 + break;
1796 case TARGET_NR_setreuid32: 1841 case TARGET_NR_setreuid32:
  1842 + ret = get_errno(setreuid(arg1, arg2));
  1843 + break;
1797 case TARGET_NR_setregid32: 1844 case TARGET_NR_setregid32:
  1845 + ret = get_errno(setregid(arg1, arg2));
  1846 + break;
1798 case TARGET_NR_getgroups32: 1847 case TARGET_NR_getgroups32:
  1848 + goto unimplemented;
1799 case TARGET_NR_setgroups32: 1849 case TARGET_NR_setgroups32:
  1850 + goto unimplemented;
1800 case TARGET_NR_fchown32: 1851 case TARGET_NR_fchown32:
  1852 + ret = get_errno(fchown(arg1, arg2, arg3));
  1853 + break;
1801 case TARGET_NR_setresuid32: 1854 case TARGET_NR_setresuid32:
  1855 + ret = get_errno(setresuid(arg1, arg2, arg3));
  1856 + break;
1802 case TARGET_NR_getresuid32: 1857 case TARGET_NR_getresuid32:
  1858 + {
  1859 + int ruid, euid, suid;
  1860 + ret = get_errno(getresuid(&ruid, &euid, &suid));
  1861 + if (!is_error(ret)) {
  1862 + *(uint32_t *)arg1 = tswap32(ruid);
  1863 + *(uint32_t *)arg2 = tswap32(euid);
  1864 + *(uint32_t *)arg3 = tswap32(suid);
  1865 + }
  1866 + }
  1867 + break;
1803 case TARGET_NR_setresgid32: 1868 case TARGET_NR_setresgid32:
  1869 + ret = get_errno(setresgid(arg1, arg2, arg3));
  1870 + break;
1804 case TARGET_NR_getresgid32: 1871 case TARGET_NR_getresgid32:
  1872 + {
  1873 + int rgid, egid, sgid;
  1874 + ret = get_errno(getresgid(&rgid, &egid, &sgid));
  1875 + if (!is_error(ret)) {
  1876 + *(uint32_t *)arg1 = tswap32(rgid);
  1877 + *(uint32_t *)arg2 = tswap32(egid);
  1878 + *(uint32_t *)arg3 = tswap32(sgid);
  1879 + }
  1880 + }
  1881 + break;
1805 case TARGET_NR_chown32: 1882 case TARGET_NR_chown32:
  1883 + ret = get_errno(chown((const char *)arg1, arg2, arg3));
  1884 + break;
1806 case TARGET_NR_setuid32: 1885 case TARGET_NR_setuid32:
  1886 + ret = get_errno(setuid(arg1));
  1887 + break;
1807 case TARGET_NR_setgid32: 1888 case TARGET_NR_setgid32:
  1889 + ret = get_errno(setgid(arg1));
  1890 + break;
1808 case TARGET_NR_setfsuid32: 1891 case TARGET_NR_setfsuid32:
  1892 + ret = get_errno(setfsuid(arg1));
  1893 + break;
1809 case TARGET_NR_setfsgid32: 1894 case TARGET_NR_setfsgid32:
  1895 + ret = get_errno(setfsgid(arg1));
  1896 + break;
1810 case TARGET_NR_pivot_root: 1897 case TARGET_NR_pivot_root:
  1898 + goto unimplemented;
1811 case TARGET_NR_mincore: 1899 case TARGET_NR_mincore:
  1900 + goto unimplemented;
1812 case TARGET_NR_madvise: 1901 case TARGET_NR_madvise:
1813 goto unimplemented; 1902 goto unimplemented;
1814 #if TARGET_LONG_BITS == 32 1903 #if TARGET_LONG_BITS == 32