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
94c0fbad
Unverified
Commit
94c0fbad
authored
Feb 13, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: convert to strequal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
8eaaad62
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
cgfsng.c
src/lxc/cgroups/cgfsng.c
+10
-10
cgroup_utils.c
src/lxc/cgroups/cgroup_utils.c
+2
-2
No files found.
src/lxc/cgroups/cgfsng.c
View file @
94c0fbad
...
...
@@ -135,7 +135,7 @@ static void must_append_controller(char **klist, char **nlist, char ***clist,
newentry
=
append_null_to_list
((
void
***
)
clist
);
if
(
strn
cmp
(
entry
,
"name="
,
5
)
==
0
)
if
(
strn
equal
(
entry
,
"name="
,
5
)
)
copy
=
must_copy_string
(
entry
);
else
if
(
string_in_list
(
klist
,
entry
))
copy
=
must_copy_string
(
entry
);
...
...
@@ -630,7 +630,7 @@ static char **cg_hybrid_get_controllers(char **klist, char **nlist, char *line,
/* Note, if we change how mountinfo works, then our caller will need to
* verify /sys/fs/cgroup/ in this field.
*/
if
(
strncmp
(
p
,
DEFAULT_CGROUP_MOUNTPOINT
"/"
,
15
)
!=
0
)
if
(
!
strnequal
(
p
,
DEFAULT_CGROUP_MOUNTPOINT
"/"
,
15
)
)
return
log_warn
(
NULL
,
"Found hierarchy not under "
DEFAULT_CGROUP_MOUNTPOINT
":
\"
%s
\"
"
,
p
);
p
+=
15
;
...
...
@@ -729,7 +729,7 @@ static char *cg_hybrid_get_mountpoint(char *line)
p
++
;
}
if
(
strncmp
(
p
,
DEFAULT_CGROUP_MOUNTPOINT
"/"
,
15
)
!=
0
)
if
(
!
strnequal
(
p
,
DEFAULT_CGROUP_MOUNTPOINT
"/"
,
15
)
)
return
NULL
;
p2
=
strchr
(
p
+
15
,
' '
);
...
...
@@ -867,7 +867,7 @@ static int get_existing_subsystems(char ***klist, char ***nlist)
}
lxc_iterate_parts
(
tok
,
p
,
","
)
{
if
(
strn
cmp
(
tok
,
"name="
,
5
)
==
0
)
if
(
strn
equal
(
tok
,
"name="
,
5
)
)
must_append_string
(
nlist
,
tok
);
else
must_append_string
(
klist
,
tok
);
...
...
@@ -1806,7 +1806,7 @@ static int __cg_mount_direct(int type, struct hierarchy *h,
if
(
!
is_unified_hierarchy
(
h
))
{
for
(
const
char
**
it
=
(
const
char
**
)
h
->
controllers
;
it
&&
*
it
;
it
++
)
{
if
(
strn
cmp
(
*
it
,
"name="
,
STRLITERALLEN
(
"name="
))
==
0
)
if
(
strn
equal
(
*
it
,
"name="
,
STRLITERALLEN
(
"name="
))
)
ret
=
fs_set_property
(
fd_fs
,
"name"
,
*
it
+
STRLITERALLEN
(
"name="
));
else
ret
=
fs_set_property
(
fd_fs
,
*
it
,
""
);
...
...
@@ -2131,7 +2131,7 @@ static int freezer_cgroup_events_cb(int fd, uint32_t events, void *cbdata,
state_string
=
"frozen 0"
;
while
(
getline
(
&
line
,
&
len
,
f
)
!=
-
1
)
if
(
strn
cmp
(
line
,
state_string
,
STRLITERALLEN
(
"frozen"
)
+
2
)
==
0
)
if
(
strn
equal
(
line
,
state_string
,
STRLITERALLEN
(
"frozen"
)
+
2
)
)
return
LXC_MAINLOOP_CLOSE
;
rewind
(
f
);
...
...
@@ -2916,8 +2916,8 @@ __cgfsng_ops static bool cgfsng_setup_limits_legacy(struct cgroup_ops *ops,
lxc_list_for_each
(
iterator
,
sorted_cgroup_settings
)
{
cg
=
iterator
->
elem
;
if
(
do_devices
==
!
strncmp
(
"devices"
,
cg
->
subsystem
,
7
))
{
if
(
cg_legacy_set_data
(
ops
,
cg
->
subsystem
,
cg
->
value
,
strn
cmp
(
"cpuset"
,
cg
->
subsystem
,
6
)
==
0
))
{
if
(
do_devices
==
strnequal
(
"devices"
,
cg
->
subsystem
,
7
))
{
if
(
cg_legacy_set_data
(
ops
,
cg
->
subsystem
,
cg
->
value
,
strn
equal
(
"cpuset"
,
cg
->
subsystem
,
6
)
))
{
if
(
do_devices
&&
(
errno
==
EACCES
||
errno
==
EPERM
))
{
SYSWARN
(
"Failed to set
\"
%s
\"
to
\"
%s
\"
"
,
cg
->
subsystem
,
cg
->
value
);
continue
;
...
...
@@ -3001,7 +3001,7 @@ __cgfsng_ops static bool cgfsng_setup_limits(struct cgroup_ops *ops,
struct
lxc_cgroup
*
cg
=
iterator
->
elem
;
int
ret
;
if
(
strn
cmp
(
"devices"
,
cg
->
subsystem
,
7
)
==
0
)
if
(
strn
equal
(
"devices"
,
cg
->
subsystem
,
7
)
)
ret
=
bpf_device_cgroup_prepare
(
ops
,
conf
,
cg
->
subsystem
,
cg
->
value
);
else
ret
=
lxc_write_openat
(
h
->
container_limit_path
,
cg
->
subsystem
,
cg
->
value
,
strlen
(
cg
->
value
));
...
...
@@ -3630,7 +3630,7 @@ int cgroup_set(const char *name, const char *lxcpath,
if
(
unified_fd
<
0
)
return
ret_errno
(
ENOCGROUP2
);
if
(
strn
cmp
(
filename
,
"devices."
,
STRLITERALLEN
(
"devices."
))
==
0
)
{
if
(
strn
equal
(
filename
,
"devices."
,
STRLITERALLEN
(
"devices."
))
)
{
struct
device_item
device
=
{};
ret
=
device_cgroup_rule_parse
(
&
device
,
filename
,
value
);
...
...
src/lxc/cgroups/cgroup_utils.c
View file @
94c0fbad
...
...
@@ -33,7 +33,7 @@ bool is_cgroupfs_v1(char *line)
char
*
p
=
strstr
(
line
,
" - "
);
if
(
!
p
)
return
false
;
return
strn
cmp
(
p
,
" - cgroup "
,
10
)
==
0
;
return
strn
equal
(
p
,
" - cgroup "
,
10
)
;
}
bool
is_cgroupfs_v2
(
char
*
line
)
...
...
@@ -42,7 +42,7 @@ bool is_cgroupfs_v2(char *line)
if
(
!
p
)
return
false
;
return
strn
cmp
(
p
,
" - cgroup2 "
,
11
)
==
0
;
return
strn
equal
(
p
,
" - cgroup2 "
,
11
)
;
}
bool
test_writeable_v1
(
char
*
mountpoint
,
char
*
path
)
...
...
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