aboutsummaryrefslogtreecommitdiffstats
path: root/0001-readfile-implement-readfile-syscall.patch
diff options
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-10 10:01:34 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-10 10:01:34 +0200
commit0ce7a6b8527fbbc84add286a0efc73803a77bcab (patch)
tree5767d1d4b878367814c962d0f2ab93121a7c54a0 /0001-readfile-implement-readfile-syscall.patch
parenteace8bb509d05bd888a3718fd6b8ecbc40ddd373 (diff)
downloadpatches-0ce7a6b8527fbbc84add286a0efc73803a77bcab.tar.gz
fix up patches that have been merged
Diffstat (limited to '0001-readfile-implement-readfile-syscall.patch')
-rw-r--r--0001-readfile-implement-readfile-syscall.patch135
1 files changed, 0 insertions, 135 deletions
diff --git a/0001-readfile-implement-readfile-syscall.patch b/0001-readfile-implement-readfile-syscall.patch
deleted file mode 100644
index 1fe832ed0ab1b1..00000000000000
--- a/0001-readfile-implement-readfile-syscall.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-From 5bb274ae162250fad4f4f441a4c75c47ebede90d Mon Sep 17 00:00:00 2001
-From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Date: Tue, 3 Mar 2020 15:05:49 +0100
-Subject: [PATCH 1/2] readfile: implement readfile syscall
-
-It's a tiny syscall, meant to allow a user to do a single "open this
-file, read into this buffer, and close the file" all in a single shot.
-
-Should be good for reading "tiny" files like sysfs, procfs, and other
-"small" files.
-
-There is no restarting the syscall, am trying to keep it simple. At
-least for now.
-
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----
- arch/x86/entry/syscalls/syscall_32.tbl | 1 +
- arch/x86/entry/syscalls/syscall_64.tbl | 1 +
- fs/open.c | 50 ++++++++++++++++++++++++++
- include/linux/syscalls.h | 2 ++
- include/uapi/asm-generic/unistd.h | 4 ++-
- 5 files changed, 57 insertions(+), 1 deletion(-)
-
-diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
-index 54581ac671b4..a10438d5e5ec 100644
---- a/arch/x86/entry/syscalls/syscall_32.tbl
-+++ b/arch/x86/entry/syscalls/syscall_32.tbl
-@@ -442,3 +442,4 @@
- 435 i386 clone3 sys_clone3
- 437 i386 openat2 sys_openat2
- 438 i386 pidfd_getfd sys_pidfd_getfd
-+439 i386 readfile sys_readfile
-diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
-index 37b844f839bc..ffcc8bed83fb 100644
---- a/arch/x86/entry/syscalls/syscall_64.tbl
-+++ b/arch/x86/entry/syscalls/syscall_64.tbl
-@@ -359,6 +359,7 @@
- 435 common clone3 sys_clone3
- 437 common openat2 sys_openat2
- 438 common pidfd_getfd sys_pidfd_getfd
-+439 common readfile sys_readfile
-
- #
- # x32-specific system call numbers start at 512 to avoid cache impact
-diff --git a/fs/open.c b/fs/open.c
-index 719b320ede52..94d1633c94bb 100644
---- a/fs/open.c
-+++ b/fs/open.c
-@@ -1339,3 +1339,53 @@ int stream_open(struct inode *inode, struct file *filp)
- }
-
- EXPORT_SYMBOL(stream_open);
-+
-+static struct file *readfile_open(int dfd, const char __user *filename,
-+ struct open_flags *op)
-+{
-+ struct filename *tmp;
-+ struct file *f;
-+
-+ tmp = getname(filename);
-+ if (IS_ERR(tmp))
-+ return (struct file *)tmp;
-+
-+ f = do_filp_open(dfd, tmp, op);
-+ if (!IS_ERR(f))
-+ fsnotify_open(f);
-+
-+ putname(tmp);
-+ return f;
-+}
-+
-+SYSCALL_DEFINE5(readfile, int, dfd, const char __user *, filename,
-+ char __user *, buffer, size_t, bufsize, int, flags)
-+{
-+ struct open_flags op;
-+ struct open_how how;
-+ struct file *file;
-+ loff_t pos = 0;
-+ int retval;
-+
-+ /* Mask off all O_ flags as we only want to read from the file */
-+ flags &= ~(VALID_OPEN_FLAGS);
-+ flags |= O_RDONLY | O_LARGEFILE;
-+
-+ how = build_open_how(flags, 0000);
-+ retval = build_open_flags(&how, &op);
-+ if (retval)
-+ return retval;
-+
-+ file = readfile_open(dfd, filename, &op);
-+ if (IS_ERR(file))
-+ return PTR_ERR(file);
-+
-+// retval = ksys_read(fd, buffer, bufsize);
-+// __close_fd(current->files, fd);
-+
-+ retval = kernel_read(file, buffer, bufsize, &pos);
-+
-+ filp_close(file, NULL);
-+
-+ return retval;
-+}
-diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
-index 1815065d52f3..3a636a913437 100644
---- a/include/linux/syscalls.h
-+++ b/include/linux/syscalls.h
-@@ -1003,6 +1003,8 @@ asmlinkage long sys_pidfd_send_signal(int pidfd, int sig,
- siginfo_t __user *info,
- unsigned int flags);
- asmlinkage long sys_pidfd_getfd(int pidfd, int fd, unsigned int flags);
-+asmlinkage long sys_readfile(int dfd, const char __user *filename,
-+ char __user *buffer, size_t bufsize, int flags);
-
- /*
- * Architecture-specific system calls
-diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
-index 3a3201e4618e..31f84500915d 100644
---- a/include/uapi/asm-generic/unistd.h
-+++ b/include/uapi/asm-generic/unistd.h
-@@ -855,9 +855,11 @@ __SYSCALL(__NR_clone3, sys_clone3)
- __SYSCALL(__NR_openat2, sys_openat2)
- #define __NR_pidfd_getfd 438
- __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd)
-+#define __NR_readfile 439
-+__SYSCALL(__NR_readfile, sys_readfile)
-
- #undef __NR_syscalls
--#define __NR_syscalls 439
-+#define __NR_syscalls 440
-
- /*
- * 32 bit systems traditionally used different
---
-2.26.2
-