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
79f4b264
Unverified
Commit
79f4b264
authored
Jul 29, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsync: remove obsolete helpers
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
07db51a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
112 deletions
+38
-112
aufs.c
src/lxc/storage/aufs.c
+35
-3
lvm.c
src/lxc/storage/lvm.c
+3
-2
rsync.c
src/lxc/storage/rsync.c
+0
-101
rsync.h
src/lxc/storage/rsync.h
+0
-6
No files found.
src/lxc/storage/aufs.c
View file @
79f4b264
...
@@ -40,11 +40,41 @@ lxc_log_define(aufs, lxc);
...
@@ -40,11 +40,41 @@ lxc_log_define(aufs, lxc);
extern
char
*
dir_new_path
(
char
*
src
,
const
char
*
oldname
,
const
char
*
name
,
extern
char
*
dir_new_path
(
char
*
src
,
const
char
*
oldname
,
const
char
*
name
,
const
char
*
oldpath
,
const
char
*
lxcpath
);
const
char
*
oldpath
,
const
char
*
lxcpath
);
int
lxc_rsync_delta
(
struct
rsync_data_char
*
data
)
{
int
ret
;
ret
=
lxc_switch_uid_gid
(
0
,
0
);
if
(
ret
<
0
)
return
-
1
;
ret
=
lxc_setgroups
(
0
,
NULL
);
if
(
ret
<
0
)
return
-
1
;
ret
=
lxc_rsync_exec
(
data
->
src
,
data
->
dest
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to rsync from
\"
%s
\"
into
\"
%s
\"
"
,
data
->
src
,
data
->
dest
);
return
-
1
;
}
return
0
;
}
int
lxc_rsync_delta_wrapper
(
void
*
data
)
{
struct
rsync_data_char
*
arg
=
data
;
return
lxc_rsync_delta
(
arg
);
}
int
aufs_clonepaths
(
struct
lxc_storage
*
orig
,
struct
lxc_storage
*
new
,
int
aufs_clonepaths
(
struct
lxc_storage
*
orig
,
struct
lxc_storage
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
struct
lxc_conf
*
conf
)
{
{
char
cmd_output
[
MAXPATHLEN
];
if
(
!
snap
)
{
if
(
!
snap
)
{
ERROR
(
"aufs is only for snapshot clones"
);
ERROR
(
"aufs is only for snapshot clones"
);
return
-
22
;
return
-
22
;
...
@@ -134,10 +164,12 @@ int aufs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -134,10 +164,12 @@ int aufs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
rdata
.
src
=
odelta
;
rdata
.
src
=
odelta
;
rdata
.
dest
=
ndelta
;
rdata
.
dest
=
ndelta
;
if
(
am_unpriv
())
if
(
am_unpriv
())
ret
=
userns_exec_1
(
conf
,
rsync_delta_wrapper
,
&
rdata
,
ret
=
userns_exec_1
(
conf
,
lxc_rsync_delta_wrapper
,
"
rsync_delta_wrapper"
);
&
rdata
,
"lxc_
rsync_delta_wrapper"
);
else
else
ret
=
rsync_delta
(
&
rdata
);
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
lxc_rsync_delta_wrapper
,
(
void
*
)
&
rdata
);
if
(
ret
)
{
if
(
ret
)
{
free
(
osrc
);
free
(
osrc
);
free
(
ndelta
);
free
(
ndelta
);
...
...
src/lxc/storage/lvm.c
View file @
79f4b264
...
@@ -464,7 +464,7 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
...
@@ -464,7 +464,7 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
int
ret
;
int
ret
;
struct
rsync_data
data
;
struct
rsync_data
data
;
char
*
cmd_args
[
2
];
char
*
cmd_args
[
2
];
char
cmd_output
[
MAXPATHLEN
];
char
cmd_output
[
MAXPATHLEN
]
=
{
0
}
;
char
fstype
[
100
]
=
"ext4"
;
char
fstype
[
100
]
=
"ext4"
;
uint64_t
size
=
newsize
;
uint64_t
size
=
newsize
;
...
@@ -506,7 +506,8 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
...
@@ -506,7 +506,8 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
data
.
orig
=
orig
;
data
.
orig
=
orig
;
data
.
new
=
new
;
data
.
new
=
new
;
ret
=
rsync_rootfs
(
&
data
);
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
lxc_rsync_exec_wrapper
,
(
void
*
)
&
data
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to rsync from
\"
%s
\"
to
\"
%s
\"
"
,
orig
->
dest
,
ERROR
(
"Failed to rsync from
\"
%s
\"
to
\"
%s
\"
"
,
orig
->
dest
,
new
->
dest
);
new
->
dest
);
...
...
src/lxc/storage/rsync.c
View file @
79f4b264
...
@@ -39,107 +39,6 @@
...
@@ -39,107 +39,6 @@
lxc_log_define
(
rsync
,
lxc
);
lxc_log_define
(
rsync
,
lxc
);
/* the bulk of this needs to become a common helper */
int
do_rsync
(
const
char
*
src
,
const
char
*
dest
)
{
// call out to rsync
pid_t
pid
;
char
*
s
;
size_t
l
;
pid
=
fork
();
if
(
pid
<
0
)
return
-
1
;
if
(
pid
>
0
)
return
wait_for_pid
(
pid
);
l
=
strlen
(
src
)
+
2
;
s
=
malloc
(
l
);
if
(
!
s
)
exit
(
1
);
strcpy
(
s
,
src
);
s
[
l
-
2
]
=
'/'
;
s
[
l
-
1
]
=
'\0'
;
execlp
(
"rsync"
,
"rsync"
,
"-aHXS"
,
"--delete"
,
s
,
dest
,
(
char
*
)
NULL
);
exit
(
1
);
}
int
rsync_delta
(
struct
rsync_data_char
*
data
)
{
if
(
setgid
(
0
)
<
0
)
{
ERROR
(
"Failed to setgid to 0"
);
return
-
1
;
}
if
(
setgroups
(
0
,
NULL
)
<
0
)
WARN
(
"Failed to clear groups"
);
if
(
setuid
(
0
)
<
0
)
{
ERROR
(
"Failed to setuid to 0"
);
return
-
1
;
}
if
(
do_rsync
(
data
->
src
,
data
->
dest
)
<
0
)
{
ERROR
(
"rsyncing %s to %s"
,
data
->
src
,
data
->
dest
);
return
-
1
;
}
return
0
;
}
int
rsync_delta_wrapper
(
void
*
data
)
{
struct
rsync_data_char
*
arg
=
data
;
return
rsync_delta
(
arg
);
}
int
rsync_rootfs
(
struct
rsync_data
*
data
)
{
struct
lxc_storage
*
orig
=
data
->
orig
,
*
new
=
data
->
new
;
if
(
unshare
(
CLONE_NEWNS
)
<
0
)
{
SYSERROR
(
"unshare CLONE_NEWNS"
);
return
-
1
;
}
if
(
detect_shared_rootfs
())
{
if
(
mount
(
NULL
,
"/"
,
NULL
,
MS_SLAVE
|
MS_REC
,
NULL
))
{
SYSERROR
(
"Failed to make / rslave"
);
ERROR
(
"Continuing..."
);
}
}
// If not a snapshot, copy the fs.
if
(
orig
->
ops
->
mount
(
orig
)
<
0
)
{
ERROR
(
"failed mounting %s onto %s"
,
orig
->
src
,
orig
->
dest
);
return
-
1
;
}
if
(
new
->
ops
->
mount
(
new
)
<
0
)
{
ERROR
(
"failed mounting %s onto %s"
,
new
->
src
,
new
->
dest
);
return
-
1
;
}
if
(
setgid
(
0
)
<
0
)
{
ERROR
(
"Failed to setgid to 0"
);
return
-
1
;
}
if
(
setgroups
(
0
,
NULL
)
<
0
)
WARN
(
"Failed to clear groups"
);
if
(
setuid
(
0
)
<
0
)
{
ERROR
(
"Failed to setuid to 0"
);
return
-
1
;
}
if
(
do_rsync
(
orig
->
dest
,
new
->
dest
)
<
0
)
{
ERROR
(
"rsyncing %s to %s"
,
orig
->
src
,
new
->
src
);
return
-
1
;
}
return
0
;
}
int
rsync_rootfs_wrapper
(
void
*
data
)
{
struct
rsync_data
*
arg
=
data
;
return
rsync_rootfs
(
arg
);
}
/* new helpers */
int
lxc_rsync_exec_wrapper
(
void
*
data
)
int
lxc_rsync_exec_wrapper
(
void
*
data
)
{
{
struct
rsync_data
*
arg
=
data
;
struct
rsync_data
*
arg
=
data
;
...
...
src/lxc/storage/rsync.h
View file @
79f4b264
...
@@ -37,12 +37,6 @@ struct rsync_data_char {
...
@@ -37,12 +37,6 @@ struct rsync_data_char {
char
*
dest
;
char
*
dest
;
};
};
int
do_rsync
(
const
char
*
src
,
const
char
*
dest
);
int
rsync_delta_wrapper
(
void
*
data
);
int
rsync_delta
(
struct
rsync_data_char
*
data
);
int
rsync_rootfs
(
struct
rsync_data
*
data
);
int
rsync_rootfs_wrapper
(
void
*
data
);
/* new helpers */
/* new helpers */
extern
int
lxc_rsync_exec_wrapper
(
void
*
data
);
extern
int
lxc_rsync_exec_wrapper
(
void
*
data
);
extern
int
lxc_rsync_exec
(
const
char
*
src
,
const
char
*
dest
);
extern
int
lxc_rsync_exec
(
const
char
*
src
,
const
char
*
dest
);
...
...
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