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
ce9ed7c0
Commit
ce9ed7c0
authored
Jun 29, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: lxc-snapshot: share internal API symbols
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
4888c731
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
22 deletions
+28
-22
Makefile.am
src/lxc/Makefile.am
+1
-1
lxc_snapshot.c
src/lxc/tools/lxc_snapshot.c
+27
-21
No files found.
src/lxc/Makefile.am
View file @
ce9ed7c0
...
...
@@ -285,7 +285,7 @@ lxc_unfreeze_SOURCES = tools/lxc_unfreeze.c tools/arguments.c
lxc_unshare_SOURCES
=
tools/lxc_unshare.c tools/arguments.c
lxc_wait_SOURCES
=
tools/lxc_wait.c tools/arguments.c
lxc_create_SOURCES
=
tools/lxc_create.c tools/arguments.c tools/tool_utils.c
lxc_snapshot_SOURCES
=
tools/lxc_snapshot.c tools/arguments.c
tools/tool_utils.c
lxc_snapshot_SOURCES
=
tools/lxc_snapshot.c tools/arguments.c
lxc_checkpoint_SOURCES
=
tools/lxc_checkpoint.c tools/arguments.c
endif
...
...
src/lxc/tools/lxc_snapshot.c
View file @
ce9ed7c0
...
...
@@ -30,7 +30,9 @@
#include <lxc/lxccontainer.h>
#include "arguments.h"
#include "tool_utils.h"
#include "log.h"
lxc_log_define
(
lxc_snapshot
,
lxc
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
...
...
@@ -99,42 +101,42 @@ int main(int argc, char *argv[])
if
(
geteuid
())
{
if
(
access
(
my_args
.
lxcpath
[
0
],
O_RDONLY
)
<
0
)
{
fprintf
(
stderr
,
"You lack access to %s
\n
"
,
my_args
.
lxcpath
[
0
]);
ERROR
(
"You lack access to %s"
,
my_args
.
lxcpath
[
0
]);
exit
(
EXIT_FAILURE
);
}
}
c
=
lxc_container_new
(
my_args
.
name
,
my_args
.
lxcpath
[
0
]);
if
(
!
c
)
{
fprintf
(
stderr
,
"System error loading container
\n
"
);
ERROR
(
"System error loading container
"
);
exit
(
EXIT_FAILURE
);
}
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
ERROR
(
"Failed to load rcfile
"
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
ERROR
(
"Out of memory setting new config filename
"
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
lxc_conf
)
{
fprintf
(
stderr
,
"No container config specified
\n
"
);
ERROR
(
"No container config specified
"
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
}
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s
\n
"
,
my_args
.
name
);
ERROR
(
"Insufficent privileges to control %s"
,
my_args
.
name
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -145,6 +147,7 @@ int main(int argc, char *argv[])
if
(
ret
==
0
)
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -207,7 +210,7 @@ static int do_snapshot(struct lxc_container *c, char *commentfile)
ret
=
c
->
snapshot
(
c
,
commentfile
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error creating a snapshot
\n
"
);
ERROR
(
"Error creating a snapshot
"
);
return
-
1
;
}
...
...
@@ -218,13 +221,13 @@ static int do_snapshot_destroy(struct lxc_container *c, char *snapname)
{
bool
ret
;
if
(
strcmp
(
snapname
,
"ALL"
)
==
0
)
if
(
!
strncmp
(
snapname
,
"ALL"
,
strlen
(
snapname
))
)
ret
=
c
->
snapshot_destroy_all
(
c
);
else
ret
=
c
->
snapshot_destroy
(
c
,
snapname
);
if
(
!
ret
)
{
fprintf
(
stderr
,
"Error destroying snapshot %s
\n
"
,
snapname
);
ERROR
(
"Error destroying snapshot %s
"
,
snapname
);
return
-
1
;
}
...
...
@@ -238,9 +241,10 @@ static int do_snapshot_list(struct lxc_container *c, int print_comments)
n
=
c
->
snapshot_list
(
c
,
&
s
);
if
(
n
<
0
)
{
fprintf
(
stderr
,
"Error listing snapshots
\n
"
);
ERROR
(
"Error listing snapshots
"
);
return
-
1
;
}
if
(
n
==
0
)
{
printf
(
"No snapshots
\n
"
);
return
0
;
...
...
@@ -248,8 +252,10 @@ static int do_snapshot_list(struct lxc_container *c, int print_comments)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
printf
(
"%s (%s) %s
\n
"
,
s
[
i
].
name
,
s
[
i
].
lxcpath
,
s
[
i
].
timestamp
);
if
(
print_comments
)
print_file
(
s
[
i
].
comment_pathname
);
s
[
i
].
free
(
&
s
[
i
]);
}
...
...
@@ -269,7 +275,7 @@ static int do_snapshot_restore(struct lxc_container *c,
* original container will be destroyed and the restored container will
* take its place. */
if
((
!
args
->
newname
)
&&
(
args
->
argc
>
1
))
{
lxc_error
(
args
,
"Too many arguments"
);
ERROR
(
"Too many arguments"
);
return
-
1
;
}
...
...
@@ -278,7 +284,7 @@ static int do_snapshot_restore(struct lxc_container *c,
bret
=
c
->
snapshot_restore
(
c
,
args
->
snapname
,
args
->
newname
);
if
(
!
bret
)
{
fprintf
(
stderr
,
"Error restoring snapshot %s
\n
"
,
args
->
snapname
);
ERROR
(
"Error restoring snapshot %s
"
,
args
->
snapname
);
return
-
1
;
}
...
...
@@ -287,19 +293,19 @@ static int do_snapshot_restore(struct lxc_container *c,
static
void
print_file
(
char
*
path
)
{
if
(
!
path
)
return
;
FILE
*
f
=
fopen
(
path
,
"r"
);
FILE
*
f
;
char
*
line
=
NULL
;
size_t
sz
=
0
;
if
(
!
path
)
return
;
f
=
fopen
(
path
,
"r"
);
if
(
!
f
)
return
;
while
(
getline
(
&
line
,
&
sz
,
f
)
!=
-
1
)
{
while
(
getline
(
&
line
,
&
sz
,
f
)
!=
-
1
)
printf
(
"%s"
,
line
);
}
free
(
line
);
fclose
(
f
);
...
...
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