[lxc-devel] [lxcfs/master] 2016 08 21/bugfixes

brauner on Github lxc-bot at linuxcontainers.org
Sun Aug 21 12:06:34 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 314 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160821/9cfdaa54/attachment.bin>
-------------- next part --------------
From 28ca60337f3d4c233d3ade75a1d48e8739665c2c Mon Sep 17 00:00:00 2001
From: Christian Brauner <cbrauner at suse.de>
Date: Sun, 21 Aug 2016 00:02:32 +0200
Subject: [PATCH 1/4] bindings: enable acces to /var/lib/lxcfs/cgroup

Signed-off-by: Christian Brauner <cbrauner at suse.de>
---
 bindings.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/bindings.c b/bindings.c
index 1fa1027..26ba60d 100644
--- a/bindings.c
+++ b/bindings.c
@@ -1909,11 +1909,17 @@ int cg_open(const char *path, struct fuse_file_info *fi)
 
 int cg_access(const char *path, int mode)
 {
+	int ret;
 	const char *cgroup;
-	char *last = NULL, *path1, *path2, * cgdir = NULL, *controller;
+	char *path1, *path2, *controller;
+	char *last = NULL, *cgdir = NULL;
 	struct cgfs_files *k = NULL;
 	struct fuse_context *fc = fuse_get_context();
-	int ret;
+
+	if (strcmp(path, "/cgroup") == 0) {
+		ret = 0;
+		goto out;
+	}
 
 	if (!fc)
 		return -EIO;

From 52c0b013eb7e2764848c10d511e251efcb3b0bda Mon Sep 17 00:00:00 2001
From: Christian Brauner <cbrauner at suse.de>
Date: Sun, 21 Aug 2016 00:11:13 +0200
Subject: [PATCH 2/4] bindings: allow access to /var/lib/lxcfs/proc

Signed-off-by: Christian Brauner <cbrauner at suse.de>
---
 bindings.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bindings.c b/bindings.c
index 26ba60d..a09aee4 100644
--- a/bindings.c
+++ b/bindings.c
@@ -4071,8 +4071,8 @@ int proc_open(const char *path, struct fuse_file_info *fi)
 int proc_access(const char *path, int mask)
 {
 	/* these are all read-only */
-	if ((mask & ~R_OK) != 0)
-		return -EACCES;
+	if (access(path, mask) < 0)
+		return -errno;
 	return 0;
 }
 

From 8eb018b5567422d53d03eba371bf38530fa476ff Mon Sep 17 00:00:00 2001
From: Christian Brauner <cbrauner at suse.de>
Date: Sun, 21 Aug 2016 00:22:38 +0200
Subject: [PATCH 3/4] bindings: grant access to /var/lib/lxcfs

Signed-off-by: Christian Brauner <cbrauner at suse.de>
---
 lxcfs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lxcfs.c b/lxcfs.c
index 47afe13..959f212 100644
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -489,6 +489,10 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, of
 static int lxcfs_access(const char *path, int mode)
 {
 	int ret;
+
+	if (strcmp(path, "/") == 0)
+		return 0;
+
 	if (strncmp(path, "/cgroup", 7) == 0) {
 		up_users();
 		ret = do_cg_access(path, mode);

From e475bec941f80029fa4bcd9a6c321237fc4061fd Mon Sep 17 00:00:00 2001
From: Christian Brauner <cbrauner at suse.de>
Date: Sun, 21 Aug 2016 13:53:27 +0200
Subject: [PATCH 4/4] lxcfs, bindings: show "." and ".." dir entries

Signed-off-by: Christian Brauner <cbrauner at suse.de>
---
 bindings.c | 17 +++++++++++------
 lxcfs.c    |  6 ++++--
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/bindings.c b/bindings.c
index a09aee4..295e70a 100644
--- a/bindings.c
+++ b/bindings.c
@@ -1742,6 +1742,9 @@ int cg_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset
 	struct fuse_context *fc = fuse_get_context();
 	char **clist = NULL;
 
+	if (filler(buf, ".", NULL, 0) != 0 || filler(buf, "..", NULL, 0) != 0)
+		return -EIO;
+
 	if (d->type != LXC_TYPE_CGDIR) {
 		fprintf(stderr, "Internal error: file cache info used in readdir\n");
 		return -EIO;
@@ -4019,12 +4022,14 @@ int proc_getattr(const char *path, struct stat *sb)
 int proc_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset,
 		struct fuse_file_info *fi)
 {
-	if (filler(buf, "cpuinfo", NULL, 0) != 0 ||
-				filler(buf, "meminfo", NULL, 0) != 0 ||
-				filler(buf, "stat", NULL, 0) != 0 ||
-				filler(buf, "uptime", NULL, 0) != 0 ||
-				filler(buf, "diskstats", NULL, 0) != 0 ||
-				filler(buf, "swaps", NULL, 0) != 0)
+	if (filler(buf, ".", NULL, 0) != 0 ||
+	    filler(buf, "..", NULL, 0) != 0 ||
+	    filler(buf, "cpuinfo", NULL, 0) != 0 ||
+	    filler(buf, "meminfo", NULL, 0) != 0 ||
+	    filler(buf, "stat", NULL, 0) != 0 ||
+	    filler(buf, "uptime", NULL, 0) != 0 ||
+	    filler(buf, "diskstats", NULL, 0) != 0 ||
+	    filler(buf, "swaps", NULL, 0) != 0)
 		return -EINVAL;
 	return 0;
 }
diff --git a/lxcfs.c b/lxcfs.c
index 959f212..b499d05 100644
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -466,8 +466,10 @@ static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, of
 {
 	int ret;
 	if (strcmp(path, "/") == 0) {
-		if (filler(buf, "proc", NULL, 0) != 0 ||
-				filler(buf, "cgroup", NULL, 0) != 0)
+		if (filler(buf, ".", NULL, 0) != 0 ||
+		    filler(buf, "..", NULL, 0) != 0 ||
+		    filler(buf, "proc", NULL, 0) != 0 ||
+		    filler(buf, "cgroup", NULL, 0) != 0)
 			return -EINVAL;
 		return 0;
 	}


More information about the lxc-devel mailing list