public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	Caleb Sander <[email protected]>,
	Muhammad Rizki <[email protected]>,
	Kanna Scarlet <[email protected]>,
	io-uring Mailing List <[email protected]>,
	Linux Kernel Mailing List <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH liburing v2 2/7] syscall: Add io_uring syscall functions
Date: Tue, 30 Aug 2022 07:56:38 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

From: Ammar Faizi <[email protected]>

We have:

  man 2 io_uring_setup;
  man 2 io_uring_enter;
  man 2 io_uring_register;

Those entries say that io_uring syscall functions are declared in
`<linux/io_uring.h>`. But they don't actually exist and never existed.
This is causing confusion for people who read the manpage. Let's just
implement them in liburing so they exist.

This also allows the user to invoke io_uring syscalls directly instead
of using the full liburing provided setup.

v2:
  - Use consistent argument types.
  - Separate syscall declarations in liburing.h with a blank line.
  - Remove unused include in syscall.c.

Link: https://github.com/axboe/liburing/pull/646#issuecomment-1229639532
Reviewed-by: Caleb Sander <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/Makefile           |  2 +-
 src/include/liburing.h | 12 ++++++++++++
 src/liburing.map       |  4 ++++
 src/syscall.c          | 29 +++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 src/syscall.c

diff --git a/src/Makefile b/src/Makefile
index dad379d..73a98ba 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -32,7 +32,7 @@ endif
 
 all: $(all_targets)
 
-liburing_srcs := setup.c queue.c register.c
+liburing_srcs := setup.c queue.c register.c syscall.c
 
 ifeq ($(CONFIG_NOLIBC),y)
 	liburing_srcs += nolibc.c
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 66c5095..6e86847 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -203,6 +203,18 @@ int io_uring_register_notifications(struct io_uring *ring, unsigned nr,
 				    struct io_uring_notification_slot *slots);
 int io_uring_unregister_notifications(struct io_uring *ring);
 
+/*
+ * io_uring syscalls.
+ */
+int io_uring_enter(unsigned int fd, unsigned int to_submit,
+		   unsigned int min_complete, unsigned int flags, sigset_t *sig);
+int io_uring_enter2(unsigned int fd, unsigned int to_submit,
+		    unsigned int min_complete, unsigned int flags,
+		    sigset_t *sig, size_t sz);
+int io_uring_setup(unsigned int entries, struct io_uring_params *p);
+int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
+		      unsigned int nr_args);
+
 /*
  * Helper for the peek/wait single cqe functions. Exported because of that,
  * but probably shouldn't be used directly in an application.
diff --git a/src/liburing.map b/src/liburing.map
index 7d8f143..8573dfc 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -62,4 +62,8 @@ LIBURING_2.3 {
 		io_uring_register_file_alloc_range;
 		io_uring_register_notifications;
 		io_uring_unregister_notifications;
+		io_uring_enter;
+		io_uring_enter2;
+		io_uring_setup;
+		io_uring_register;
 } LIBURING_2.2;
diff --git a/src/syscall.c b/src/syscall.c
new file mode 100644
index 0000000..2054d17
--- /dev/null
+++ b/src/syscall.c
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: MIT */
+
+#include "syscall.h"
+#include <liburing.h>
+
+int io_uring_enter(unsigned int fd, unsigned int to_submit,
+		   unsigned int min_complete, unsigned int flags, sigset_t *sig)
+{
+	return __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig);
+}
+
+int io_uring_enter2(unsigned int fd, unsigned int to_submit,
+		    unsigned int min_complete, unsigned int flags,
+		    sigset_t *sig, size_t sz)
+{
+	return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
+				     sz);
+}
+
+int io_uring_setup(unsigned int entries, struct io_uring_params *p)
+{
+	return __sys_io_uring_setup(entries, p);
+}
+
+int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
+		      unsigned int nr_args)
+{
+	return __sys_io_uring_register(fd, opcode, arg, nr_args);
+}
-- 
Ammar Faizi


  parent reply	other threads:[~2022-08-30  0:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30  0:56 [PATCH liburing v2 0/7] Export io_uring syscall functions Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 1/7] syscall: Make io_uring syscall arguments consistent Ammar Faizi
2022-08-30  0:56 ` Ammar Faizi [this message]
2022-08-30  0:56 ` [PATCH liburing v2 3/7] man: Clarify "man 2" entry for io_uring syscalls Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 4/7] man: Add `io_uring_enter2()` function signature Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 5/7] man: Alias `io_uring_enter2()` to `io_uring_enter()` Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 6/7] test/io_uring_{enter,setup,register}: Use the exported syscall functions Ammar Faizi
2022-08-30  0:56 ` [PATCH liburing v2 7/7] man/io_uring_enter.2: Fix typo "which is behaves" -> "which behaves" Ammar Faizi
2022-08-30 14:14 ` [PATCH liburing v2 0/7] Export io_uring syscall functions 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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [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