| OLD | NEW |
| 1 | 1 |
| 2 /*--------------------------------------------------------------------*/ | 2 /*--------------------------------------------------------------------*/ |
| 3 /*--- Wrappers for generic Unix system calls syswrap-generic.c ---*/ | 3 /*--- Wrappers for generic Unix system calls syswrap-generic.c ---*/ |
| 4 /*--------------------------------------------------------------------*/ | 4 /*--------------------------------------------------------------------*/ |
| 5 | 5 |
| 6 /* | 6 /* |
| 7 This file is part of Valgrind, a dynamic binary instrumentation | 7 This file is part of Valgrind, a dynamic binary instrumentation |
| 8 framework. | 8 framework. |
| 9 | 9 |
| 10 Copyright (C) 2000-2009 Julian Seward | 10 Copyright (C) 2000-2009 Julian Seward |
| (...skipping 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3100 PRE(sys_getppid) | 3100 PRE(sys_getppid) |
| 3101 { | 3101 { |
| 3102 PRINT("sys_getppid ()"); | 3102 PRINT("sys_getppid ()"); |
| 3103 PRE_REG_READ0(long, "getppid"); | 3103 PRE_REG_READ0(long, "getppid"); |
| 3104 } | 3104 } |
| 3105 | 3105 |
| 3106 static void common_post_getrlimit(ThreadId tid, UWord a1, UWord a2) | 3106 static void common_post_getrlimit(ThreadId tid, UWord a1, UWord a2) |
| 3107 { | 3107 { |
| 3108 POST_MEM_WRITE( a2, sizeof(struct vki_rlimit) ); | 3108 POST_MEM_WRITE( a2, sizeof(struct vki_rlimit) ); |
| 3109 | 3109 |
| 3110 #ifdef _RLIMIT_POSIX_FLAG |
| 3111 /* Darwin will sometimes set _RLIMIT_POSIX_FLAG on getrlimit calls. |
| 3112 * Unset it here to make the switch case below work correctly. |
| 3113 * _RLIMIT_POSIX_FLAG is defined in sys/resource.h and is only |
| 3114 * present on Darwin. |
| 3115 */ |
| 3116 a1 &= ~_RLIMIT_POSIX_FLAG; |
| 3117 #endif |
| 3118 |
| 3110 switch (a1) { | 3119 switch (a1) { |
| 3111 case VKI_RLIMIT_NOFILE: | 3120 case VKI_RLIMIT_NOFILE: |
| 3112 ((struct vki_rlimit *)a2)->rlim_cur = VG_(fd_soft_limit); | 3121 ((struct vki_rlimit *)a2)->rlim_cur = VG_(fd_soft_limit); |
| 3113 ((struct vki_rlimit *)a2)->rlim_max = VG_(fd_hard_limit); | 3122 ((struct vki_rlimit *)a2)->rlim_max = VG_(fd_hard_limit); |
| 3114 break; | 3123 break; |
| 3115 | 3124 |
| 3116 case VKI_RLIMIT_DATA: | 3125 case VKI_RLIMIT_DATA: |
| 3117 *((struct vki_rlimit *)a2) = VG_(client_rlimit_data); | 3126 *((struct vki_rlimit *)a2) = VG_(client_rlimit_data); |
| 3118 break; | 3127 break; |
| 3119 | 3128 |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3819 } | 3828 } |
| 3820 | 3829 |
| 3821 PRE(sys_setreuid) | 3830 PRE(sys_setreuid) |
| 3822 { | 3831 { |
| 3823 PRINT("sys_setreuid ( 0x%lx, 0x%lx )", ARG1, ARG2); | 3832 PRINT("sys_setreuid ( 0x%lx, 0x%lx )", ARG1, ARG2); |
| 3824 PRE_REG_READ2(long, "setreuid", vki_uid_t, ruid, vki_uid_t, euid); | 3833 PRE_REG_READ2(long, "setreuid", vki_uid_t, ruid, vki_uid_t, euid); |
| 3825 } | 3834 } |
| 3826 | 3835 |
| 3827 PRE(sys_setrlimit) | 3836 PRE(sys_setrlimit) |
| 3828 { | 3837 { |
| 3838 UWord arg1 = ARG1; |
| 3829 PRINT("sys_setrlimit ( %ld, %#lx )", ARG1,ARG2); | 3839 PRINT("sys_setrlimit ( %ld, %#lx )", ARG1,ARG2); |
| 3830 PRE_REG_READ2(long, "setrlimit", | 3840 PRE_REG_READ2(long, "setrlimit", |
| 3831 unsigned int, resource, struct rlimit *, rlim); | 3841 unsigned int, resource, struct rlimit *, rlim); |
| 3832 PRE_MEM_READ( "setrlimit(rlim)", ARG2, sizeof(struct vki_rlimit) ); | 3842 PRE_MEM_READ( "setrlimit(rlim)", ARG2, sizeof(struct vki_rlimit) ); |
| 3833 | 3843 |
| 3834 if (ARG1 == VKI_RLIMIT_NOFILE) { | 3844 #ifdef _RLIMIT_POSIX_FLAG |
| 3845 /* Darwin will sometimes set _RLIMIT_POSIX_FLAG on setrlimit calls. |
| 3846 * Unset it here to make the if statements below work correctly. |
| 3847 * _RLIMIT_POSIX_FLAG is defined in sys/resource.h and is only |
| 3848 * present on Darwin. |
| 3849 */ |
| 3850 arg1 &= ~_RLIMIT_POSIX_FLAG; |
| 3851 #endif |
| 3852 |
| 3853 if (arg1 == VKI_RLIMIT_NOFILE) { |
| 3835 if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(fd_hard_limit) || | 3854 if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(fd_hard_limit) || |
| 3836 ((struct vki_rlimit *)ARG2)->rlim_max != VG_(fd_hard_limit)) { | 3855 ((struct vki_rlimit *)ARG2)->rlim_max != VG_(fd_hard_limit)) { |
| 3837 SET_STATUS_Failure( VKI_EPERM ); | 3856 SET_STATUS_Failure( VKI_EPERM ); |
| 3838 } | 3857 } |
| 3839 else { | 3858 else { |
| 3840 VG_(fd_soft_limit) = ((struct vki_rlimit *)ARG2)->rlim_cur; | 3859 VG_(fd_soft_limit) = ((struct vki_rlimit *)ARG2)->rlim_cur; |
| 3841 SET_STATUS_Success( 0 ); | 3860 SET_STATUS_Success( 0 ); |
| 3842 } | 3861 } |
| 3843 } | 3862 } |
| 3844 else if (ARG1 == VKI_RLIMIT_DATA) { | 3863 else if (arg1 == VKI_RLIMIT_DATA) { |
| 3845 if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(client_rlimit_data).rlim_m
ax || | 3864 if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(client_rlimit_data).rlim_m
ax || |
| 3846 ((struct vki_rlimit *)ARG2)->rlim_max > VG_(client_rlimit_data).rlim_m
ax) { | 3865 ((struct vki_rlimit *)ARG2)->rlim_max > VG_(client_rlimit_data).rlim_m
ax) { |
| 3847 SET_STATUS_Failure( VKI_EPERM ); | 3866 SET_STATUS_Failure( VKI_EPERM ); |
| 3848 } | 3867 } |
| 3849 else { | 3868 else { |
| 3850 VG_(client_rlimit_data) = *(struct vki_rlimit *)ARG2; | 3869 VG_(client_rlimit_data) = *(struct vki_rlimit *)ARG2; |
| 3851 SET_STATUS_Success( 0 ); | 3870 SET_STATUS_Success( 0 ); |
| 3852 } | 3871 } |
| 3853 } | 3872 } |
| 3854 else if (ARG1 == VKI_RLIMIT_STACK && tid == 1) { | 3873 else if (arg1 == VKI_RLIMIT_STACK && tid == 1) { |
| 3855 if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(client_rlimit_stack).rlim_
max || | 3874 if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(client_rlimit_stack).rlim_
max || |
| 3856 ((struct vki_rlimit *)ARG2)->rlim_max > VG_(client_rlimit_stack).rlim_
max) { | 3875 ((struct vki_rlimit *)ARG2)->rlim_max > VG_(client_rlimit_stack).rlim_
max) { |
| 3857 SET_STATUS_Failure( VKI_EPERM ); | 3876 SET_STATUS_Failure( VKI_EPERM ); |
| 3858 } | 3877 } |
| 3859 else { | 3878 else { |
| 3860 VG_(threads)[tid].client_stack_szB = ((struct vki_rlimit *)ARG2)->rlim_
cur; | 3879 VG_(threads)[tid].client_stack_szB = ((struct vki_rlimit *)ARG2)->rlim_
cur; |
| 3861 VG_(client_rlimit_stack) = *(struct vki_rlimit *)ARG2; | 3880 VG_(client_rlimit_stack) = *(struct vki_rlimit *)ARG2; |
| 3862 SET_STATUS_Success( 0 ); | 3881 SET_STATUS_Success( 0 ); |
| 3863 } | 3882 } |
| 3864 } | 3883 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 POST_MEM_WRITE( ARG2, sizeof(vki_stack_t)); | 4112 POST_MEM_WRITE( ARG2, sizeof(vki_stack_t)); |
| 4094 } | 4113 } |
| 4095 | 4114 |
| 4096 #undef PRE | 4115 #undef PRE |
| 4097 #undef POST | 4116 #undef POST |
| 4098 | 4117 |
| 4099 /*--------------------------------------------------------------------*/ | 4118 /*--------------------------------------------------------------------*/ |
| 4100 /*--- end ---*/ | 4119 /*--- end ---*/ |
| 4101 /*--------------------------------------------------------------------*/ | 4120 /*--------------------------------------------------------------------*/ |
| 4102 | 4121 |
| OLD | NEW |