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
2238c216
Unverified
Commit
2238c216
authored
Jun 13, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Jul 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: mv config_value_empty() to confile_utils
and rename it to lxc_config_value_empty() Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
0d75d4a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
45 deletions
+51
-45
confile.c
src/lxc/confile.c
+37
-45
confile_utils.c
src/lxc/confile_utils.c
+10
-0
confile_utils.h
src/lxc/confile_utils.h
+4
-0
No files found.
src/lxc/confile.c
View file @
2238c216
...
...
@@ -443,19 +443,11 @@ int lxc_listconfigs(char *retv, int inlen)
return
fulllen
;
}
static
inline
bool
config_value_empty
(
const
char
*
value
)
{
if
(
value
&&
strlen
(
value
)
>
0
)
return
false
;
return
true
;
}
static
int
set_config_string_item
(
char
**
conf_item
,
const
char
*
value
)
{
char
*
new_value
;
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
free
(
*
conf_item
);
*
conf_item
=
NULL
;
return
0
;
...
...
@@ -533,7 +525,7 @@ out:
static
int
set_config_network
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
{
if
(
!
config_value_empty
(
value
))
{
if
(
!
lxc_
config_value_empty
(
value
))
{
ERROR
(
"lxc.network must not have a value"
);
return
-
1
;
}
...
...
@@ -550,7 +542,7 @@ static int set_config_network_type(const char *key, const char *value,
struct
lxc_netdev
*
netdev
;
struct
lxc_list
*
list
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_config_network
(
lxc_conf
);
netdev
=
malloc
(
sizeof
(
*
netdev
));
...
...
@@ -893,7 +885,7 @@ static int set_config_network_hwaddr(const char *key, const char *value,
return
-
1
;
};
if
(
config_value_empty
(
new_value
))
{
if
(
lxc_
config_value_empty
(
new_value
))
{
free
(
new_value
);
netdev
->
hwaddr
=
NULL
;
return
0
;
...
...
@@ -944,7 +936,7 @@ static int set_config_network_ipv4(const char *key, const char *value,
char
*
cursor
,
*
slash
;
char
*
addr
=
NULL
,
*
bcast
=
NULL
,
*
prefix
=
NULL
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
clr_config_network_item
(
key
,
lxc_conf
);
netdev
=
network_netdev
(
key
,
value
,
&
lxc_conf
->
network
);
...
...
@@ -1038,7 +1030,7 @@ static int set_config_network_ipv4_gateway(const char *key, const char *value,
free
(
netdev
->
ipv4_gateway
);
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
netdev
->
ipv4_gateway
=
NULL
;
}
else
if
(
!
strcmp
(
value
,
"auto"
))
{
netdev
->
ipv4_gateway
=
NULL
;
...
...
@@ -1073,7 +1065,7 @@ static int set_config_network_ipv6(const char *key, const char *value,
struct
lxc_list
*
list
;
char
*
slash
,
*
valdup
,
*
netmask
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
clr_config_network_item
(
key
,
lxc_conf
);
netdev
=
network_netdev
(
key
,
value
,
&
lxc_conf
->
network
);
...
...
@@ -1139,7 +1131,7 @@ static int set_config_network_ipv6_gateway(const char *key, const char *value,
free
(
netdev
->
ipv6_gateway
);
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
netdev
->
ipv6_gateway
=
NULL
;
}
else
if
(
!
strcmp
(
value
,
"auto"
))
{
netdev
->
ipv6_gateway
=
NULL
;
...
...
@@ -1223,7 +1215,7 @@ static int set_config_init_uid(const char *key, const char *value,
unsigned
int
init_uid
;
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
init_uid
=
0
;
return
0
;
}
...
...
@@ -1242,7 +1234,7 @@ static int set_config_init_gid(const char *key, const char *value,
unsigned
int
init_gid
;
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
init_gid
=
0
;
return
0
;
}
...
...
@@ -1260,7 +1252,7 @@ static int set_config_hooks(const char *key, const char *value,
{
char
*
copy
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_hooks
(
lxc_conf
,
key
);
if
(
strcmp
(
key
+
4
,
"hook"
)
==
0
)
{
...
...
@@ -1314,7 +1306,7 @@ static int set_config_pts(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
pts
=
0
;
return
0
;
}
...
...
@@ -1336,7 +1328,7 @@ static int set_config_start(const char *key, const char *value,
{
bool
is_empty
;
is_empty
=
config_value_empty
(
value
);
is_empty
=
lxc_
config_value_empty
(
value
);
if
(
*
(
key
+
10
)
==
'a'
)
{
/* lxc.start.auto */
/* Set config value to default. */
...
...
@@ -1381,7 +1373,7 @@ static int set_config_monitor(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
monitor_unshare
=
0
;
return
0
;
}
...
...
@@ -1401,7 +1393,7 @@ static int set_config_group(const char *key, const char *value,
struct
lxc_list
*
grouplist
;
int
ret
=
-
1
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_groups
(
lxc_conf
);
groups
=
strdup
(
value
);
...
...
@@ -1445,7 +1437,7 @@ static int set_config_environment(const char *key, const char *value,
{
struct
lxc_list
*
list_item
=
NULL
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_environment
(
lxc_conf
);
list_item
=
malloc
(
sizeof
(
*
list_item
));
...
...
@@ -1470,7 +1462,7 @@ static int set_config_tty(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
tty
=
0
;
return
0
;
}
...
...
@@ -1490,7 +1482,7 @@ static int set_config_kmsg(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
kmsg
=
0
;
return
0
;
}
...
...
@@ -1515,7 +1507,7 @@ static int set_config_lsm_aa_incomplete(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
lsm_aa_allow_incomplete
=
0
;
return
0
;
}
...
...
@@ -1544,7 +1536,7 @@ static int set_config_logfile(const char *key, const char *value,
{
int
ret
;
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
free
(
c
->
logfile
);
c
->
logfile
=
NULL
;
return
0
;
...
...
@@ -1565,7 +1557,7 @@ static int set_config_loglevel(const char *key, const char *value,
int
newlevel
;
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
loglevel
=
LXC_LOG_LEVEL_NOTSET
;
return
0
;
}
...
...
@@ -1589,7 +1581,7 @@ static int set_config_autodev(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
autodev
=
0
;
return
0
;
}
...
...
@@ -1661,7 +1653,7 @@ static int set_config_haltsignal(const char *key, const char *value,
int
sig_n
;
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
haltsignal
=
0
;
return
0
;
}
...
...
@@ -1682,7 +1674,7 @@ static int set_config_rebootsignal(const char *key, const char *value,
int
sig_n
;
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
rebootsignal
=
0
;
return
0
;
}
...
...
@@ -1702,7 +1694,7 @@ static int set_config_stopsignal(const char *key, const char *value,
int
sig_n
;
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
stopsignal
=
0
;
return
0
;
}
...
...
@@ -1724,7 +1716,7 @@ static int set_config_cgroup(const char *key, const char *value,
struct
lxc_list
*
cglist
=
NULL
;
struct
lxc_cgroup
*
cgelem
=
NULL
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_cgroups
(
lxc_conf
,
key
);
subkey
=
strstr
(
key
,
token
);
...
...
@@ -1783,7 +1775,7 @@ static int set_config_idmaps(const char *key, const char *value,
struct
lxc_list
*
idmaplist
=
NULL
;
struct
id_map
*
idmap
=
NULL
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_idmaps
(
lxc_conf
);
idmaplist
=
malloc
(
sizeof
(
*
idmaplist
));
...
...
@@ -1826,7 +1818,7 @@ on_error:
static
int
set_config_fstab
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
{
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
clr_config_fstab
(
key
,
lxc_conf
);
return
-
1
;
}
...
...
@@ -1867,7 +1859,7 @@ static int set_config_mount_auto(const char *key, const char *value,
{
NULL
,
0
,
0
}
};
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
auto_mounts
=
0
;
return
0
;
}
...
...
@@ -1909,7 +1901,7 @@ static int set_config_mount(const char *key, const char *value,
char
*
mntelem
;
struct
lxc_list
*
mntlist
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_mount_entries
(
lxc_conf
);
mntlist
=
malloc
(
sizeof
(
*
mntlist
));
...
...
@@ -1935,7 +1927,7 @@ static int set_config_cap_keep(const char *key, const char *value,
struct
lxc_list
*
keeplist
;
int
ret
=
-
1
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_config_keepcaps
(
lxc_conf
);
keepcaps
=
strdup
(
value
);
...
...
@@ -1985,7 +1977,7 @@ static int set_config_cap_drop(const char *key, const char *value,
struct
lxc_list
*
droplist
;
int
ret
=
-
1
;
if
(
config_value_empty
(
value
))
if
(
lxc_
config_value_empty
(
value
))
return
lxc_clear_config_caps
(
lxc_conf
);
dropcaps
=
strdup
(
value
);
...
...
@@ -2150,7 +2142,7 @@ static int set_config_includefiles(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
clr_config_includefiles
(
key
,
lxc_conf
);
return
0
;
}
...
...
@@ -2183,7 +2175,7 @@ static int set_config_rootfs_options(const char *key, const char *value,
static
int
set_config_rootfs_backend
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
{
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
free
(
lxc_conf
->
rootfs
.
bdev_type
);
lxc_conf
->
rootfs
.
bdev_type
=
NULL
;
return
0
;
...
...
@@ -2209,7 +2201,7 @@ static int set_config_utsname(const char *key, const char *value,
{
struct
utsname
*
utsname
;
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
clr_config_utsname
(
key
,
lxc_conf
);
return
0
;
}
...
...
@@ -2494,7 +2486,7 @@ bool do_append_unexp_config_line(struct lxc_conf *conf, const char *key,
len
=
strlen
(
key
)
+
strlen
(
v
)
+
4
;
tmp
=
alloca
(
len
);
if
(
config_value_empty
(
v
))
if
(
lxc_
config_value_empty
(
v
))
ret
=
snprintf
(
tmp
,
len
,
"%s ="
,
key
);
else
ret
=
snprintf
(
tmp
,
len
,
"%s = %s"
,
key
,
v
);
...
...
@@ -2849,7 +2841,7 @@ static int set_config_ephemeral(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
)
{
/* Set config value to default. */
if
(
config_value_empty
(
value
))
{
if
(
lxc_
config_value_empty
(
value
))
{
lxc_conf
->
ephemeral
=
0
;
return
0
;
}
...
...
src/lxc/confile_utils.c
View file @
2238c216
...
...
@@ -20,6 +20,8 @@
#include <stdio.h>
#include <string.h>
#include "conf.h"
#include "log.h"
#include "utils.h"
int
parse_idmaps
(
const
char
*
idmap
,
char
*
type
,
unsigned
long
*
nsid
,
...
...
@@ -146,3 +148,11 @@ on_error:
return
ret
;
}
bool
lxc_config_value_empty
(
const
char
*
value
)
{
if
(
value
&&
strlen
(
value
)
>
0
)
return
false
;
return
true
;
}
src/lxc/confile_utils.h
View file @
2238c216
...
...
@@ -20,7 +20,11 @@
#ifndef __LXC_CONFILE_UTILS_H
#define __LXC_CONFILE_UTILS_H
#include <stdbool.h>
extern
int
parse_idmaps
(
const
char
*
idmap
,
char
*
type
,
unsigned
long
*
nsid
,
unsigned
long
*
hostid
,
unsigned
long
*
range
);
extern
bool
lxc_config_value_empty
(
const
char
*
value
);
#endif
/* __LXC_CONFILE_UTILS_H */
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