/* 282 */ SyscallDesc("signalfd", unimplementedFunc),
/* 283 */ SyscallDesc("timerfd_create", unimplementedFunc),
/* 284 */ SyscallDesc("eventfd", unimplementedFunc),
- /* 285 */ SyscallDesc("fallocate", unimplementedFunc),
+ /* 285 */ SyscallDesc("fallocate", fallocateFunc),
/* 286 */ SyscallDesc("timerfd_settime", unimplementedFunc),
/* 287 */ SyscallDesc("timerfd_gettime", unimplementedFunc),
/* 288 */ SyscallDesc("accept4", unimplementedFunc),
}
}
+SyscallReturn
+fallocateFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+ ThreadContext *tc)
+{
+ int index = 0;
+ int tgt_fd = process->getSyscallArg(tc, index);
+ int mode = process->getSyscallArg(tc, index);
+ off_t offset = process->getSyscallArg(tc, index);
+ off_t len = process->getSyscallArg(tc, index);
+
+ int sim_fd = process->getSimFD(tgt_fd);
+ if (sim_fd < 0)
+ return -EBADF;
+
+ int result = fallocate(sim_fd, mode, offset, len);
+ if (result < 0)
+ return -errno;
+
+ return 0;
+}
+
SyscallReturn
accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc,
int index)
SyscallReturn ignoreFunc(SyscallDesc *desc, int num,
LiveProcess *p, ThreadContext *tc);
+// Target fallocateFunc() handler.
+SyscallReturn fallocateFunc(SyscallDesc *desc, int num,
+ LiveProcess *p, ThreadContext *tc);
+
/// Target exit() handler: terminate current context.
SyscallReturn exitFunc(SyscallDesc *desc, int num,
LiveProcess *p, ThreadContext *tc);