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
bfada1b3
Unverified
Commit
bfada1b3
authored
Dec 08, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: cleanup set_config_sysctl()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
88d3a239
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
conf.h
src/lxc/conf.h
+10
-0
confile.c
src/lxc/confile.c
+12
-22
No files found.
src/lxc/conf.h
View file @
bfada1b3
...
@@ -121,6 +121,16 @@ struct lxc_sysctl {
...
@@ -121,6 +121,16 @@ struct lxc_sysctl {
char
*
value
;
char
*
value
;
};
};
static
void
free_lxc_sysctl
(
struct
lxc_sysctl
*
ptr
)
{
if
(
ptr
)
{
free
(
ptr
->
key
);
free
(
ptr
->
value
);
free_disarm
(
ptr
);
}
}
define_cleanup_function
(
struct
lxc_sysctl
*
,
free_lxc_sysctl
);
/*
/*
* Defines a structure to configure proc filesystem at runtime.
* Defines a structure to configure proc filesystem at runtime.
* @filename : the proc filesystem will be configured without the "lxc.proc" prefix
* @filename : the proc filesystem will be configured without the "lxc.proc" prefix
...
...
src/lxc/confile.c
View file @
bfada1b3
...
@@ -1816,10 +1816,9 @@ static int set_config_prlimit(const char *key, const char *value,
...
@@ -1816,10 +1816,9 @@ static int set_config_prlimit(const char *key, const char *value,
static
int
set_config_sysctl
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_sysctl
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
__do_free
struct
lxc_list
*
sysctl_list
=
NULL
;
call_cleaner
(
free_lxc_sysctl
)
struct
lxc_sysctl
*
sysctl_elem
=
NULL
;
struct
lxc_list
*
iter
;
struct
lxc_list
*
iter
;
char
*
replace_value
=
NULL
;
struct
lxc_list
*
sysctl_list
=
NULL
;
struct
lxc_sysctl
*
sysctl_elem
=
NULL
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
clr_config_sysctl
(
key
,
lxc_conf
,
NULL
);
return
clr_config_sysctl
(
key
,
lxc_conf
,
NULL
);
...
@@ -1831,6 +1830,8 @@ static int set_config_sysctl(const char *key, const char *value,
...
@@ -1831,6 +1830,8 @@ static int set_config_sysctl(const char *key, const char *value,
/* find existing list element */
/* find existing list element */
lxc_list_for_each
(
iter
,
&
lxc_conf
->
sysctls
)
{
lxc_list_for_each
(
iter
,
&
lxc_conf
->
sysctls
)
{
__do_free
char
*
replace_value
=
NULL
;
sysctl_elem
=
iter
->
elem
;
sysctl_elem
=
iter
->
elem
;
if
(
strcmp
(
key
,
sysctl_elem
->
key
)
!=
0
)
if
(
strcmp
(
key
,
sysctl_elem
->
key
)
!=
0
)
...
@@ -1838,10 +1839,10 @@ static int set_config_sysctl(const char *key, const char *value,
...
@@ -1838,10 +1839,10 @@ static int set_config_sysctl(const char *key, const char *value,
replace_value
=
strdup
(
value
);
replace_value
=
strdup
(
value
);
if
(
!
replace_value
)
if
(
!
replace_value
)
return
-
1
;
return
ret_errno
(
EINVAL
)
;
free
(
sysctl_elem
->
value
);
free
(
sysctl_elem
->
value
);
sysctl_elem
->
value
=
replace_value
;
sysctl_elem
->
value
=
move_ptr
(
replace_value
)
;
return
0
;
return
0
;
}
}
...
@@ -1849,36 +1850,25 @@ static int set_config_sysctl(const char *key, const char *value,
...
@@ -1849,36 +1850,25 @@ static int set_config_sysctl(const char *key, const char *value,
/* allocate list element */
/* allocate list element */
sysctl_list
=
malloc
(
sizeof
(
*
sysctl_list
));
sysctl_list
=
malloc
(
sizeof
(
*
sysctl_list
));
if
(
!
sysctl_list
)
if
(
!
sysctl_list
)
goto
on_error
;
return
ret_errno
(
ENOMEM
)
;
sysctl_elem
=
malloc
(
sizeof
(
*
sysctl_elem
));
sysctl_elem
=
malloc
(
sizeof
(
*
sysctl_elem
));
if
(
!
sysctl_elem
)
if
(
!
sysctl_elem
)
goto
on_error
;
return
ret_errno
(
ENOMEM
)
;
memset
(
sysctl_elem
,
0
,
sizeof
(
*
sysctl_elem
));
memset
(
sysctl_elem
,
0
,
sizeof
(
*
sysctl_elem
));
sysctl_elem
->
key
=
strdup
(
key
);
sysctl_elem
->
key
=
strdup
(
key
);
if
(
!
sysctl_elem
->
key
)
if
(
!
sysctl_elem
->
key
)
goto
on_error
;
return
ret_errno
(
ENOMEM
)
;
sysctl_elem
->
value
=
strdup
(
value
);
sysctl_elem
->
value
=
strdup
(
value
);
if
(
!
sysctl_elem
->
value
)
if
(
!
sysctl_elem
->
value
)
goto
on_error
;
return
ret_errno
(
ENOMEM
)
;
lxc_list_add_elem
(
sysctl_list
,
sysctl_elem
);
lxc_list_add_elem
(
sysctl_list
,
move_ptr
(
sysctl_elem
)
);
lxc_list_add_tail
(
&
lxc_conf
->
sysctls
,
sysctl_list
);
lxc_list_add_tail
(
&
lxc_conf
->
sysctls
,
move_ptr
(
sysctl_list
)
);
return
0
;
return
0
;
on_error:
free
(
sysctl_list
);
if
(
sysctl_elem
)
{
free
(
sysctl_elem
->
key
);
free
(
sysctl_elem
->
value
);
free
(
sysctl_elem
);
}
return
-
1
;
}
}
static
int
set_config_proc
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_proc
(
const
char
*
key
,
const
char
*
value
,
...
...
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