[PATCH 10/19] vircgroup: introduce virCgroupV2DeviceGetPerms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroupv2.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 839f19c1f6..30f8da22ac 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1967,6 +1967,32 @@ virCgroupV2DeviceRemoveProg(virCgroupPtr group)
 }
 
 
+static __u32
+virCgroupV2DeviceGetPerms(int perms,
+                          char type)
+{
+    __u32 ret = 0;
+
+    if (perms & VIR_CGROUP_DEVICE_MKNOD)
+        ret |= BPF_DEVCG_ACC_MKNOD << 16;
+
+    if (perms & VIR_CGROUP_DEVICE_READ)
+        ret |= BPF_DEVCG_ACC_READ << 16;
+
+    if (perms & VIR_CGROUP_DEVICE_WRITE)
+        ret |= BPF_DEVCG_ACC_WRITE << 16;
+
+    if (type == 'b')
+        ret |= BPF_DEVCG_DEV_BLOCK;
+    else if (type == 'c')
+        ret |= BPF_DEVCG_DEV_CHAR;
+    else
+        ret |= BPF_DEVCG_DEV_BLOCK | BPF_DEVCG_DEV_CHAR;
+
+    return ret;
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux