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
d685aa80
Commit
d685aa80
authored
Oct 12, 2009
by
Daniel Lezcano
Committed by
Daniel Lezcano
Oct 12, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up and factor out some code
Factor out some code and fix a memory corruption when dupping the arguments. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
a059591e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
19 additions
and
27 deletions
+19
-27
arguments.c
src/lxc/arguments.c
+1
-1
conf.c
src/lxc/conf.c
+0
-1
conf.h
src/lxc/conf.h
+0
-1
confile.c
src/lxc/confile.c
+0
-2
create.c
src/lxc/create.c
+7
-3
lxc.h
src/lxc/lxc.h
+1
-1
lxc_create.c
src/lxc/lxc_create.c
+1
-1
lxc_execute.c
src/lxc/lxc_execute.c
+2
-8
start.c
src/lxc/start.c
+5
-7
confile.c
test/confile.c
+1
-1
lxc_create.c
test/lxc_create.c
+1
-1
No files found.
src/lxc/arguments.c
View file @
d685aa80
...
...
@@ -214,7 +214,7 @@ extern char **lxc_arguments_dup(const char *file, struct lxc_arguments *args)
if
(
args
->
quiet
)
nbargs
+=
1
;
argv
=
malloc
(
nbargs
*
sizeof
(
*
argv
));
argv
=
malloc
(
(
nbargs
+
1
)
*
sizeof
(
*
argv
));
if
(
!
argv
)
return
NULL
;
...
...
src/lxc/conf.c
View file @
d685aa80
...
...
@@ -917,7 +917,6 @@ out:
int
lxc_conf_init
(
struct
lxc_conf
*
conf
)
{
conf
->
rcfile
=
NULL
;
conf
->
rootfs
=
NULL
;
conf
->
fstab
=
NULL
;
conf
->
utsname
=
NULL
;
...
...
src/lxc/conf.h
View file @
d685aa80
...
...
@@ -129,7 +129,6 @@ struct lxc_tty_info {
* @utsname : the container utsname
*/
struct
lxc_conf
{
const
char
*
rcfile
;
char
*
rootfs
;
char
*
fstab
;
int
tty
;
...
...
src/lxc/confile.c
View file @
d685aa80
...
...
@@ -538,8 +538,6 @@ int lxc_config_read(const char *file, struct lxc_conf *conf)
{
char
buffer
[
MAXPATHLEN
];
conf
->
rcfile
=
file
;
return
lxc_file_for_each_line
(
file
,
parse_line
,
buffer
,
sizeof
(
buffer
),
conf
);
}
src/lxc/create.c
View file @
d685aa80
...
...
@@ -101,7 +101,7 @@ static int remove_lxc_directory(const char *dirname)
static
int
copy_config_file
(
const
char
*
name
,
const
char
*
file
)
{
char
*
dst
;
int
ret
;
int
ret
=
-
1
;
if
(
!
asprintf
(
&
dst
,
LXCPATH
"/%s/config"
,
name
))
{
ERROR
(
"failed to allocate memory"
);
...
...
@@ -111,23 +111,27 @@ static int copy_config_file(const char *name, const char *file)
ret
=
lxc_copy_file
(
file
,
dst
);
if
(
ret
)
ERROR
(
"failed to copy '%s' to '%s'"
,
file
,
dst
);
free
(
dst
);
return
ret
;
}
int
lxc_create
(
const
char
*
name
,
struct
lxc_conf
*
conf
)
int
lxc_create
(
const
char
*
name
,
const
char
*
confile
)
{
int
lock
,
err
=
-
1
;
if
(
create_lxc_directory
(
name
))
return
err
;
if
(
!
confile
)
return
0
;
lock
=
lxc_get_lock
(
name
);
if
(
lock
<
0
)
goto
err
;
if
(
co
nf
->
rcfile
&&
copy_config_file
(
name
,
conf
->
rc
file
))
{
if
(
co
py_config_file
(
name
,
con
file
))
{
ERROR
(
"failed to copy the configuration file"
);
goto
err_state
;
}
...
...
src/lxc/lxc.h
View file @
d685aa80
...
...
@@ -54,7 +54,7 @@ extern "C" {
* @conf : the configuration data for the container
* Returns 0 on success, < 0 otherwise
*/
extern
int
lxc_create
(
const
char
*
name
,
struct
lxc_conf
*
conf
);
extern
int
lxc_create
(
const
char
*
name
,
const
char
*
confile
);
/*
* Destroy the container object. Removes the files into the /lxc/<name>
...
...
src/lxc/lxc_create.c
View file @
d685aa80
...
...
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
return
-
1
;
}
if
(
lxc_create
(
my_args
.
name
,
&
lxc_conf
))
{
if
(
lxc_create
(
my_args
.
name
,
my_args
.
rcfile
))
{
ERROR
(
"failed to create the container"
);
return
-
1
;
}
...
...
src/lxc/lxc_execute.c
View file @
d685aa80
...
...
@@ -81,7 +81,6 @@ int main(int argc, char *argv[])
char
path
[
MAXPATHLEN
];
int
autodestroy
=
0
;
int
ret
=
-
1
;
struct
lxc_conf
lxc_conf
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
goto
out
;
...
...
@@ -90,15 +89,10 @@ int main(int argc, char *argv[])
my_args
.
progname
,
my_args
.
quiet
))
goto
out
;
if
(
lxc_conf_init
(
&
lxc_conf
))
goto
out
;
if
(
my_args
.
rcfile
&&
lxc_config_read
(
my_args
.
rcfile
,
&
lxc_conf
))
goto
out
;
/* the container is not created, let's create it */
snprintf
(
path
,
MAXPATHLEN
,
LXCPATH
"/%s"
,
my_args
.
name
);
if
(
access
(
path
,
R_OK
))
{
if
(
lxc_create
(
my_args
.
name
,
&
lxc_conf
))
if
(
lxc_create
(
my_args
.
name
,
my_args
.
rcfile
))
goto
out
;
autodestroy
=
1
;
}
...
...
src/lxc/start.c
View file @
d685aa80
...
...
@@ -263,15 +263,13 @@ struct lxc_handler *lxc_init(const char *name)
snprintf
(
path
,
sizeof
(
path
),
LXCPATH
"/%s/config"
,
name
);
if
(
!
access
(
path
,
F_OK
))
{
if
(
lxc_config_read
(
path
,
&
handler
->
conf
))
{
ERROR
(
"failed to read the configuration file"
);
goto
out_aborting
;
}
if
(
!
access
(
path
,
F_OK
)
&&
lxc_config_read
(
path
,
&
handler
->
conf
))
{
ERROR
(
"failed to read the configuration file"
);
goto
out_aborting
;
}
if
(
console_init
(
handler
->
conf
.
console
,
sizeof
(
handler
->
conf
.
console
)))
{
if
(
console_init
(
handler
->
conf
.
console
,
sizeof
(
handler
->
conf
.
console
)))
{
ERROR
(
"failed to initialize the console"
);
goto
out_aborting
;
}
...
...
test/confile.c
View file @
d685aa80
...
...
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
return
1
;
}
if
(
lxc_create
(
name
,
&
lxc_conf
))
{
if
(
lxc_create
(
name
,
file
))
{
fprintf
(
stderr
,
"failed to create <%s>
\n
"
,
name
);
return
1
;
}
...
...
test/lxc_create.c
View file @
d685aa80
...
...
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
lxc_conf_init
(
&
lxc_conf
);
if
(
lxc_create
(
name
,
&
lxc_conf
))
{
if
(
lxc_create
(
name
,
NULL
))
{
fprintf
(
stderr
,
"failed to create the container %s
\n
"
,
name
);
return
1
;
}
...
...
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