1/* Basic syscall test for Solaris/x86 specific syscalls. */ 2 3#include "scalar.h" 4 5#include <string.h> 6#include <sys/fcntl.h> 7#include <sys/lwp.h> 8#include <sys/statvfs.h> 9 10/* Helper functions. These are necessary if we've got two tests for a single 11 syscall. In that case, Memcheck can sometimes merge error messages. Doing 12 each test in its own function prevents that. */ 13__attribute__((noinline)) 14static void sys_openat64(void) 15{ 16 GO(SYS_openat64, "(3-args) 3s 1m"); 17 SY(SYS_openat64, x0 - 1, x0, x0); FAILx(EBADF); 18} 19 20__attribute__((noinline)) 21static void sys_openat642(void) 22{ 23 GO(SYS_openat64, "(4-args) 4s 1m"); 24 SY(SYS_openat64, x0 - 1, x0, x0 | O_CREAT, x0); FAILx(EBADF); 25} 26 27__attribute__((noinline)) 28static void sys_statvfs64(void) 29{ 30 GO(SYS_statvfs64, "2s 2m"); 31 SY(SYS_statvfs64, x0 + 1, x0 + 1); FAIL; 32} 33 34__attribute__((noinline)) 35static int sys_statvfs642(void) 36{ 37 const char path[] = "/"; 38 struct statvfs64 stats; 39 40 GO(SYS_statvfs64, "4s 0m"); 41 SY(SYS_statvfs64, x0 + path, x0 + &stats); SUCC; 42 43 size_t basetype_len = strlen(stats.f_basetype); 44 size_t fstr_len = strlen(stats.f_fstr); 45 46 /* Now check that memory after the strings is reported uninitialized. */ 47 int x = 0; 48 if (stats.f_basetype[basetype_len + 2] != ' ') x = -1; else x = -2; 49 if (stats.f_fstr[fstr_len + 2] != ' ') x = -3; else x = -4; 50 return x; 51} 52 53int main(void) 54{ 55 /* Uninitialised, but we know px[0] is 0x0. */ 56 long *px = malloc(sizeof(long)); 57 x0 = px[0]; 58 59 /* SYS_fstatat64 67 */ 60 GO(SYS_fstatat64, "4s 2m"); 61 SY(SYS_fstatat64, x0 - 1, x0 + 1, x0, x0); FAILx(EBADF); 62 63 /* SYS_openat64 69 */ 64 sys_openat64(); 65 sys_openat642(); 66 67 /* SYS_lwp_private 166 */ 68 GO(SYS_lwp_private, "3s 1m"); 69 SY(SYS_lwp_private, x0 + _LWP_GETPRIVATE, x0 + _LWP_GSBASE, x0); FAIL; 70 71 /* SYS_llseek 175 */ 72 GO(SYS_llseek, "4s 0m"); 73 SY(SYS_llseek, x0 - 1, x0, x0, x0); FAILx(EBADF); 74 75 /* SYS_getdents64 213 */ 76 GO(SYS_getdents64, "3s 1m"); 77 SY(SYS_getdents64, x0, x0, x0 + 1); FAIL; 78 79 /* SYS_mmap64 214 */ 80 GO(SYS_mmap64, "7s 0m"); 81 SY(SYS_mmap64, x0, x0, x0, x0, x0, x0, x0); FAILx(EINVAL); 82 83 /* SYS_stat64 215 */ 84 /* Tested in x86-solaris/scalar_obsolete.c. */ 85 86 /* SYS_lstat64 216 */ 87 /* Tested in x86-solaris/scalar_obsolete.c. */ 88 89 /* SYS_fstat64 217 */ 90 /* Tested in x86-solaris/scalar_obsolete.c. */ 91 92 /* SYS_statvfs64 218 */ 93 sys_statvfs64(); 94 sys_statvfs642(); 95 96 /* SYS_fstatvfs64 219 */ 97 GO(SYS_fstatvfs64, "2s 1m"); 98 SY(SYS_fstatvfs64, x0 - 1, x0 + 1); FAILx(EBADF); 99 100 /* SYS_setrlimit64 220 */ 101 GO(SYS_setrlimit64, "2s 1m"); 102 SY(SYS_setrlimit64, x0, x0); FAIL; 103 104 /* SYS_getrlimit64 221 */ 105 GO(SYS_getrlimit64, "2s 1m"); 106 SY(SYS_getrlimit64, x0, x0); FAIL; 107 108 /* SYS_pread64 222 */ 109 GO(SYS_pread64, "5s 1m"); 110 SY(SYS_pread64, x0 - 1, x0, x0 + 1, x0, x0); FAILx(EBADF); 111 112 /* SYS_pwrite64 223 */ 113 GO(SYS_pwrite64, "5s 1m"); 114 SY(SYS_pwrite64, x0 - 1, x0, x0 + 1, x0, x0); FAILx(EBADF); 115 116 /* SYS_open64 225 */ 117 /* Tested in x86-solaris/scalar_obsolete.c. */ 118 119 return 0; 120} 121 122