From eae324ca644554d5ce363186bee820a088bb74ab Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Sun, 20 Apr 2025 12:47:25 +0200 Subject: [PATCH] configfs: Add CONFIGFS_ATTR_PERM helper This new helper allows creating rw files with custom permissions. Signed-off-by: Richard Weinberger Reviewed-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg Link: https://lore.kernel.org/r/20250420104726.2963750-1-richard@nod.at Signed-off-by: Andreas Hindborg --- 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 c771e9d0d0b92..698520b1bfdbc 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.47.2