public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] src/syscall: Add `close` syscall wrapper
@ 2021-10-04  1:35 Ammar Faizi
  2021-10-04  1:37 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Ammar Faizi @ 2021-10-04  1:35 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring Mailing List, Ammar Faizi

In commit 0c210dbae26a80ee82dbc7430828ab6fd7012548 ("Wrap all syscalls
in a kernel style return value"), we forgot to add a syscall wrapper
for `close()`. Add it.

Fixes: cccf0fa1762aac3f14323fbfc5cef2c99a03efe4 ("Wrap all syscalls in a kernel style return value")
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/setup.c   | 4 ++--
 src/syscall.h | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/setup.c b/src/setup.c
index bdbf97c..4f006de 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -145,7 +145,7 @@ int io_uring_queue_init_params(unsigned entries, struct io_uring *ring,
 
 	ret = io_uring_queue_mmap(fd, p, ring);
 	if (ret) {
-		close(fd);
+		uring_close(fd);
 		return ret;
 	}
 
@@ -174,7 +174,7 @@ void io_uring_queue_exit(struct io_uring *ring)
 
 	uring_munmap(sq->sqes, *sq->kring_entries * sizeof(struct io_uring_sqe));
 	io_uring_unmap_rings(sq, cq);
-	close(ring->ring_fd);
+	uring_close(ring->ring_fd);
 }
 
 struct io_uring_probe *io_uring_get_probe_ring(struct io_uring *ring)
diff --git a/src/syscall.h b/src/syscall.h
index a9dd280..9eff968 100644
--- a/src/syscall.h
+++ b/src/syscall.h
@@ -156,4 +156,12 @@ static inline int uring_setrlimit(int resource, const struct rlimit *rlim)
 	return (ret < 0) ? -errno : ret;
 }
 
+static inline int uring_close(int fd)
+{
+	int ret;
+
+	ret = close(fd);
+	return (ret < 0) ? -errno : ret;
+}
+
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-04  2:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-04  1:35 [PATCH liburing] src/syscall: Add `close` syscall wrapper Ammar Faizi
2021-10-04  1:37 ` Jens Axboe
2021-10-04  1:51   ` Ammar Faizi
2021-10-04  2:01     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox