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
83e79752
Commit
83e79752
authored
Dec 13, 2015
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify naming for overlay types & functions
Use ovl_ as prefix for types and functions. Signed-off-by:
Christian Brauner
<
christian.brauner@mailbox.org
>
parent
4ec31c52
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
49 deletions
+47
-49
bdev.c
src/lxc/bdev/bdev.c
+8
-8
overlay.c
src/lxc/bdev/overlay.c
+23
-24
overlay.h
src/lxc/bdev/overlay.h
+13
-14
lxccontainer.c
src/lxc/lxccontainer.c
+3
-3
No files found.
src/lxc/bdev/bdev.c
View file @
83e79752
...
...
@@ -2349,13 +2349,13 @@ static int rsync_delta_wrapper(void *data)
}
/* overlay */
static
const
struct
bdev_ops
ov
erlayfs
_ops
=
{
.
detect
=
&
ov
erlayfs
_detect
,
.
mount
=
&
ov
erlayfs
_mount
,
.
umount
=
&
ov
erlayfs
_umount
,
.
clone_paths
=
&
ov
erlayfs
_clonepaths
,
.
destroy
=
&
ov
erlayfs
_destroy
,
.
create
=
&
ov
erlayfs
_create
,
static
const
struct
bdev_ops
ov
l
_ops
=
{
.
detect
=
&
ov
l
_detect
,
.
mount
=
&
ov
l
_mount
,
.
umount
=
&
ov
l
_umount
,
.
clone_paths
=
&
ov
l
_clonepaths
,
.
destroy
=
&
ov
l
_destroy
,
.
create
=
&
ov
l
_create
,
.
can_snapshot
=
true
,
.
can_backup
=
true
,
};
...
...
@@ -2963,7 +2963,7 @@ static const struct bdev_type bdevs[] = {
{.
name
=
"btrfs"
,
.
ops
=
&
btrfs_ops
,},
{.
name
=
"dir"
,
.
ops
=
&
dir_ops
,},
{.
name
=
"aufs"
,
.
ops
=
&
aufs_ops
,},
{.
name
=
"overlayfs"
,
.
ops
=
&
ov
erlayfs
_ops
,},
{.
name
=
"overlayfs"
,
.
ops
=
&
ov
l
_ops
,},
{.
name
=
"loop"
,
.
ops
=
&
loop_ops
,},
{.
name
=
"nbd"
,
.
ops
=
&
nbd_ops
,},
};
...
...
src/lxc/bdev/overlay.c
View file @
83e79752
...
...
@@ -49,7 +49,7 @@ extern int do_rsync(const char *src, const char *dest);
extern
char
*
dir_new_path
(
char
*
src
,
const
char
*
oldname
,
const
char
*
name
,
const
char
*
oldpath
,
const
char
*
lxcpath
);
char
*
ov
erlay
_getlower
(
char
*
p
)
char
*
ov
l
_getlower
(
char
*
p
)
{
char
*
p1
=
strchr
(
p
,
':'
);
if
(
p1
)
...
...
@@ -57,15 +57,15 @@ char *overlay_getlower(char *p)
return
p
;
}
int
ov
erlayfs
_detect
(
const
char
*
path
)
int
ov
l
_detect
(
const
char
*
path
)
{
if
(
strncmp
(
path
,
"overlayfs:"
,
10
)
==
0
)
return
1
;
// take their word for it
return
0
;
}
static
char
*
ov
erlayfs
_name
;
static
char
*
detect_overlayfs
_name
(
void
)
static
char
*
ov
l
_name
;
static
char
*
ovl_detect
_name
(
void
)
{
char
*
v
=
"overlayfs"
;
char
*
line
=
NULL
;
...
...
@@ -87,7 +87,7 @@ static char *detect_overlayfs_name(void)
}
/* XXXXXXX plain directory bind mount ops */
int
ov
erlayfs
_mount
(
struct
bdev
*
bdev
)
int
ov
l
_mount
(
struct
bdev
*
bdev
)
{
char
*
options
,
*
dup
,
*
lower
,
*
upper
;
char
*
options_work
,
*
work
,
*
lastslash
;
...
...
@@ -102,9 +102,8 @@ int overlayfs_mount(struct bdev *bdev)
if
(
!
bdev
->
src
||
!
bdev
->
dest
)
return
-
22
;
// defined in bdev.c
if
(
!
overlayfs_name
)
overlayfs_name
=
detect_overlayfs_name
();
if
(
!
ovl_name
)
ovl_name
=
ovl_detect_name
();
// separately mount it first
// mount -t overlayfs -oupperdir=${upper},lowerdir=${lower} lower dest
...
...
@@ -175,13 +174,13 @@ int overlayfs_mount(struct bdev *bdev)
}
// mount without workdir option for overlayfs before v21
ret
=
mount
(
lower
,
bdev
->
dest
,
ov
erlayfs
_name
,
MS_MGC_VAL
|
mntflags
,
options
);
ret
=
mount
(
lower
,
bdev
->
dest
,
ov
l
_name
,
MS_MGC_VAL
|
mntflags
,
options
);
if
(
ret
<
0
)
{
INFO
(
"overlayfs: error mounting %s onto %s options %s. retry with workdir"
,
lower
,
bdev
->
dest
,
options
);
// retry with workdir option for overlayfs v22 and higher
ret
=
mount
(
lower
,
bdev
->
dest
,
ov
erlayfs
_name
,
MS_MGC_VAL
|
mntflags
,
options_work
);
ret
=
mount
(
lower
,
bdev
->
dest
,
ov
l
_name
,
MS_MGC_VAL
|
mntflags
,
options_work
);
if
(
ret
<
0
)
SYSERROR
(
"overlayfs: error mounting %s onto %s options %s"
,
lower
,
bdev
->
dest
,
options_work
);
...
...
@@ -195,7 +194,7 @@ int overlayfs_mount(struct bdev *bdev)
return
ret
;
}
int
ov
erlayfs
_umount
(
struct
bdev
*
bdev
)
int
ov
l
_umount
(
struct
bdev
*
bdev
)
{
if
(
strcmp
(
bdev
->
type
,
"overlayfs"
))
return
-
22
;
...
...
@@ -229,18 +228,18 @@ static int ovl_rsync(struct ovl_rsync_data *data)
ERROR
(
"Continuing..."
);
}
}
if
(
ov
erlayfs
_mount
(
data
->
orig
)
<
0
)
{
if
(
ov
l
_mount
(
data
->
orig
)
<
0
)
{
ERROR
(
"Failed mounting original container fs"
);
return
-
1
;
}
if
(
ov
erlayfs
_mount
(
data
->
new
)
<
0
)
{
if
(
ov
l
_mount
(
data
->
new
)
<
0
)
{
ERROR
(
"Failed mounting new container fs"
);
return
-
1
;
}
ret
=
do_rsync
(
data
->
orig
->
dest
,
data
->
new
->
dest
);
ov
erlayfs
_umount
(
data
->
new
);
ov
erlayfs
_umount
(
data
->
orig
);
ov
l
_umount
(
data
->
new
);
ov
l
_umount
(
data
->
orig
);
if
(
ret
<
0
)
{
ERROR
(
"rsyncing %s to %s"
,
data
->
orig
->
dest
,
data
->
new
->
dest
);
...
...
@@ -273,9 +272,9 @@ static int ovl_do_rsync(struct bdev *orig, struct bdev *new, struct lxc_conf *co
return
ret
;
}
int
ov
erlayfs
_clonepaths
(
struct
bdev
*
orig
,
struct
bdev
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
int
ov
l
_clonepaths
(
struct
bdev
*
orig
,
struct
bdev
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
{
if
(
!
snap
)
{
ERROR
(
"overlayfs is only for snapshot clones"
);
...
...
@@ -425,7 +424,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam
}
else
{
ERROR
(
"overlayfs clone of %s container is not yet supported"
,
orig
->
type
);
// Note, supporting this will require ov
erlayfs
_mount supporting
// Note, supporting this will require ov
l
_mount supporting
// mounting of the underlay. No big deal, just needs to be done.
return
-
1
;
}
...
...
@@ -433,7 +432,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam
return
0
;
}
int
ov
erlayfs
_destroy
(
struct
bdev
*
orig
)
int
ov
l
_destroy
(
struct
bdev
*
orig
)
{
char
*
upper
;
...
...
@@ -452,7 +451,7 @@ int overlayfs_destroy(struct bdev *orig)
* changes after starting the container are written to
* $lxcpath/$lxcname/delta0
*/
int
ov
erlayfs
_create
(
struct
bdev
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
ov
l
_create
(
struct
bdev
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
{
char
*
delta
;
...
...
@@ -502,9 +501,9 @@ int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
* independent of each other since lxc_conf->mountlist may container more mount
* entries (e.g. from other included files) than lxc_conf->unexpanded_config .
*/
int
update_ovl
_paths
(
struct
lxc_conf
*
lxc_conf
,
const
char
*
lxc_path
,
const
char
*
lxc_name
,
const
char
*
newpath
,
const
char
*
newname
)
int
ovl_update_abs
_paths
(
struct
lxc_conf
*
lxc_conf
,
const
char
*
lxc_path
,
const
char
*
lxc_name
,
const
char
*
newpath
,
const
char
*
newname
)
{
char
new_upper
[
MAXPATHLEN
];
char
new_work
[
MAXPATHLEN
];
...
...
src/lxc/bdev/overlay.h
View file @
83e79752
...
...
@@ -38,16 +38,15 @@ struct bdev_specs;
/* defined conf.h */
struct
lxc_conf
;
int
overlayfs_detect
(
const
char
*
path
);
int
overlayfs_mount
(
struct
bdev
*
bdev
);
int
overlayfs_umount
(
struct
bdev
*
bdev
);
int
overlayfs_clonepaths
(
struct
bdev
*
orig
,
struct
bdev
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
int
overlayfs_destroy
(
struct
bdev
*
orig
);
int
overlayfs_create
(
struct
bdev
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
int
ovl_detect
(
const
char
*
path
);
int
ovl_mount
(
struct
bdev
*
bdev
);
int
ovl_umount
(
struct
bdev
*
bdev
);
int
ovl_clonepaths
(
struct
bdev
*
orig
,
struct
bdev
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
int
ovl_destroy
(
struct
bdev
*
orig
);
int
ovl_create
(
struct
bdev
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
/*
* To be called from lxcapi_clone() in lxccontainer.c: When we clone a container
...
...
@@ -57,14 +56,14 @@ int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
* independent of each other since lxc_conf->mountlist may container more mount
* entries (e.g. from other included files) than lxc_conf->unexpanded_config .
*/
int
update_ovl
_paths
(
struct
lxc_conf
*
lxc_conf
,
const
char
*
lxc_path
,
const
char
*
lxc_name
,
const
char
*
newpath
,
const
char
*
newname
);
int
ovl_update_abs
_paths
(
struct
lxc_conf
*
lxc_conf
,
const
char
*
lxc_path
,
const
char
*
lxc_name
,
const
char
*
newpath
,
const
char
*
newname
);
/*
* To be called from functions in lxccontainer.c: Get lower directory for
* overlay rootfs.
*/
char
*
ov
erlay
_getlower
(
char
*
p
);
char
*
ov
l
_getlower
(
char
*
p
);
#endif
/* __LXC_OVERLAY_H */
src/lxc/lxccontainer.c
View file @
83e79752
...
...
@@ -1093,9 +1093,9 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool need_
* the template
*/
if
(
strncmp
(
src
,
"overlayfs:"
,
10
)
==
0
)
src
=
ov
erlay
_getlower
(
src
+
10
);
src
=
ov
l
_getlower
(
src
+
10
);
if
(
strncmp
(
src
,
"aufs:"
,
5
)
==
0
)
src
=
ov
erlay
_getlower
(
src
+
5
);
src
=
ov
l
_getlower
(
src
+
5
);
bdev
=
bdev_init
(
c
->
lxc_conf
,
src
,
c
->
lxc_conf
->
rootfs
.
mount
,
NULL
);
if
(
!
bdev
)
{
...
...
@@ -3125,7 +3125,7 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
}
// update absolute paths for overlay mount directories
if
(
update_ovl
_paths
(
c2
->
lxc_conf
,
c
->
config_path
,
c
->
name
,
lxcpath
,
newname
)
<
0
)
if
(
ovl_update_abs
_paths
(
c2
->
lxc_conf
,
c
->
config_path
,
c
->
name
,
lxcpath
,
newname
)
<
0
)
goto
out
;
// We've now successfully created c2's storage, so clear it out if we
...
...
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