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
2ea2f3c8
Unverified
Commit
2ea2f3c8
authored
Jul 24, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Aug 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsync: add new rsync functions
We will fade out the old helpers soon. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
8608cb0b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
lxcrsync.c
src/lxc/bdev/lxcrsync.c
+79
-0
lxcrsync.h
src/lxc/bdev/lxcrsync.h
+5
-0
No files found.
src/lxc/bdev/lxcrsync.c
View file @
2ea2f3c8
...
@@ -139,3 +139,82 @@ int rsync_rootfs_wrapper(void *data)
...
@@ -139,3 +139,82 @@ int rsync_rootfs_wrapper(void *data)
struct
rsync_data
*
arg
=
data
;
struct
rsync_data
*
arg
=
data
;
return
rsync_rootfs
(
arg
);
return
rsync_rootfs
(
arg
);
}
}
/* new helpers */
int
lxc_rsync_exec_wrapper
(
void
*
data
)
{
struct
rsync_data
*
arg
=
data
;
return
lxc_rsync
(
arg
);
}
int
lxc_rsync_exec
(
const
char
*
src
,
const
char
*
dest
)
{
int
ret
;
size_t
l
;
char
*
s
;
l
=
strlen
(
src
)
+
2
;
s
=
malloc
(
l
);
if
(
!
s
)
return
-
1
;
ret
=
snprintf
(
s
,
l
,
"%s"
,
src
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
l
)
return
-
1
;
s
[
l
-
2
]
=
'/'
;
s
[
l
-
1
]
=
'\0'
;
execlp
(
"rsync"
,
"rsync"
,
"-aHXS"
,
"--delete"
,
s
,
dest
,
(
char
*
)
NULL
);
return
-
1
;
}
int
lxc_rsync
(
struct
rsync_data
*
data
)
{
int
ret
;
struct
bdev
*
orig
=
data
->
orig
,
*
new
=
data
->
new
;
char
*
dest
,
*
src
;
ret
=
unshare
(
CLONE_NEWNS
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to unshare CLONE_NEWNS"
);
return
-
1
;
}
ret
=
detect_shared_rootfs
();
if
(
ret
)
{
ret
=
mount
(
NULL
,
"/"
,
NULL
,
MS_SLAVE
|
MS_REC
,
NULL
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to make
\"
/
\"
a slave mount"
);
}
ret
=
orig
->
ops
->
mount
(
orig
);
if
(
ret
<
0
)
{
ERROR
(
"Failed mounting
\"
%s
\"
on
\"
%s
\"
"
,
orig
->
src
,
orig
->
dest
);
return
-
1
;
}
ret
=
new
->
ops
->
mount
(
new
);
if
(
ret
<
0
)
{
ERROR
(
"Failed mounting
\"
%s
\"
onto
\"
%s
\"
"
,
new
->
src
,
new
->
dest
);
return
-
1
;
}
ret
=
lxc_switch_uid_gid
(
0
,
0
);
if
(
ret
<
0
)
return
-
1
;
ret
=
lxc_setgroups
(
0
,
NULL
);
if
(
ret
<
0
)
return
-
1
;
src
=
lxc_storage_get_path
(
orig
->
dest
,
orig
->
type
);
dest
=
lxc_storage_get_path
(
new
->
dest
,
new
->
type
);
ret
=
lxc_rsync_exec
(
src
,
dest
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to rsync from
\"
%s
\"
into
\"
%s
\"
"
,
src
,
dest
);
return
-
1
;
}
return
0
;
}
src/lxc/bdev/lxcrsync.h
View file @
2ea2f3c8
...
@@ -43,4 +43,9 @@ int rsync_delta(struct rsync_data_char *data);
...
@@ -43,4 +43,9 @@ int rsync_delta(struct rsync_data_char *data);
int
rsync_rootfs
(
struct
rsync_data
*
data
);
int
rsync_rootfs
(
struct
rsync_data
*
data
);
int
rsync_rootfs_wrapper
(
void
*
data
);
int
rsync_rootfs_wrapper
(
void
*
data
);
/* new helpers */
extern
int
lxc_rsync_exec_wrapper
(
void
*
data
);
extern
int
lxc_rsync_exec
(
const
char
*
src
,
const
char
*
dest
);
extern
int
lxc_rsync
(
struct
rsync_data
*
data
);
#endif // __LXC_RSYNC_H
#endif // __LXC_RSYNC_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