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
d7efa8fc
Commit
d7efa8fc
authored
May 28, 2009
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy the configuration file in the conf repo
When creating the container, copy the configuration file to the configuration tree. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
4fcc0112
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
lxc_create.c
src/lxc/lxc_create.c
+19
-2
lxc_destroy.c
src/lxc/lxc_destroy.c
+32
-1
No files found.
src/lxc/lxc_create.c
View file @
d7efa8fc
...
@@ -20,9 +20,11 @@
...
@@ -20,9 +20,11 @@
* License along with this library; if not, write to the Free Software
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdio.h>
#include <libgen.h>
#include <libgen.h>
#include <unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/param.h>
#include <sys/utsname.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <sys/types.h>
...
@@ -67,7 +69,20 @@ Options :\n\
...
@@ -67,7 +69,20 @@ Options :\n\
static
int
copy_config_file
(
const
char
*
name
,
const
char
*
file
)
static
int
copy_config_file
(
const
char
*
name
,
const
char
*
file
)
{
{
return
0
;
char
*
src
;
int
ret
;
if
(
!
asprintf
(
&
src
,
LXCPATH
"/%s/config"
,
name
))
{
ERROR
(
"failed to allocate memory"
);
return
-
1
;
}
ret
=
lxc_copy_file
(
file
,
src
);
if
(
ret
)
ERROR
(
"failed to copy '%s' to '%s'"
,
file
,
src
);
free
(
src
);
return
ret
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
@@ -96,12 +111,14 @@ int main(int argc, char *argv[])
...
@@ -96,12 +111,14 @@ int main(int argc, char *argv[])
return
-
1
;
return
-
1
;
}
}
if
(
copy_config_file
(
my_args
.
name
,
my_args
.
rcfile
))
{
if
(
my_args
.
rcfile
&&
copy_config_file
(
my_args
.
name
,
my_args
.
rcfile
))
{
ERROR
(
"failed to copy the configuration file"
);
ERROR
(
"failed to copy the configuration file"
);
lxc_destroy
(
my_args
.
name
);
lxc_destroy
(
my_args
.
name
);
return
-
1
;
return
-
1
;
}
}
INFO
(
"'%s' created"
,
my_args
.
name
);
return
0
;
return
0
;
}
}
src/lxc/lxc_destroy.c
View file @
d7efa8fc
...
@@ -21,12 +21,15 @@
...
@@ -21,12 +21,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
#include <stdio.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/types.h>
#include <lxc/lxc.h>
#include <lxc/lxc.h>
#include "arguments.h"
#include "arguments.h"
lxc_log_define
(
lxc_destroy
,
lxc
);
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
};
};
...
@@ -45,6 +48,24 @@ Options :\n\
...
@@ -45,6 +48,24 @@ Options :\n\
.
checker
=
NULL
,
.
checker
=
NULL
,
};
};
static
int
remove_config_file
(
const
char
*
name
)
{
char
path
[
MAXPATHLEN
];
snprintf
(
path
,
MAXPATHLEN
,
LXCPATH
"/%s/config"
,
name
);
/* config file does not exists */
if
(
access
(
path
,
F_OK
))
return
0
;
if
(
unlink
(
path
))
{
ERROR
(
"failed to unlink '%s'"
,
path
);
return
-
1
;
}
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
...
@@ -54,6 +75,16 @@ int main(int argc, char *argv[])
...
@@ -54,6 +75,16 @@ int main(int argc, char *argv[])
my_args
.
progname
,
my_args
.
quiet
))
my_args
.
progname
,
my_args
.
quiet
))
return
-
1
;
return
-
1
;
return
lxc_destroy
(
my_args
.
name
);
if
(
remove_config_file
(
my_args
.
name
))
WARN
(
"failed to remove the configuration file"
);
if
(
lxc_destroy
(
my_args
.
name
))
{
ERROR
(
"failed to destroy the container"
);
return
-
1
;
}
INFO
(
"'%s' destroyed"
,
my_args
.
name
);
return
0
;
}
}
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