]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
empty cgroup dir if set unified_cgroup_hierarchy=1
authorGuohao Wang <guohao.wang@shopee.com>
Sun, 5 Dec 2021 08:45:00 +0000 (16:45 +0800)
committerGuohao Wang <wangguohao.2009@gmail.com>
Tue, 7 Dec 2021 01:55:21 +0000 (09:55 +0800)
Signed-off-by: Guohao Wang <wangguohao.2009@gmail.com>
src/cgroup_fuse.c

index 5c22fd15d5c7f45cfdee3bc02f7cde8ae0c5e183..ee382dfeb30bb4dd822812136608eb02fd4ee406 100644 (file)
@@ -517,7 +517,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb)
        if (!liblxcfs_functional())
                return -EIO;
 
-       if (!fc || !cgroup_ops || pure_unified_layout(cgroup_ops))
+       if (!fc || !cgroup_ops)
                return -EIO;
 
        memset(sb, 0, sizeof(struct stat));
@@ -529,7 +529,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb)
        sb->st_atim = sb->st_mtim = sb->st_ctim = now;
        sb->st_size = 0;
 
-       if (strcmp(path, "/cgroup") == 0) {
+       if (pure_unified_layout(cgroup_ops) || strcmp(path, "/cgroup") == 0) {
                sb->st_mode = S_IFDIR | 00755;
                sb->st_nlink = 2;
                return 0;
@@ -546,6 +546,7 @@ __lxcfs_fuse_ops int cg_getattr(const char *path, struct stat *sb)
                return 0;
        }
 
+
        get_cgdir_and_path(cgroup, &cgdir, &last);
 
        if (!last) {
@@ -1421,10 +1422,10 @@ __lxcfs_fuse_ops int cg_opendir(const char *path, struct fuse_file_info *fi)
        if (!liblxcfs_functional())
                return -EIO;
 
-       if (!fc || !cgroup_ops || pure_unified_layout(cgroup_ops))
+       if (!fc || !cgroup_ops)
                return -EIO;
 
-       if (strcmp(path, "/cgroup") == 0) {
+       if (pure_unified_layout(cgroup_ops) || strcmp(path, "/cgroup") == 0) {
                cgroup = NULL;
                controller = NULL;
        } else {
@@ -1950,9 +1951,14 @@ __lxcfs_fuse_ops int cg_readdir(const char *path, void *buf,
        if (!liblxcfs_functional())
                return -EIO;
 
-       if (!fc || !cgroup_ops || pure_unified_layout(cgroup_ops))
+       if (!fc || !cgroup_ops)
                return -EIO;
 
+       if (pure_unified_layout(cgroup_ops)) {
+               ret = 0;
+               goto out;
+       }
+
        if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || DIR_FILLER(filler, buf, "..", NULL, 0) != 0)
                return -EIO;