Skip to content

Commit

Permalink
Merge pull request #506 from Sn0rt/empty-cgroup-if-set-unified_cgroup…
Browse files Browse the repository at this point in the history
…_hierarchy=1

empty cgroup dir if set unified_cgroup_hierarchy=1
  • Loading branch information
Christian Brauner authored Dec 7, 2021
2 parents f88df4b + bcde492 commit 0cbe135
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/cgroup_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 0cbe135

Please sign in to comment.