From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: io-uring Mailing List <[email protected]>,
Ammar Faizi <[email protected]>
Subject: [PATCH liburing] src/syscall: Add `close` syscall wrapper
Date: Mon, 4 Oct 2021 08:35:10 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
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
next reply other threads:[~2021-10-04 1:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 1:35 Ammar Faizi [this message]
2021-10-04 1:37 ` [PATCH liburing] src/syscall: Add `close` syscall wrapper Jens Axboe
2021-10-04 1:51 ` Ammar Faizi
2021-10-04 2:01 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211004013510.428077-1-ammar.faizi@students.amikom.ac.id \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox