From: Richard Weinberger Date: Sun, 20 Apr 2025 10:47:25 +0000 (+0200) Subject: configfs: Add CONFIGFS_ATTR_PERM helper X-Git-Tag: v6.16-rc1~213^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eae324ca644554d5ce363186bee820a088bb74ab;p=thirdparty%2Fkernel%2Flinux.git 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 --- 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), \