static int sys_fcntl64_xlk64(const struct syscall_info* call) { const int syscallno = SYS_fcntl64; int fd = call->args[0]; int cmd = call->args[1]; struct flock64* lock = (struct flock64*)call->args[2]; void* ptr = prep_syscall(); struct flock64* lock2 = NULL; long ret; assert(syscallno == call->no); if (lock) { lock2 = ptr; ptr += sizeof(*lock2); } if (!start_commit_buffered_syscall(syscallno, ptr, WONT_BLOCK)) { return traced_raw_syscall(call); } if (lock2) { local_memcpy(lock2, lock, sizeof(*lock2)); } ret = untraced_syscall3(syscallno, fd, cmd, lock2); if (lock2) { local_memcpy(lock, lock2, sizeof(*lock)); } return commit_raw_syscall(syscallno, ptr, ret); }
static int sys_fcntl64_own_ex(const struct syscall_info* call) { const int syscallno = SYS_fcntl64; int fd = call->args[0]; int cmd = call->args[1]; struct f_owner_ex* owner = (struct f_owner_ex*)call->args[2]; /* The OWN_EX fcntl's aren't may-block. */ void* ptr = prep_syscall(); struct f_owner_ex* owner2 = NULL; long ret; assert(syscallno == call->no); if (owner) { owner2 = ptr; ptr += sizeof(*owner2); } if (!start_commit_buffered_syscall(syscallno, ptr, WONT_BLOCK)) { return traced_raw_syscall(call); } if (owner2) { local_memcpy(owner2, owner, sizeof(*owner2)); } ret = untraced_syscall3(syscallno, fd, cmd, owner2); if (owner2) { local_memcpy(owner, owner2, sizeof(*owner)); } return commit_raw_syscall(syscallno, ptr, ret); }
static long sys_xstat64(const struct syscall_info* call) { const int syscallno = call->no; /* NB: this arg may be a string or an fd, but for the purposes * of this generic helper we don't care. */ long what = call->args[0]; struct stat64* buf = (struct stat64*)call->args[1]; /* Like open(), not arming the desched event because it's not * needed for correctness, and there are no data to suggest * whether it's a good idea perf-wise. */ void* ptr = prep_syscall(); struct stat64* buf2 = NULL; long ret; if (buf) { buf2 = ptr; ptr += sizeof(*buf2); } if (!start_commit_buffered_syscall(syscallno, ptr, WONT_BLOCK)) { return traced_raw_syscall(call); } ret = untraced_syscall2(syscallno, what, buf2); if (buf2) { local_memcpy(buf, buf2, sizeof(*buf)); } return commit_raw_syscall(syscallno, ptr, ret); }
static long sys_recv(const struct syscall_info* call) { const int syscallno = SYS_socketcall; long* args = (long*)call->args[1]; int sockfd = args[0]; void* buf = (void*)args[1]; size_t len = args[2]; unsigned int flags = args[3]; void* ptr = prep_syscall(); void* buf2 = NULL; long ret; assert(syscallno == call->no); if (buf && len > 0) { buf2 = ptr; ptr += len; } if (!start_commit_buffered_syscall(SYS_socketcall, ptr, MAY_BLOCK)) { return traced_raw_syscall(call); } ret = untraced_socketcall4(SYS_RECV, sockfd, buf2, len, flags); if (buf2 && ret > 0) { local_memcpy(buf, buf2, ret); } return commit_raw_syscall(SYS_socketcall, ptr, ret); }
static long sys_readlink(const struct syscall_info* call) { const int syscallno = SYS_readlink; const char* path = (const char*)call->args[0]; char* buf = (char*)call->args[1]; int bufsiz = call->args[2]; void* ptr = prep_syscall(); char* buf2 = NULL; long ret; assert(syscallno == call->no); if (buf && bufsiz > 0) { buf2 = ptr; ptr += bufsiz; } if (!start_commit_buffered_syscall(syscallno, ptr, WONT_BLOCK)) { return traced_raw_syscall(call); } ret = untraced_syscall3(syscallno, path, buf2, bufsiz); if (buf2 && ret > 0) { local_memcpy(buf, buf2, ret); } return commit_raw_syscall(syscallno, ptr, ret); }
static long sys_read(const struct syscall_info* call) { const int syscallno = SYS_read; int fd = call->args[0]; void* buf = (void*)call->args[1]; size_t count = call->args[2]; void* ptr = prep_syscall(); void* buf2 = NULL; long ret; assert(syscallno == call->no); if (buf && count > 0) { buf2 = ptr; ptr += count; } if (!start_commit_buffered_syscall(syscallno, ptr, MAY_BLOCK)) { return traced_raw_syscall(call); } ret = untraced_syscall3(syscallno, fd, buf2, count); if (buf2 && ret > 0) { local_memcpy(buf, buf2, ret); } return commit_raw_syscall(syscallno, ptr, ret); }
static long sys_clock_gettime(const struct syscall_info* call) { const int syscallno = SYS_clock_gettime; clockid_t clk_id = (clockid_t)call->args[0]; struct timespec* tp = (struct timespec*)call->args[1]; void* ptr = prep_syscall(); struct timespec *tp2 = NULL; long ret; assert(syscallno == call->no); if (tp) { tp2 = ptr; ptr += sizeof(*tp2); } if (!start_commit_buffered_syscall(syscallno, ptr, WONT_BLOCK)) { return traced_raw_syscall(call); } ret = untraced_syscall2(syscallno, clk_id, tp2); if (tp) { local_memcpy(tp, tp2, sizeof(*tp)); } return commit_raw_syscall(syscallno, ptr, ret); }
static long sys_poll(const struct syscall_info* call) { const int syscallno = SYS_poll; struct pollfd* fds = (struct pollfd*)call->args[0]; unsigned int nfds = call->args[1]; int timeout = call->args[2]; void* ptr = prep_syscall(); struct pollfd* fds2 = NULL; long ret; assert(syscallno == call->no); if (fds && nfds > 0) { fds2 = ptr; ptr += nfds * sizeof(*fds2); } if (!start_commit_buffered_syscall(syscallno, ptr, MAY_BLOCK)) { return traced_raw_syscall(call); } if (fds2) { local_memcpy(fds2, fds, nfds * sizeof(*fds2)); } ret = untraced_syscall3(syscallno, fds2, nfds, timeout); if (fds2) { /* NB: even when poll returns 0 indicating no pending * fds, it still sets each .revent outparam to 0. * (Reasonably.) So we always need to copy on return * value >= 0. poll() may or may not copy on errors, * but we assume those are rare enough not to merit a * special case here. */ local_memcpy(fds, fds2, nfds * sizeof(*fds)); } return commit_raw_syscall(syscallno, ptr, ret); }
static long sys_gettimeofday(const struct syscall_info* call) { const int syscallno = SYS_gettimeofday; struct timeval* tp = (struct timeval*)call->args[0]; struct timezone* tzp = (struct timezone*)call->args[1]; /* XXX it seems odd that clock_gettime() is spec'd to be * async-signal-safe while gettimeofday() isn't, but that's * what the docs say! */ void *ptr = prep_syscall(); struct timeval *tp2 = NULL; struct timezone *tzp2 = NULL; long ret; assert(syscallno == call->no); if (tp) { tp2 = ptr; ptr += sizeof(*tp2); } if (tzp) { tzp2 = ptr; ptr += sizeof(*tzp2); } if (!start_commit_buffered_syscall(syscallno, ptr, WONT_BLOCK)) { return traced_raw_syscall(call); } ret = untraced_syscall2(syscallno, tp2, tzp2); if (tp) { local_memcpy(tp, tp2, sizeof(*tp)); } if (tzp) { local_memcpy(tzp, tzp2, sizeof(*tzp)); } return commit_raw_syscall(syscallno, ptr, ret); }
void BF_set_key (int len, unsigned char *data) #endif { int i; BF_LONG *p, ri, in[2]; unsigned char *d, *end; local_memcpy (key_P, bf_init_P, BF_ROUNDS + 2); local_memcpy (key_S, bf_init_S, 4 * 256); p = key_P; if (len > ((BF_ROUNDS + 2) * 4)) len = (BF_ROUNDS + 2) * 4; d = data; end = &(data[len]); for (i = 0; i < (BF_ROUNDS + 2); i++) { ri = *(d++); if (d >= end) d = data; ri <<= 8; ri |= *(d++); if (d >= end) d = data; ri <<= 8; ri |= *(d++); if (d >= end) d = data; ri <<= 8; ri |= *(d++); if (d >= end) d = data; p[i] ^= ri; } in[0] = 0L; in[1] = 0L; for (i = 0; i < (BF_ROUNDS + 2); i += 2) { #ifdef DWARV BF_encrypt (in, BF_ENCRYPT, key_P, key_S); #else BF_encrypt (in, BF_ENCRYPT); #endif p[i] = in[0]; p[i + 1] = in[1]; } p = key_S; for (i = 0; i < 4 * 256; i += 2) { #ifdef DWARV BF_encrypt (in, BF_ENCRYPT, key_P, key_S); #else BF_encrypt (in, BF_ENCRYPT); #endif p[i] = in[0]; p[i + 1] = in[1]; } }