OBS-URL: https://build.opensuse.org/request/show/423993 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/lxcfs?expand=0&rev=6
114 lines
2.6 KiB
Diff
114 lines
2.6 KiB
Diff
From bc70ba9b492f1af79ce692471f3e300eaf4afe29 Mon Sep 17 00:00:00 2001
|
|
From: Christian Brauner <cbrauner@suse.de>
|
|
Date: Fri, 26 Aug 2016 10:32:32 +0200
|
|
Subject: [PATCH 19/24] bindings: improve returned errnos
|
|
|
|
Signed-off-by: Christian Brauner <cbrauner@suse.de>
|
|
---
|
|
bindings.c | 34 ++++++++++++++++++++--------------
|
|
1 file changed, 20 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/bindings.c b/bindings.c
|
|
index 8a5909a..aaba840 100644
|
|
--- a/bindings.c
|
|
+++ b/bindings.c
|
|
@@ -1541,12 +1541,17 @@ static const char *find_cgroup_in_path(const char *path)
|
|
{
|
|
const char *p1;
|
|
|
|
- if (strlen(path) < 9)
|
|
+ if (strlen(path) < 9) {
|
|
+ errno = EINVAL;
|
|
return NULL;
|
|
- p1 = strstr(path+8, "/");
|
|
- if (!p1)
|
|
+ }
|
|
+ p1 = strstr(path + 8, "/");
|
|
+ if (!p1) {
|
|
+ errno = EINVAL;
|
|
return NULL;
|
|
- return p1+1;
|
|
+ }
|
|
+ errno = 0;
|
|
+ return p1 + 1;
|
|
}
|
|
|
|
/*
|
|
@@ -1866,7 +1871,7 @@ int cg_open(const char *path, struct fuse_file_info *fi)
|
|
return -errno;
|
|
cgroup = find_cgroup_in_path(path);
|
|
if (!cgroup)
|
|
- return -EINVAL;
|
|
+ return -errno;
|
|
|
|
get_cgdir_and_path(cgroup, &cgdir, &last);
|
|
if (!last) {
|
|
@@ -2717,15 +2722,16 @@ int cg_chown(const char *path, uid_t uid, gid_t gid)
|
|
return -EIO;
|
|
|
|
if (strcmp(path, "/cgroup") == 0)
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
|
|
controller = pick_controller_from_path(fc, path);
|
|
if (!controller)
|
|
- return -errno;
|
|
+ return errno == ENOENT ? -EPERM : -errno;
|
|
+
|
|
cgroup = find_cgroup_in_path(path);
|
|
if (!cgroup)
|
|
/* this is just /cgroup/controller */
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
|
|
get_cgdir_and_path(cgroup, &cgdir, &last);
|
|
|
|
@@ -2782,15 +2788,16 @@ int cg_chmod(const char *path, mode_t mode)
|
|
return -EIO;
|
|
|
|
if (strcmp(path, "/cgroup") == 0)
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
|
|
controller = pick_controller_from_path(fc, path);
|
|
if (!controller)
|
|
- return -errno;
|
|
+ return errno == ENOENT ? -EPERM : -errno;
|
|
+
|
|
cgroup = find_cgroup_in_path(path);
|
|
if (!cgroup)
|
|
/* this is just /cgroup/controller */
|
|
- return -EINVAL;
|
|
+ return -EPERM;
|
|
|
|
get_cgdir_and_path(cgroup, &cgdir, &last);
|
|
|
|
@@ -2848,14 +2855,13 @@ int cg_mkdir(const char *path, mode_t mode)
|
|
if (!fc)
|
|
return -EIO;
|
|
|
|
-
|
|
controller = pick_controller_from_path(fc, path);
|
|
if (!controller)
|
|
return errno == ENOENT ? -EPERM : -errno;
|
|
|
|
cgroup = find_cgroup_in_path(path);
|
|
if (!cgroup)
|
|
- return -EINVAL;
|
|
+ return -errno;
|
|
|
|
get_cgdir_and_path(cgroup, &cgdir, &last);
|
|
if (!last)
|
|
@@ -2909,7 +2915,7 @@ int cg_rmdir(const char *path)
|
|
|
|
cgroup = find_cgroup_in_path(path);
|
|
if (!cgroup)
|
|
- return -EINVAL;
|
|
+ return -errno;
|
|
|
|
get_cgdir_and_path(cgroup, &cgdir, &last);
|
|
if (!last) {
|
|
--
|
|
2.9.3
|
|
|