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
8e295bc1
Unverified
Commit
8e295bc1
authored
Jul 16, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Aug 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
btrfs: non-functional changes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2d66f571
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
bdev.c
src/lxc/bdev/bdev.c
+16
-19
No files found.
src/lxc/bdev/bdev.c
View file @
8e295bc1
...
@@ -322,16 +322,15 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -322,16 +322,15 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
/* if the container name doesn't show up in the rootfs path, then
/* if the container name doesn't show up in the rootfs path, then
* we 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
)
==
NULL
)
{
if
(
!
strstr
(
src
,
oldname
))
{
ERROR
(
ERROR
(
"original rootfs path %s doesn't include container name %s"
,
"original rootfs path %s doesn't include container name %s"
,
src
,
oldname
);
src
,
oldname
);
return
NULL
;
return
NULL
;
}
}
orig
=
bdev_init
(
c0
->
lxc_conf
,
src
,
NULL
,
NULL
);
orig
=
bdev_init
(
c0
->
lxc_conf
,
src
,
NULL
,
NULL
);
if
(
!
orig
)
{
if
(
!
orig
)
{
ERROR
(
"
failed to detect blockdev type for %s
"
,
src
);
ERROR
(
"
Failed to detect storage driver for
\"
%s
\"
"
,
src
);
return
NULL
;
return
NULL
;
}
}
...
@@ -343,14 +342,14 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -343,14 +342,14 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
len
=
strlen
(
oldpath
)
+
strlen
(
oldname
)
+
strlen
(
"/rootfs"
)
+
2
;
len
=
strlen
(
oldpath
)
+
strlen
(
oldname
)
+
strlen
(
"/rootfs"
)
+
2
;
orig
->
dest
=
malloc
(
len
);
orig
->
dest
=
malloc
(
len
);
if
(
!
orig
->
dest
)
{
if
(
!
orig
->
dest
)
{
ERROR
(
"
out of
memory"
);
ERROR
(
"
Failed to allocate
memory"
);
bdev_put
(
orig
);
bdev_put
(
orig
);
return
NULL
;
return
NULL
;
}
}
ret
=
snprintf
(
orig
->
dest
,
len
,
"%s/%s/rootfs"
,
oldpath
,
oldname
);
ret
=
snprintf
(
orig
->
dest
,
len
,
"%s/%s/rootfs"
,
oldpath
,
oldname
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
{
ERROR
(
"
rootfs path too lo
ng"
);
ERROR
(
"
Failed to create stri
ng"
);
bdev_put
(
orig
);
bdev_put
(
orig
);
return
NULL
;
return
NULL
;
}
}
...
@@ -358,14 +357,13 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -358,14 +357,13 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
if
(
ret
<
0
&&
errno
==
ENOENT
)
if
(
ret
<
0
&&
errno
==
ENOENT
)
if
(
mkdir_p
(
orig
->
dest
,
0755
)
<
0
)
if
(
mkdir_p
(
orig
->
dest
,
0755
)
<
0
)
WARN
(
"
Error creating '%s', continuing.
"
,
WARN
(
"
Failed to create directoy
\"
%s
\"
"
,
orig
->
dest
);
orig
->
dest
);
}
}
/*
/* Special case for snapshot. If the caller requested maybe_snapshot and
* special case for snapshot - if caller requested maybe_snapshot and
* keepbdevtype and the backing store is directory, then proceed with a
* keepbdevtype and backing store is directory, then proceed with a copy
* a copy clone rather than returning error.
* clone rather than returning error
*/
*/
if
(
maybe_snap
&&
keepbdevtype
&&
!
bdevtype
&&
!
orig
->
ops
->
can_snapshot
)
if
(
maybe_snap
&&
keepbdevtype
&&
!
bdevtype
&&
!
orig
->
ops
->
can_snapshot
)
snap
=
false
;
snap
=
false
;
...
@@ -410,7 +408,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -410,7 +408,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
if
(
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
)
<
0
)
{
snap
,
newsize
,
c0
->
lxc_conf
)
<
0
)
{
ERROR
(
"
failed getting pathnames for cloned storage: %s
"
,
src
);
ERROR
(
"
Failed getting pathnames for clone of
\"
%s
\"
"
,
src
);
goto
err
;
goto
err
;
}
}
...
@@ -424,10 +422,9 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -424,10 +422,9 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
if
(
snap
)
if
(
snap
)
return
new
;
return
new
;
/*
/* https://github.com/lxc/lxc/issues/131
* https://github.com/lxc/lxc/issues/131
* Use btrfs snapshot feature instead of rsync to restore if both orig
* Use btrfs snapshot feature instead of rsync to restore if both orig
* and new are btrfs
* and new are btrfs
.
*/
*/
if
(
bdevtype
&&
strcmp
(
orig
->
type
,
"btrfs"
)
==
0
&&
if
(
bdevtype
&&
strcmp
(
orig
->
type
,
"btrfs"
)
==
0
&&
strcmp
(
new
->
type
,
"btrfs"
)
==
0
&&
strcmp
(
new
->
type
,
"btrfs"
)
==
0
&&
...
@@ -435,12 +432,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -435,12 +432,12 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
struct
rsync_data_char
arg
;
struct
rsync_data_char
arg
;
if
(
btrfs_destroy
(
new
)
<
0
)
{
if
(
btrfs_destroy
(
new
)
<
0
)
{
ERROR
(
"
Error destroying %
s subvolume"
,
new
->
dest
);
ERROR
(
"
Failed to destroy
\"
%s
\"
btrf
s subvolume"
,
new
->
dest
);
goto
err
;
goto
err
;
}
}
if
(
mkdir_p
(
new
->
dest
,
0755
)
<
0
)
{
if
(
mkdir_p
(
new
->
dest
,
0755
)
<
0
)
{
ERROR
(
"
Error creating %s directory
"
,
new
->
dest
);
ERROR
(
"
Failed to create directory
\"
%s
\"
"
,
new
->
dest
);
goto
err
;
goto
err
;
}
}
...
@@ -484,7 +481,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
...
@@ -484,7 +481,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
else
else
ret
=
rsync_rootfs
(
&
data
);
ret
=
rsync_rootfs
(
&
data
);
if
(
ret
<
0
)
if
(
ret
<
0
)
ERROR
(
"Failed to rsync"
);
ERROR
(
"Failed to rsync
from
"
);
exit
(
ret
==
0
?
0
:
1
);
exit
(
ret
==
0
?
0
:
1
);
...
...
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