Skip to content

Commit c327e2f

Browse files
committed
fixup! [LibOS] Add support for timerfd system calls
Signed-off-by: Kailun Qin <[email protected]>
1 parent ebeb395 commit c327e2f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

libos/src/sys/libos_timerfd.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@ long libos_syscall_timerfd_settime(int fd, int flags, const struct __kernel_itim
162162
if (!hdl)
163163
return -EBADF;
164164

165+
if (hdl->type != TYPE_TIMERFD) {
166+
ret = -EINVAL;
167+
goto out;
168+
}
169+
165170
if (hdl->info.timerfd.broken_in_child) {
166171
log_warning("Child process tried to access timerfd created by parent process. This is "
167172
"disallowed in Gramine.");
168173
return -EIO;
169174
}
170175

171-
if (hdl->type != TYPE_TIMERFD) {
172-
ret = -EINVAL;
173-
goto out;
174-
}
175-
176176
if (!is_user_memory_readable(value, sizeof(*value))) {
177177
ret = -EFAULT;
178178
goto out;
@@ -253,17 +253,17 @@ long libos_syscall_timerfd_gettime(int fd, struct __kernel_itimerspec* value) {
253253
if (!hdl)
254254
return -EBADF;
255255

256+
if (hdl->type != TYPE_TIMERFD) {
257+
ret = -EINVAL;
258+
goto out;
259+
}
260+
256261
if (hdl->info.timerfd.broken_in_child) {
257262
log_warning("Child process tried to access timerfd created by parent process. This is "
258263
"disallowed in Gramine.");
259264
return -EIO;
260265
}
261266

262-
if (hdl->type != TYPE_TIMERFD) {
263-
ret = -EINVAL;
264-
goto out;
265-
}
266-
267267
if (!is_user_memory_writable(value, sizeof(*value))) {
268268
ret = -EFAULT;
269269
goto out;

libos/test/regression/timerfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void test_epoll_modes(int fd) {
210210
errx(1, "epoll: unexpected number of fds (expected 1, got %u)", nfds);
211211

212212
/* waiting for another event without reading the expiration count: here, even though the timer
213-
* expired at least one, there is no event reported because we're in edge-triggered mode (which
213+
* expired at least once, there is no event reported because we're in edge-triggered mode (which
214214
* does not "reset" the event since there was no read) */
215215
nfds = CHECK(epoll_wait(epfd, events, 1, /*timeout=*/PERIODIC_INTERVAL * 1000 * 2));
216216
if (nfds != 0)

0 commit comments

Comments
 (0)