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
01f8fa2f
Unverified
Commit
01f8fa2f
authored
Aug 15, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "bdev: non-functional changes"
This reverts commit
8608cb0b
. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
bafd3a1f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
29 deletions
+25
-29
bdev.c
src/lxc/bdev/bdev.c
+25
-29
No files found.
src/lxc/bdev/bdev.c
View file @
01f8fa2f
...
@@ -337,12 +337,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -337,12 +337,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
const
char
*
oldpath
=
c0
->
config_path
;
const
char
*
oldpath
=
c0
->
config_path
;
struct
rsync_data
data
;
struct
rsync_data
data
;
/*
If the container name doesn't show up in the rootfs path, then we
/*
if the container name doesn't show up in the rootfs path, then
*
don't know how to come up with a new name.
*
we don't know how to come up with a new name
*/
*/
if
(
!
strstr
(
src
,
oldname
))
{
if
(
!
strstr
(
src
,
oldname
))
{
ERROR
(
"
Original rootfs path
\"
%s
\"
does not include container "
ERROR
(
"
original rootfs path %s doesn't include container name %s"
,
"name
\"
%s
\"
"
,
src
,
oldname
);
src
,
oldname
);
return
NULL
;
return
NULL
;
}
}
...
@@ -371,13 +371,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -371,13 +371,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
bdev_put
(
orig
);
bdev_put
(
orig
);
return
NULL
;
return
NULL
;
}
}
ret
=
stat
(
orig
->
dest
,
&
sb
);
ret
=
stat
(
orig
->
dest
,
&
sb
);
if
(
ret
<
0
&&
errno
==
ENOENT
)
{
ret
=
mkdir_p
(
orig
->
dest
,
0755
);
if
(
ret
<
0
&&
errno
==
ENOENT
)
if
(
ret
<
0
)
if
(
mkdir_p
(
orig
->
dest
,
0755
)
<
0
)
WARN
(
"Failed to create directoy
\"
%s
\"
"
,
orig
->
dest
);
WARN
(
"Failed to create directoy
\"
%s
\"
"
,
}
orig
->
dest
);
}
}
/* Special case for snapshot. If the caller requested maybe_snapshot and
/* Special case for snapshot. If the caller requested maybe_snapshot and
...
@@ -387,8 +386,11 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -387,8 +386,11 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
if
(
maybe_snap
&&
keepbdevtype
&&
!
bdevtype
&&
!
orig
->
ops
->
can_snapshot
)
if
(
maybe_snap
&&
keepbdevtype
&&
!
bdevtype
&&
!
orig
->
ops
->
can_snapshot
)
snap
=
false
;
snap
=
false
;
/* If newtype is NULL and snapshot is set, then use overlay. */
/*
if
(
!
bdevtype
&&
!
keepbdevtype
&&
snap
&&
strcmp
(
orig
->
type
,
"dir"
)
==
0
)
* If newtype is NULL and snapshot is set, then use overlayfs
*/
if
(
!
bdevtype
&&
!
keepbdevtype
&&
snap
&&
strcmp
(
orig
->
type
,
"dir"
)
==
0
)
bdevtype
=
"overlay"
;
bdevtype
=
"overlay"
;
if
(
am_unpriv
()
&&
!
unpriv_snap_allowed
(
orig
,
bdevtype
,
snap
,
maybe_snap
))
{
if
(
am_unpriv
()
&&
!
unpriv_snap_allowed
(
orig
,
bdevtype
,
snap
,
maybe_snap
))
{
...
@@ -399,12 +401,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -399,12 +401,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
}
}
*
needs_rdep
=
0
;
*
needs_rdep
=
0
;
if
(
bdevtype
&&
!
strcmp
(
orig
->
type
,
"dir"
)
&&
if
(
bdevtype
&&
strcmp
(
orig
->
type
,
"dir"
)
==
0
&&
(
strcmp
(
bdevtype
,
"aufs"
)
==
0
||
(
strcmp
(
bdevtype
,
"aufs"
)
==
0
||
strcmp
(
bdevtype
,
"overlayfs"
)
==
0
||
strcmp
(
bdevtype
,
"overlayfs"
)
==
0
||
strcmp
(
bdevtype
,
"overlay"
)
==
0
))
{
strcmp
(
bdevtype
,
"overlay"
)
==
0
))
{
*
needs_rdep
=
1
;
*
needs_rdep
=
1
;
}
else
if
(
snap
&&
!
strcmp
(
orig
->
type
,
"lvm"
)
&&
}
else
if
(
snap
&&
strcmp
(
orig
->
type
,
"lvm"
)
==
0
&&
!
lvm_is_thin_volume
(
orig
->
src
))
{
!
lvm_is_thin_volume
(
orig
->
src
))
{
*
needs_rdep
=
1
;
*
needs_rdep
=
1
;
}
}
...
@@ -417,22 +419,20 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -417,22 +419,20 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
/* get new bdev type */
/* get new bdev type */
new
=
bdev_get
(
bdevtype
);
new
=
bdev_get
(
bdevtype
);
if
(
!
new
)
{
if
(
!
new
)
{
ERROR
(
"
Failed to initialize
\"
%s
\"
storage driver
"
,
ERROR
(
"
no such block device type: %s
"
,
bdevtype
?
bdevtype
:
orig
->
type
);
bdevtype
?
bdevtype
:
orig
->
type
);
bdev_put
(
orig
);
bdev_put
(
orig
);
return
NULL
;
return
NULL
;
}
}
TRACE
(
"
Initializ
ed
\"
%s
\"
storage driver"
,
new
->
type
);
TRACE
(
"
Detect
ed
\"
%s
\"
storage driver"
,
new
->
type
);
/* create new paths */
/* create new paths */
ret
=
new
->
ops
->
clone_paths
(
orig
,
new
,
oldname
,
cname
,
oldpath
,
lxcpath
,
if
(
new
->
ops
->
clone_paths
(
orig
,
new
,
oldname
,
cname
,
oldpath
,
lxcpath
,
snap
,
newsize
,
c0
->
lxc_conf
);
snap
,
newsize
,
c0
->
lxc_conf
)
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed getting pathnames for clone of
\"
%s
\"
"
,
src
);
ERROR
(
"Failed creating new paths for clone of
\"
%s
\"
"
,
src
);
goto
err
;
goto
err
;
}
}
/* btrfs */
if
(
!
strcmp
(
orig
->
type
,
"btrfs"
)
&&
!
strcmp
(
new
->
type
,
"btrfs"
))
{
if
(
!
strcmp
(
orig
->
type
,
"btrfs"
)
&&
!
strcmp
(
new
->
type
,
"btrfs"
))
{
bool
bret
=
false
;
bool
bret
=
false
;
if
(
snap
||
btrfs_same_fs
(
orig
->
dest
,
new
->
dest
)
==
0
)
if
(
snap
||
btrfs_same_fs
(
orig
->
dest
,
new
->
dest
)
==
0
)
...
@@ -444,7 +444,6 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -444,7 +444,6 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
return
new
;
return
new
;
}
}
/* lvm */
if
(
!
strcmp
(
orig
->
type
,
"lvm"
)
&&
!
strcmp
(
new
->
type
,
"lvm"
))
{
if
(
!
strcmp
(
orig
->
type
,
"lvm"
)
&&
!
strcmp
(
new
->
type
,
"lvm"
))
{
bool
bret
=
false
;
bool
bret
=
false
;
if
(
snap
)
if
(
snap
)
...
@@ -459,22 +458,19 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -459,22 +458,19 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
}
}
if
(
strcmp
(
bdevtype
,
"btrfs"
))
{
if
(
strcmp
(
bdevtype
,
"btrfs"
))
{
if
(
!
strcmp
(
new
->
type
,
"overlay"
)
||
!
strcmp
(
new
->
type
,
"overlayfs"
))
if
(
!
strcmp
(
new
->
type
,
"overlay"
)
||
!
strcmp
(
new
->
type
,
"overlayfs"
))
src_no_prefix
=
ovl_get_lower
(
new
->
src
);
src_no_prefix
=
ovl_get_lower
(
new
->
src
);
else
else
src_no_prefix
=
lxc_storage_get_path
(
new
->
src
,
new
->
type
);
src_no_prefix
=
lxc_storage_get_path
(
new
->
src
,
new
->
type
);
if
(
am_unpriv
())
{
if
(
am_unpriv
()
&&
chown_mapped_root
(
src_no_prefix
,
c0
->
lxc_conf
)
<
0
)
ret
=
chown_mapped_root
(
src_no_prefix
,
c0
->
lxc_conf
);
WARN
(
"Failed to chown
\"
%s
\"
"
,
src_no_prefix
);
if
(
ret
<
0
)
WARN
(
"Failed to chown
\"
%s
\"
"
,
new
->
src
);
}
}
}
if
(
snap
)
if
(
snap
)
return
new
;
return
new
;
/* rsync the contents from source to target */
pid
=
fork
();
pid
=
fork
();
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
SYSERROR
(
"fork"
);
SYSERROR
(
"fork"
);
...
...
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