From 2817fe445d768199fb36d819f8ed336feb74afa4 Mon Sep 17 00:00:00 2001 From: Devon Schwartz Date: Wed, 1 May 2024 15:27:29 -0500 Subject: [PATCH] Combine last 3 commits into one commit that changes the macros Changed the strcmp in lxcfs_read() to macros Signed-off-by: Devon Schwartz Fixed reads so that they have proper parameters Signed-off-by: Devon Schwartz Fixed semicolon and variable instantiation Signed-off-by: Devon Schwartz --- src/lxcfs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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; }