Skip to content

Commit c303ae2

Browse files
authored
Merge pull request #661 from mihalicyn/lxcfs_cgroup2_fix
lxcfs: fix readdir for procfs subtree
2 parents 68fa858 + 2594ae8 commit c303ae2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/lxcfs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
747747
{
748748
int ret;
749749
enum lxcfs_virt_t type;
750-
750+
751751
type = file_info_type(fi);
752752

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

771-
if (LXCFS_TYPE_PROC(type)) {
771+
if (strcmp(path, "/proc") == 0) {
772772
up_users();
773773
ret = do_proc_readdir(path, buf, filler, offset, fi);
774774
down_users();
@@ -883,7 +883,7 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset,
883883
{
884884
int ret;
885885
enum lxcfs_virt_t type;
886-
886+
887887
type = file_info_type(fi);
888888

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

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

913913
return -EINVAL;
914914
}
@@ -918,7 +918,7 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
918918
{
919919
int ret;
920920
enum lxcfs_virt_t type;
921-
921+
922922
type = file_info_type(fi);
923923

924924
if (cgroup_is_enabled && LXCFS_TYPE_CGROUP(type)) {

tests/test_proc.in

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ fi
6565
echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/${memory_limit_file}
6666
echo 0 > ${cpupath}/lxcfs_test_proc/cpuset.cpus
6767

68+
# Test that readdir on /proc basically works
69+
echo "==> Testing directory listing on /proc"
70+
ls -l ${LXCFSDIR}/proc | grep uptime
71+
ls -l ${LXCFSDIR}/proc | grep cpuinfo
72+
ls -l ${LXCFSDIR}/proc | grep stat
73+
ls -l ${LXCFSDIR}/proc | grep meminfo
74+
6875
# Test uptime
6976
echo "==> Testing /proc/uptime"
7077
grep -Eq "^0.[0-9]{2} 0.[0-9]{2}$" ${LXCFSDIR}/proc/uptime

0 commit comments

Comments
 (0)