Skip to content

Commit

Permalink
Merge pull request #661 from mihalicyn/lxcfs_cgroup2_fix
Browse files Browse the repository at this point in the history
lxcfs: fix readdir for procfs subtree
  • Loading branch information
stgraber authored Oct 2, 2024
2 parents 68fa858 + 2594ae8 commit c303ae2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lxcfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
{
int ret;
enum lxcfs_virt_t type;

type = file_info_type(fi);

if (strcmp(path, "/") == 0) {
Expand All @@ -768,7 +768,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
return ret;
}

if (LXCFS_TYPE_PROC(type)) {
if (strcmp(path, "/proc") == 0) {
up_users();
ret = do_proc_readdir(path, buf, filler, offset, fi);
down_users();
Expand Down Expand Up @@ -883,7 +883,7 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
{
int ret;
enum lxcfs_virt_t type;

type = file_info_type(fi);

if (cgroup_is_enabled && LXCFS_TYPE_CGROUP(type)) {
Expand All @@ -908,7 +908,7 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
}

lxcfs_error("unknown file type: path=%s, type=%d, fi->fh=%" PRIu64,
path, type, fi->fh);
path, type, fi->fh);

return -EINVAL;
}
Expand All @@ -918,7 +918,7 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
{
int ret;
enum lxcfs_virt_t type;

type = file_info_type(fi);

if (cgroup_is_enabled && LXCFS_TYPE_CGROUP(type)) {
Expand Down
7 changes: 7 additions & 0 deletions tests/test_proc.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ fi
echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/${memory_limit_file}
echo 0 > ${cpupath}/lxcfs_test_proc/cpuset.cpus

# Test that readdir on /proc basically works
echo "==> Testing directory listing on /proc"
ls -l ${LXCFSDIR}/proc | grep uptime
ls -l ${LXCFSDIR}/proc | grep cpuinfo
ls -l ${LXCFSDIR}/proc | grep stat
ls -l ${LXCFSDIR}/proc | grep meminfo

# Test uptime
echo "==> Testing /proc/uptime"
grep -Eq "^0.[0-9]{2} 0.[0-9]{2}$" ${LXCFSDIR}/proc/uptime
Expand Down

0 comments on commit c303ae2

Please sign in to comment.