Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
060aaa39
Unverified
Commit
060aaa39
authored
Feb 26, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: s/syerrno_set()/syserror_set()/g
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
6d829cd2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
46 deletions
+38
-46
af_unix.c
src/lxc/af_unix.c
+6
-6
cgfsng.c
src/lxc/cgroups/cgfsng.c
+10
-10
cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.c
+3
-3
commands.c
src/lxc/commands.c
+10
-10
confile.c
src/lxc/confile.c
+9
-9
log.h
src/lxc/log.h
+0
-8
No files found.
src/lxc/af_unix.c
View file @
060aaa39
...
...
@@ -228,14 +228,14 @@ again:
for
(
idx
=
0
;
idx
<
num_raw
;
idx
++
)
close
(
fds_raw
[
idx
]);
return
syserr
no
_set
(
-
EFBIG
,
"Received excessive number of file descriptors"
);
return
syserr
or
_set
(
-
EFBIG
,
"Received excessive number of file descriptors"
);
}
if
(
msg
.
msg_flags
&
MSG_CTRUNC
)
{
for
(
idx
=
0
;
idx
<
num_raw
;
idx
++
)
close
(
fds_raw
[
idx
]);
return
syserr
no
_set
(
-
EFBIG
,
"Control message was truncated; closing all fds and rejecting incomplete message"
);
return
syserr
or
_set
(
-
EFBIG
,
"Control message was truncated; closing all fds and rejecting incomplete message"
);
}
if
(
ret_fds
->
fd_count_max
>
num_raw
)
{
...
...
@@ -243,7 +243,7 @@ again:
for
(
idx
=
0
;
idx
<
num_raw
;
idx
++
)
close
(
fds_raw
[
idx
]);
return
syserr
no
_set
(
-
EINVAL
,
"Received fewer file descriptors than we expected %u != %u"
,
return
syserr
or
_set
(
-
EINVAL
,
"Received fewer file descriptors than we expected %u != %u"
,
ret_fds
->
fd_count_max
,
num_raw
);
}
...
...
@@ -261,7 +261,7 @@ again:
for
(
idx
=
0
;
idx
<
num_raw
;
idx
++
)
close
(
fds_raw
[
idx
]);
return
syserr
no
_set
(
-
EINVAL
,
"Received more file descriptors than we expected %u != %u"
,
return
syserr
or
_set
(
-
EINVAL
,
"Received more file descriptors than we expected %u != %u"
,
ret_fds
->
fd_count_max
,
num_raw
);
}
...
...
@@ -280,7 +280,7 @@ again:
for
(
idx
=
0
;
idx
<
num_raw
;
idx
++
)
close
(
fds_raw
[
idx
]);
return
syserr
no
_set
(
-
EINVAL
,
"Invalid flag combination; closing to not risk leaking fds %u != %u"
,
return
syserr
or
_set
(
-
EINVAL
,
"Invalid flag combination; closing to not risk leaking fds %u != %u"
,
ret_fds
->
fd_count_max
,
num_raw
);
}
...
...
@@ -296,7 +296,7 @@ again:
/* We expected to receive file descriptors. */
if
((
ret_fds
->
flags
&
UNIX_FDS_ACCEPT_MASK
)
&&
!
(
ret_fds
->
flags
&
UNIX_FDS_ACCEPT_NONE
))
return
syserr
no
_set
(
-
EINVAL
,
"Received no file descriptors"
);
return
syserr
or
_set
(
-
EINVAL
,
"Received no file descriptors"
);
}
return
ret
;
...
...
src/lxc/cgroups/cgfsng.c
View file @
060aaa39
...
...
@@ -425,7 +425,7 @@ static int cgroup_hierarchy_add(struct cgroup_ops *ops, int dfd_mnt, char *mnt,
int
idx
;
if
(
abspath
(
base_cgroup
))
return
syserr
no
_set
(
-
EINVAL
,
"Container base path must be relative to controller mount"
);
return
syserr
or
_set
(
-
EINVAL
,
"Container base path must be relative to controller mount"
);
new
=
zalloc
(
sizeof
(
*
new
));
if
(
!
new
)
...
...
@@ -736,10 +736,10 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
* absolute nor walks upwards.
*/
if
(
abspath
(
cur
))
return
syserr
no
_set
(
-
EINVAL
,
"No absolute paths allowed"
);
return
syserr
or
_set
(
-
EINVAL
,
"No absolute paths allowed"
);
if
(
strnequal
(
cur
,
".."
,
STRLITERALLEN
(
".."
)))
return
syserr
no
_set
(
-
EINVAL
,
"No upward walking paths allowed"
);
return
syserr
or
_set
(
-
EINVAL
,
"No upward walking paths allowed"
);
ret
=
mkdirat
(
dfd_cur
,
cur
,
mode
);
if
(
ret
<
0
)
{
...
...
@@ -768,7 +768,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
/* The final cgroup must be succesfully creatd by us. */
if
(
ret
)
{
if
(
ret
!=
-
EEXIST
||
!
eexist_ignore
)
return
syserr
no
_set
(
ret
,
"Creating the final cgroup %d(%s) failed"
,
dfd_base
,
path
);
return
syserr
or
_set
(
ret
,
"Creating the final cgroup %d(%s) failed"
,
dfd_base
,
path
);
}
return
move_fd
(
dfd_final
);
...
...
@@ -1339,7 +1339,7 @@ static int chown_cgroup_wrapper(void *data)
int
dirfd
=
arg
->
hierarchies
[
i
]
->
dfd_con
;
if
(
dirfd
<
0
)
return
syserr
no
_set
(
-
EBADF
,
"Invalid cgroup file descriptor"
);
return
syserr
or
_set
(
-
EBADF
,
"Invalid cgroup file descriptor"
);
(
void
)
fchowmodat
(
dirfd
,
""
,
destuid
,
nsgid
,
0775
);
...
...
@@ -2787,7 +2787,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
else
ret
=
device_cgroup_rule_parse
(
&
device_item
,
key
,
val
);
if
(
ret
<
0
)
return
syserr
no
_set
(
EINVAL
,
"Failed to parse device rule %s=%s"
,
key
,
val
);
return
syserr
or
_set
(
EINVAL
,
"Failed to parse device rule %s=%s"
,
key
,
val
);
/*
* Note that bpf_list_add_device() returns 1 if it altered the device
...
...
@@ -2930,10 +2930,10 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
* absolute nor walks upwards.
*/
if
(
abspath
(
cur
))
return
syserr
no
_set
(
-
EINVAL
,
"No absolute paths allowed"
);
return
syserr
or
_set
(
-
EINVAL
,
"No absolute paths allowed"
);
if
(
strnequal
(
cur
,
".."
,
STRLITERALLEN
(
".."
)))
return
syserr
no
_set
(
-
EINVAL
,
"No upward walking paths allowed"
);
return
syserr
or
_set
(
-
EINVAL
,
"No upward walking paths allowed"
);
ret
=
lxc_writeat
(
dfd_cur
,
"cgroup.subtree_control"
,
add_controllers
,
full_len
);
if
(
ret
<
0
)
...
...
@@ -3258,7 +3258,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
}
if
(
!
controllers_available
(
ops
))
return
syserr
no
_set
(
-
ENOENT
,
"One or more requested controllers unavailable or not delegated"
);
return
syserr
or
_set
(
-
ENOENT
,
"One or more requested controllers unavailable or not delegated"
);
return
0
;
}
...
...
@@ -3436,7 +3436,7 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
}
if
(
idx
==
0
)
return
syserr
no
_set
(
-
ENOENT
,
"Failed to attach to cgroups"
);
return
syserr
or
_set
(
-
ENOENT
,
"Failed to attach to cgroups"
);
TRACE
(
"Attached to %s cgroup layout"
,
cgroup_layout_name
(
ctx
->
layout
));
return
0
;
...
...
src/lxc/cgroups/cgroup2_devices.c
View file @
060aaa39
...
...
@@ -352,7 +352,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
return
ret_errno
(
EBADF
);
if
(
flags
&
~
(
BPF_F_ALLOW_OVERRIDE
|
BPF_F_ALLOW_MULTI
|
BPF_F_REPLACE
))
return
syserr
no
_set
(
-
EINVAL
,
"Invalid flags for bpf program"
);
return
syserr
or
_set
(
-
EINVAL
,
"Invalid flags for bpf program"
);
/*
* Don't allow the bpf program to be overwritten for now. If we ever
...
...
@@ -513,11 +513,11 @@ int bpf_list_add_device(struct bpf_devices *bpf_devices,
list_elem
=
malloc
(
sizeof
(
*
list_elem
));
if
(
!
list_elem
)
return
syserr
no
_set
(
ENOMEM
,
"Failed to allocate new device list"
);
return
syserr
or
_set
(
ENOMEM
,
"Failed to allocate new device list"
);
new_device
=
memdup
(
device
,
sizeof
(
struct
device_item
));
if
(
!
new_device
)
return
syserr
no
_set
(
ENOMEM
,
"Failed to allocate new device item"
);
return
syserr
or
_set
(
ENOMEM
,
"Failed to allocate new device item"
);
lxc_list_add_elem
(
list_elem
,
move_ptr
(
new_device
));
lxc_list_add_tail
(
&
bpf_devices
->
device_item
,
move_ptr
(
list_elem
));
...
...
src/lxc/commands.c
View file @
060aaa39
...
...
@@ -231,7 +231,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
*/
if
((
rsp
->
datalen
>
LXC_CMD_DATA_MAX
)
&&
(
cur_cmd
!=
LXC_CMD_CONSOLE_LOG
))
return
syserr
no
_set
(
-
E2BIG
,
"Response data for command
\"
%s
\"
is too long: %d bytes > %d"
,
return
syserr
or
_set
(
-
E2BIG
,
"Response data for command
\"
%s
\"
is too long: %d bytes > %d"
,
cur_cmdstr
,
rsp
->
datalen
,
LXC_CMD_DATA_MAX
);
/*
...
...
@@ -254,14 +254,14 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
__fallthrough
;
case
LXC_CMD_GET_LIMIT_CGROUP_FD
:
/* data */
if
(
rsp
->
datalen
>
sizeof
(
struct
cgroup_fd
))
return
syserr
no
_set
(
-
EINVAL
,
"Invalid response size from server for
\"
%s
\"
"
,
cur_cmdstr
);
return
syserr
or
_set
(
-
EINVAL
,
"Invalid response size from server for
\"
%s
\"
"
,
cur_cmdstr
);
/* Don't pointlessly allocate. */
rsp
->
data
=
(
void
*
)
cmd
->
req
.
data
;
break
;
case
LXC_CMD_GET_CGROUP_CTX
:
/* data */
if
(
rsp
->
datalen
>
sizeof
(
struct
cgroup_ctx
))
return
syserr
no
_set
(
-
EINVAL
,
"Invalid response size from server for
\"
%s
\"
"
,
cur_cmdstr
);
return
syserr
or
_set
(
-
EINVAL
,
"Invalid response size from server for
\"
%s
\"
"
,
cur_cmdstr
);
/* Don't pointlessly allocate. */
rsp
->
data
=
(
void
*
)
cmd
->
req
.
data
;
...
...
@@ -284,7 +284,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
rsp
->
data
=
tty
;
break
;
}
return
syserr
no
_set
(
-
ENOMEM
,
"Failed to receive response for command
\"
%s
\"
"
,
cur_cmdstr
);
return
syserr
or
_set
(
-
ENOMEM
,
"Failed to receive response for command
\"
%s
\"
"
,
cur_cmdstr
);
case
LXC_CMD_CONSOLE_LOG
:
/* data */
__data
=
zalloc
(
rsp
->
datalen
+
1
);
rsp
->
data
=
__data
;
...
...
@@ -305,7 +305,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
* Either static or allocated memory.
*/
if
(
!
rsp
->
data
)
return
syserr
no
_set
(
-
ENOMEM
,
"Failed to prepare response buffer for command
\"
%s
\"
"
,
return
syserr
or
_set
(
-
ENOMEM
,
"Failed to prepare response buffer for command
\"
%s
\"
"
,
cur_cmdstr
);
bytes_recv
=
lxc_recv_nointr
(
sock
,
rsp
->
data
,
rsp
->
datalen
,
0
);
...
...
@@ -744,7 +744,7 @@ static int lxc_cmd_get_seccomp_notify_fd_callback(int fd, struct lxc_cmd_req *re
rsp
.
ret
=
0
;
return
rsp_one_fd_reap
(
fd
,
handler
->
conf
->
seccomp
.
notifier
.
notify_fd
,
&
rsp
);
#else
return
syserr
no
_set
(
-
EOPNOTSUPP
,
"Seccomp notifier not supported"
);
return
syserr
or
_set
(
-
EOPNOTSUPP
,
"Seccomp notifier not supported"
);
#endif
}
...
...
@@ -1388,17 +1388,17 @@ int lxc_cmd_add_bpf_device_cgroup(const char *name, const char *lxcpath,
struct
lxc_cmd_rr
cmd
;
if
(
strlen
(
device
->
access
)
>
STRLITERALLEN
(
"rwm"
))
return
syserr
no
_set
(
-
EINVAL
,
"Invalid access mode specified %s"
,
device
->
access
);
return
syserr
or
_set
(
-
EINVAL
,
"Invalid access mode specified %s"
,
device
->
access
);
lxc_cmd_init
(
&
cmd
,
LXC_CMD_ADD_BPF_DEVICE_CGROUP
);
lxc_cmd_data
(
&
cmd
,
sizeof
(
struct
device_item
),
device
);
ret
=
lxc_cmd
(
name
,
&
cmd
,
&
stopped
,
lxcpath
,
NULL
);
if
(
ret
<
0
)
return
syserr
no
_set
(
ret
,
"Failed to process new bpf device cgroup command"
);
return
syserr
or
_set
(
ret
,
"Failed to process new bpf device cgroup command"
);
if
(
cmd
.
rsp
.
ret
<
0
)
return
syserr
no
_set
(
cmd
.
rsp
.
ret
,
"Failed to add new bpf device cgroup rule"
);
return
syserr
or
_set
(
cmd
.
rsp
.
ret
,
"Failed to add new bpf device cgroup rule"
);
return
0
;
}
...
...
@@ -1856,7 +1856,7 @@ static int lxc_cmd_rsp_send_enosys(int fd, int id)
};
__lxc_cmd_rsp_send
(
fd
,
&
rsp
);
return
syserr
no
_set
(
-
ENOSYS
,
"Invalid command id %d"
,
id
);
return
syserr
or
_set
(
-
ENOSYS
,
"Invalid command id %d"
,
id
);
}
static
int
lxc_cmd_process
(
int
fd
,
struct
lxc_cmd_req
*
req
,
...
...
src/lxc/confile.c
View file @
060aaa39
...
...
@@ -1825,10 +1825,10 @@ static int set_config_cgroup_dir(const char *key, const char *value,
return
clr_config_cgroup_dir
(
key
,
lxc_conf
,
NULL
);
if
(
abspath
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
if
(
dotdot
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
set_config_path_item
(
&
lxc_conf
->
cgroup_meta
.
dir
,
value
);
}
...
...
@@ -1840,10 +1840,10 @@ static int set_config_cgroup_monitor_dir(const char *key, const char *value,
return
clr_config_cgroup_monitor_dir
(
key
,
lxc_conf
,
NULL
);
if
(
abspath
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
if
(
dotdot
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
set_config_path_item
(
&
lxc_conf
->
cgroup_meta
.
monitor_dir
,
value
);
}
...
...
@@ -1855,10 +1855,10 @@ static int set_config_cgroup_monitor_pivot_dir(const char *key, const char *valu
return
clr_config_cgroup_monitor_pivot_dir
(
key
,
lxc_conf
,
NULL
);
if
(
abspath
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
if
(
dotdot
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
set_config_path_item
(
&
lxc_conf
->
cgroup_meta
.
monitor_pivot_dir
,
value
);
}
...
...
@@ -1871,10 +1871,10 @@ static int set_config_cgroup_container_dir(const char *key, const char *value,
return
clr_config_cgroup_container_dir
(
key
,
lxc_conf
,
NULL
);
if
(
abspath
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
if
(
dotdot
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not walk upwards via
\"
../
\"
"
,
key
);
return
set_config_path_item
(
&
lxc_conf
->
cgroup_meta
.
container_dir
,
value
);
}
...
...
@@ -1888,7 +1888,7 @@ static int set_config_cgroup_container_inner_dir(const char *key,
return
clr_config_cgroup_container_inner_dir
(
key
,
lxc_conf
,
NULL
);
if
(
abspath
(
value
))
return
syserr
no
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
return
syserr
or
_set
(
-
EINVAL
,
"%s paths may not be absolute"
,
key
);
if
(
strchr
(
value
,
'/'
)
||
strequal
(
value
,
"."
)
||
strequal
(
value
,
".."
))
return
log_error_errno
(
-
EINVAL
,
EINVAL
,
"lxc.cgroup.dir.container.inner must be a single directory name"
);
...
...
src/lxc/log.h
View file @
060aaa39
...
...
@@ -522,14 +522,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__internal_ret__; \
})
#define syserrno_set(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
errno = labs(__ret__); \
SYSERROR(format, ##__VA_ARGS__); \
__internal_ret__; \
})
#define syswarn_set(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment