mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] configfs: Add CONFIGFS_ATTR_PERM helper
@ 2025-04-20 10:47 Richard Weinberger
  2025-04-20 10:47 ` [PATCH 2/2] nvmet: Restrict in-band config files to root Richard Weinberger
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Richard Weinberger @ 2025-04-20 10:47 UTC (permalink / raw)
  To: linux-nvme
  Cc: linux-kernel, a.hindborg, leitao, kch, sagi, hch, upstream+nvme,
	Richard Weinberger

This new helper allows creating rw files with custom
permissions.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 include/linux/configfs.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index c771e9d0d0b9..698520b1bfdb 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -120,15 +120,19 @@ struct configfs_attribute {
 	ssize_t (*store)(struct config_item *, const char *, size_t);
 };
 
-#define CONFIGFS_ATTR(_pfx, _name)			\
+#define CONFIGFS_ATTR_PERM(_pfx, _name, _perm)		\
 static struct configfs_attribute _pfx##attr_##_name = {	\
 	.ca_name	= __stringify(_name),		\
-	.ca_mode	= S_IRUGO | S_IWUSR,		\
+	.ca_mode	= _perm,			\
 	.ca_owner	= THIS_MODULE,			\
 	.show		= _pfx##_name##_show,		\
 	.store		= _pfx##_name##_store,		\
 }
 
+#define CONFIGFS_ATTR(_pfx, _name) CONFIGFS_ATTR_PERM(	\
+		_pfx, _name, S_IRUGO | S_IWUSR		\
+)
+
 #define CONFIGFS_ATTR_RO(_pfx, _name)			\
 static struct configfs_attribute _pfx##attr_##_name = {	\
 	.ca_name	= __stringify(_name),		\
-- 
2.48.1


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

end of thread, other threads:[~2025-04-25  6:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-20 10:47 [PATCH 1/2] configfs: Add CONFIGFS_ATTR_PERM helper Richard Weinberger
2025-04-20 10:47 ` [PATCH 2/2] nvmet: Restrict in-band config files to root Richard Weinberger
2025-04-22  6:32   ` Chaitanya Kulkarni
2025-04-22  6:36     ` Richard Weinberger
2025-04-22 11:53   ` Sagi Grimberg
2025-04-22  6:27 ` [PATCH 1/2] configfs: Add CONFIGFS_ATTR_PERM helper Chaitanya Kulkarni
2025-04-22 11:53 ` Sagi Grimberg
2025-04-25  6:27 ` Andreas Hindborg

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

all inboxes | Powered by JetHome®