diff --git a/src/lxcfs.c b/src/lxcfs.c index 9fb19cfd..4d55a908 100644 --- a/src/lxcfs.c +++ b/src/lxcfs.c @@ -876,28 +876,34 @@ static int lxcfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int ret; + enum lxcfs_virt_t type; + + type = file_info_type(fi); - if (cgroup_is_enabled && strncmp(path, "/cgroup", 7) == 0) { + if (LXCFS_TYPE_CGROUP(type)) { up_users(); ret = do_cg_read(path, buf, size, offset, fi); down_users(); return ret; } - if (strncmp(path, "/proc", 5) == 0) { + if (LXCFS_TYPE_PROC(type)) { up_users(); ret = do_proc_read(path, buf, size, offset, fi); down_users(); return ret; } - if (strncmp(path, "/sys", 4) == 0) { + if (LXCFS_TYPE_SYS(type)) { up_users(); ret = do_sys_read(path, buf, size, offset, fi); down_users(); return ret; } + lxcfs_error("unknown file type: path=%s, type=%d, fi->fh=%" PRIu64, + path, type, fi->fh); + return -EINVAL; }