]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
configfs: Add CONFIGFS_ATTR_PERM helper
authorRichard Weinberger <richard@nod.at>
Sun, 20 Apr 2025 10:47:25 +0000 (12:47 +0200)
committerAndreas Hindborg <a.hindborg@kernel.org>
Fri, 25 Apr 2025 09:44:35 +0000 (11:44 +0200)
This new helper allows creating rw files with custom
permissions.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Link: https://lore.kernel.org/r/20250420104726.2963750-1-richard@nod.at
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
include/linux/configfs.h

index c771e9d0d0b92eee3826d5df1782e0cd5935fea2..698520b1bfdbc3437fd467b82accd8eac1672bc0 100644 (file)
@@ -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),           \