lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-4-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:12:23 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 003/437] fs: add helpers for defining read/write iterator helpers

To ease conversion for drivers, add helpers that allow a driver to simply
wrap their existing read/write file_operations hook and turn it into one
that is appropriate for ->read_iter() or ->write_iter().

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 include/linux/fs.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index fd862985a309..72de0b1d5647 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2141,6 +2141,22 @@ extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
 					struct file *dst_file, loff_t dst_pos,
 					loff_t len, unsigned int remap_flags);
 
+/*
+ * Drivers can use these to ease transition to using ->read_iter() instead
+ * of ->read(), and ->write_iter() instead of ->write(). Ideally these will
+ * go away one day.
+ */
+#define FOPS_READ_ITER_HELPER(name)					\
+static ssize_t name## _iter(struct kiocb *iocb, struct iov_iter *to)	\
+{									\
+	return vfs_read_iter(iocb, to, name);				\
+}
+#define FOPS_WRITE_ITER_HELPER(name)					\
+static ssize_t name## _iter(struct kiocb *iocb, struct iov_iter *from)	\
+{									\
+	return vfs_write_iter(iocb, from, name);			\
+}
+
 /**
  * enum freeze_holder - holder of the freeze
  * @FREEZE_HOLDER_KERNEL: kernel wants to freeze or thaw filesystem
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ