[Devel] [PATCH RH9 3/7] ve/sysfs: generic sysfs_set_def_perms() helper introduced
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Tue Oct 5 15:55:49 MSK 2021
From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Can be used to set default visibility permissions for sysfs entries.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
(cherry picked from vz8 commit a394be4ae816d06c53c5085b7fbca4891f18b3d1)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
fs/sysfs/ve.c | 11 +++++++++++
include/linux/sysfs-ve.h | 20 ++++++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100644 include/linux/sysfs-ve.h
diff --git a/fs/sysfs/ve.c b/fs/sysfs/ve.c
index 4b1f5d54f14d..0dcbd479361b 100644
--- a/fs/sysfs/ve.c
+++ b/fs/sysfs/ve.c
@@ -15,6 +15,17 @@ struct kmapset_set sysfs_ve_perms_set;
static DEFINE_MUTEX(sysfs_perms_mutex);
+int sysfs_set_def_perms(char *path, int mask)
+{
+ int ret;
+
+ mutex_lock(&sysfs_perms_mutex);
+ ret = kernfs_perms_set(path, get_ve0(), mask, sysfs_root_kn, NULL);
+ mutex_unlock(&sysfs_perms_mutex);
+
+ return ret;
+}
+
void sysfs_set_ve_perms(struct dentry *root)
{
kernfs_set_ve_perms(root, offsetof(struct ve_struct,
diff --git a/include/linux/sysfs-ve.h b/include/linux/sysfs-ve.h
new file mode 100644
index 000000000000..95e176f6ae80
--- /dev/null
+++ b/include/linux/sysfs-ve.h
@@ -0,0 +1,20 @@
+/*
+ * include/linux/sysfs-ve.h
+ *
+ * Copyright (c) 2018-2021 Virtuozzo International GmbH. All rights reserved.
+ *
+ */
+
+#ifndef _SYSFS_VE_H_
+#define _SYSFS_VE_H_
+
+#ifdef CONFIG_VE
+int sysfs_set_def_perms(char *path, int mask);
+#else
+static inline int sysfs_set_def_perms(char *path, int mask)
+{
+ return 0;
+}
+#endif
+
+#endif
--
2.31.1
More information about the Devel
mailing list