Rizin
unix-like reverse engineering framework and cli tools
linux-syscalls.c File Reference
#include "linux-syscalls.h"
#include <unistd.h>
#include <signal.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <errno.h>

Go to the source code of this file.

Functions

int uv__sendmmsg (int fd, struct uv__mmsghdr *mmsg, unsigned int vlen)
 
int uv__recvmmsg (int fd, struct uv__mmsghdr *mmsg, unsigned int vlen)
 
ssize_t uv__preadv (int fd, const struct iovec *iov, int iovcnt, int64_t offset)
 
ssize_t uv__pwritev (int fd, const struct iovec *iov, int iovcnt, int64_t offset)
 
int uv__dup3 (int oldfd, int newfd, int flags)
 
ssize_t uv__fs_copy_file_range (int fd_in, ssize_t *off_in, int fd_out, ssize_t *off_out, size_t len, unsigned int flags)
 
int uv__statx (int dirfd, const char *path, int flags, unsigned int mask, struct uv__statx *statxbuf)
 
ssize_t uv__getrandom (void *buf, size_t buflen, unsigned flags)
 

Function Documentation

◆ uv__dup3()

int uv__dup3 ( int  oldfd,
int  newfd,
int  flags 
)

Definition at line 214 of file linux-syscalls.c.

214  {
215 #if defined(__NR_dup3)
216  return syscall(__NR_dup3, oldfd, newfd, flags);
217 #else
218  return errno = ENOSYS, -1;
219 #endif
220 }
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path oldfd
Definition: sflib.h:94
#define __NR_dup3
Definition: sfsysnr.h:326
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
const char * syscall
Definition: internal.h:270

References __NR_dup3, flags, oldfd, and syscall.

◆ uv__fs_copy_file_range()

ssize_t uv__fs_copy_file_range ( int  fd_in,
ssize_t off_in,
int  fd_out,
ssize_t off_out,
size_t  len,
unsigned int  flags 
)

Definition at line 224 of file linux-syscalls.c.

230 {
231 #ifdef __NR_copy_file_range
232  return syscall(__NR_copy_file_range,
233  fd_in,
234  off_in,
235  fd_out,
236  off_out,
237  len,
238  flags);
239 #else
240  return errno = ENOSYS, -1;
241 #endif
242 }
size_t len
Definition: 6502dis.c:15

References flags, len, and syscall.

Referenced by uv__fs_sendfile().

◆ uv__getrandom()

ssize_t uv__getrandom ( void *  buf,
size_t  buflen,
unsigned  flags 
)

Definition at line 261 of file linux-syscalls.c.

261  {
262 #if defined(__NR_getrandom)
263  return syscall(__NR_getrandom, buf, buflen, flags);
264 #else
265  return errno = ENOSYS, -1;
266 #endif
267 }
voidpf void * buf
Definition: ioapi.h:138
ut64 buflen
Definition: core.c:76

References buflen, flags, and syscall.

◆ uv__preadv()

ssize_t uv__preadv ( int  fd,
const struct iovec iov,
int  iovcnt,
int64_t  offset 
)

Definition at line 196 of file linux-syscalls.c.

196  {
197 #if defined(__NR_preadv)
198  return syscall(__NR_preadv, fd, iov, iovcnt, (long)offset, (long)(offset >> 32));
199 #else
200  return errno = ENOSYS, -1;
201 #endif
202 }
#define __NR_preadv
Definition: sfsysnr.h:641
voidpf uLong offset
Definition: ioapi.h:144
static uv_buf_t iov
Definition: main.c:15
static const z80_opcode fd[]
Definition: z80_tab.h:997

References __NR_preadv, fd, iov, and syscall.

Referenced by uv__fs_read().

◆ uv__pwritev()

ssize_t uv__pwritev ( int  fd,
const struct iovec iov,
int  iovcnt,
int64_t  offset 
)

Definition at line 205 of file linux-syscalls.c.

205  {
206 #if defined(__NR_pwritev)
207  return syscall(__NR_pwritev, fd, iov, iovcnt, (long)offset, (long)(offset >> 32));
208 #else
209  return errno = ENOSYS, -1;
210 #endif
211 }
#define __NR_pwritev
Definition: sfsysnr.h:644

References __NR_pwritev, fd, iov, and syscall.

Referenced by uv__fs_write().

◆ uv__recvmmsg()

int uv__recvmmsg ( int  fd,
struct uv__mmsghdr *  mmsg,
unsigned int  vlen 
)

Definition at line 170 of file linux-syscalls.c.

170  {
171 #if defined(__i386__)
172  unsigned long args[5];
173  int rc;
174 
175  args[0] = (unsigned long) fd;
176  args[1] = (unsigned long) mmsg;
177  args[2] = (unsigned long) vlen;
178  args[3] = /* flags */ 0;
179  args[4] = /* timeout */ 0;
180 
181  /* socketcall() raises EINVAL when SYS_RECVMMSG is not supported. */
182  rc = syscall(/* __NR_socketcall */ 102, 19 /* SYS_RECVMMSG */, args);
183  if (rc == -1)
184  if (errno == EINVAL)
185  errno = ENOSYS;
186 
187  return rc;
188 #elif defined(__NR_recvmmsg)
189  return syscall(__NR_recvmmsg, fd, mmsg, vlen, /* flags */ 0, /* timeout */ 0);
190 #else
191  return errno = ENOSYS, -1;
192 #endif
193 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags long
Definition: sflib.h:79
int args
Definition: mipsasm.c:18
#define EINVAL
Definition: sftypes.h:132

References args, EINVAL, fd, long, and syscall.

◆ uv__sendmmsg()

int uv__sendmmsg ( int  fd,
struct uv__mmsghdr *  mmsg,
unsigned int  vlen 
)

Definition at line 145 of file linux-syscalls.c.

145  {
146 #if defined(__i386__)
147  unsigned long args[4];
148  int rc;
149 
150  args[0] = (unsigned long) fd;
151  args[1] = (unsigned long) mmsg;
152  args[2] = (unsigned long) vlen;
153  args[3] = /* flags */ 0;
154 
155  /* socketcall() raises EINVAL when SYS_SENDMMSG is not supported. */
156  rc = syscall(/* __NR_socketcall */ 102, 20 /* SYS_SENDMMSG */, args);
157  if (rc == -1)
158  if (errno == EINVAL)
159  errno = ENOSYS;
160 
161  return rc;
162 #elif defined(__NR_sendmmsg)
163  return syscall(__NR_sendmmsg, fd, mmsg, vlen, /* flags */ 0);
164 #else
165  return errno = ENOSYS, -1;
166 #endif
167 }

References args, EINVAL, fd, long, and syscall.

◆ uv__statx()

int uv__statx ( int  dirfd,
const char *  path,
int  flags,
unsigned int  mask,
struct uv__statx statxbuf 
)

Definition at line 245 of file linux-syscalls.c.

249  {
250  /* __NR_statx make Android box killed by SIGSYS.
251  * That looks like a seccomp2 sandbox filter rejecting the system call.
252  */
253 #if defined(__NR_statx) && !defined(__ANDROID__)
254  return syscall(__NR_statx, dirfd, path, flags, mask, statxbuf);
255 #else
256  return errno = ENOSYS, -1;
257 #endif
258 }
#define mask()
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35

References flags, mask, path, and syscall.

Referenced by uv__fs_statx().