Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxcfs: fix readdir for procfs subtree #661

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading