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
be459e99
Unverified
Commit
be459e99
authored
Dec 08, 2017
by
Serge Hallyn
Committed by
GitHub
Dec 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1950 from brauner/2017-11-27/criu_fixes
bugfixes
parents
f6812e7f
1c7222c0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
246 additions
and
170 deletions
+246
-170
conf.c
src/lxc/conf.c
+4
-4
conf.h
src/lxc/conf.h
+1
-1
confile.c
src/lxc/confile.c
+35
-1
criu.c
src/lxc/criu.c
+2
-0
lxccontainer.c
src/lxc/lxccontainer.c
+0
-0
btrfs.c
src/lxc/storage/btrfs.c
+6
-5
dir.c
src/lxc/storage/dir.c
+4
-3
loop.c
src/lxc/storage/loop.c
+8
-2
lvm.c
src/lxc/storage/lvm.c
+9
-7
nbd.c
src/lxc/storage/nbd.c
+1
-1
overlay.c
src/lxc/storage/overlay.c
+41
-42
overlay.h
src/lxc/storage/overlay.h
+1
-1
rbd.c
src/lxc/storage/rbd.c
+2
-2
rsync.c
src/lxc/storage/rsync.c
+1
-1
storage.c
src/lxc/storage/storage.c
+78
-52
storage.h
src/lxc/storage/storage.h
+16
-17
storage_utils.c
src/lxc/storage/storage_utils.c
+9
-7
storage_utils.h
src/lxc/storage/storage_utils.h
+1
-1
zfs.c
src/lxc/storage/zfs.c
+22
-18
utils.c
src/lxc/utils.c
+4
-4
utils.h
src/lxc/utils.h
+1
-1
No files found.
src/lxc/conf.c
View file @
be459e99
...
...
@@ -1191,7 +1191,7 @@ static int lxc_setup_rootfs(struct lxc_conf *conf)
return
-
1
;
}
bdev
=
storage_init
(
conf
,
rootfs
->
path
,
rootfs
->
mount
,
rootfs
->
options
);
bdev
=
storage_init
(
conf
);
if
(
!
bdev
)
{
ERROR
(
"Failed to mount rootfs
\"
%s
\"
onto
\"
%s
\"
with options
\"
%s
\"
."
,
rootfs
->
path
,
rootfs
->
mount
,
...
...
@@ -2725,7 +2725,7 @@ int chown_mapped_root_exec_wrapper(void *args)
* root is privileged with respect to hostuid/hostgid X, allowing
* him to do the chown.
*/
int
chown_mapped_root
(
char
*
path
,
struct
lxc_conf
*
conf
)
int
chown_mapped_root
(
c
onst
c
har
*
path
,
struct
lxc_conf
*
conf
)
{
uid_t
rootuid
,
rootgid
;
unsigned
long
val
;
...
...
@@ -2733,14 +2733,14 @@ int chown_mapped_root(char *path, struct lxc_conf *conf)
struct
stat
sb
;
char
map1
[
100
],
map2
[
100
],
map3
[
100
],
map4
[
100
],
map5
[
100
];
char
ugid
[
100
];
char
*
args1
[]
=
{
"lxc-usernsexec"
,
c
onst
c
har
*
args1
[]
=
{
"lxc-usernsexec"
,
"-m"
,
map1
,
"-m"
,
map2
,
"-m"
,
map3
,
"-m"
,
map5
,
"--"
,
"chown"
,
ugid
,
path
,
NULL
};
char
*
args2
[]
=
{
"lxc-usernsexec"
,
c
onst
c
har
*
args2
[]
=
{
"lxc-usernsexec"
,
"-m"
,
map1
,
"-m"
,
map2
,
"-m"
,
map3
,
...
...
src/lxc/conf.h
View file @
be459e99
...
...
@@ -410,7 +410,7 @@ extern int setup_resource_limits(struct lxc_list *limits, pid_t pid);
extern
int
find_unmapped_nsid
(
struct
lxc_conf
*
conf
,
enum
idtype
idtype
);
extern
int
mapped_hostid
(
unsigned
id
,
struct
lxc_conf
*
conf
,
enum
idtype
idtype
);
extern
int
chown_mapped_root
(
char
*
path
,
struct
lxc_conf
*
conf
);
extern
int
chown_mapped_root
(
c
onst
c
har
*
path
,
struct
lxc_conf
*
conf
);
extern
int
lxc_ttys_shift_ids
(
struct
lxc_conf
*
c
);
extern
int
userns_exec_1
(
struct
lxc_conf
*
conf
,
int
(
*
fn
)(
void
*
),
void
*
data
,
const
char
*
fn_name
);
...
...
src/lxc/confile.c
View file @
be459e99
...
...
@@ -1910,7 +1910,41 @@ static int set_config_includefiles(const char *key, const char *value,
static
int
set_config_rootfs_path
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
return
set_config_path_item
(
&
lxc_conf
->
rootfs
.
path
,
value
);
int
ret
;
char
*
dup
,
*
tmp
;
const
char
*
container_path
;
if
(
lxc_config_value_empty
(
value
))
{
free
(
lxc_conf
->
rootfs
.
path
);
lxc_conf
->
rootfs
.
path
=
NULL
;
return
0
;
}
dup
=
strdup
(
value
);
if
(
!
dup
)
return
-
1
;
/* Split <storage type>:<container path> into <storage type> and
* <container path>. Set "rootfs.bdev_type" to <storage type> and
* "rootfs.path" to <container path>.
*/
tmp
=
strchr
(
dup
,
':'
);
if
(
tmp
)
{
*
tmp
=
'\0'
;
ret
=
set_config_path_item
(
&
lxc_conf
->
rootfs
.
bdev_type
,
dup
);
if
(
ret
<
0
)
{
free
(
dup
);
return
-
1
;
}
tmp
++
;
container_path
=
tmp
;
}
else
{
container_path
=
value
;
}
ret
=
set_config_path_item
(
&
lxc_conf
->
rootfs
.
path
,
container_path
);
free
(
dup
);
return
ret
;
}
static
int
set_config_rootfs_mount
(
const
char
*
key
,
const
char
*
value
,
...
...
src/lxc/criu.c
View file @
be459e99
...
...
@@ -564,6 +564,8 @@ static void exec_criu(struct criu_opts *opts)
switch
(
n
->
type
)
{
case
LXC_NET_VETH
:
veth
=
n
->
priv
.
veth_attr
.
pair
;
if
(
veth
[
0
]
==
'\0'
)
veth
=
n
->
priv
.
veth_attr
.
veth1
;
if
(
n
->
link
[
0
]
!=
'\0'
)
{
if
(
external_not_veth
)
...
...
src/lxc/lxccontainer.c
View file @
be459e99
This diff is collapsed.
Click to expand it.
src/lxc/storage/btrfs.c
View file @
be459e99
...
...
@@ -187,7 +187,8 @@ bool btrfs_detect(const char *path)
int
btrfs_mount
(
struct
lxc_storage
*
bdev
)
{
unsigned
long
mntflags
;
char
*
mntdata
,
*
src
;
char
*
mntdata
;
const
char
*
src
;
int
ret
;
if
(
strcmp
(
bdev
->
type
,
"btrfs"
))
...
...
@@ -348,7 +349,7 @@ out:
int
btrfs_snapshot_wrapper
(
void
*
data
)
{
char
*
src
;
c
onst
c
har
*
src
;
struct
rsync_data_char
*
arg
=
data
;
if
(
setgid
(
0
)
<
0
)
{
...
...
@@ -372,7 +373,7 @@ int btrfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
{
char
*
src
;
c
onst
c
har
*
src
;
if
(
!
orig
->
dest
||
!
orig
->
src
)
return
-
1
;
...
...
@@ -483,7 +484,7 @@ bool btrfs_create_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
return
true
;
}
ret
=
btrfs_snapshot
(
orig
->
dest
,
new
->
dest
);
ret
=
btrfs_snapshot
(
orig
->
src
,
new
->
dest
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to create btrfs snapshot
\"
%s
\"
from
\"
%s
\"
"
,
new
->
dest
,
orig
->
dest
);
...
...
@@ -821,7 +822,7 @@ bool btrfs_try_remove_subvol(const char *path)
int
btrfs_destroy
(
struct
lxc_storage
*
orig
)
{
char
*
src
;
c
onst
c
har
*
src
;
src
=
lxc_storage_get_path
(
orig
->
src
,
"btrfs"
);
...
...
src/lxc/storage/dir.c
View file @
be459e99
...
...
@@ -39,7 +39,7 @@ int dir_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
{
char
*
src_no_prefix
;
c
onst
c
har
*
src_no_prefix
;
int
ret
;
size_t
len
;
...
...
@@ -121,7 +121,7 @@ int dir_create(struct lxc_storage *bdev, const char *dest, const char *n,
int
dir_destroy
(
struct
lxc_storage
*
orig
)
{
int
ret
;
char
*
src
;
c
onst
c
har
*
src
;
src
=
lxc_storage_get_path
(
orig
->
src
,
orig
->
src
);
...
...
@@ -149,7 +149,8 @@ int dir_mount(struct lxc_storage *bdev)
{
int
ret
;
unsigned
long
mflags
,
mntflags
;
char
*
src
,
*
mntdata
;
char
*
mntdata
;
const
char
*
src
;
if
(
strcmp
(
bdev
->
type
,
"dir"
))
return
-
22
;
...
...
src/lxc/storage/loop.c
View file @
be459e99
...
...
@@ -204,7 +204,13 @@ int loop_create(struct lxc_storage *bdev, const char *dest, const char *n,
}
int
loop_destroy
(
struct
lxc_storage
*
orig
)
{
return
unlink
(
orig
->
src
+
5
);
char
*
dir
;
dir
=
orig
->
src
;
if
(
strncmp
(
orig
->
src
,
"loop:"
,
5
)
==
0
)
dir
+=
5
;
return
unlink
(
dir
);
}
bool
loop_detect
(
const
char
*
path
)
...
...
@@ -229,7 +235,7 @@ int loop_mount(struct lxc_storage *bdev)
{
int
ret
,
loopfd
;
char
loname
[
MAXPATHLEN
];
char
*
src
;
c
onst
c
har
*
src
;
if
(
strcmp
(
bdev
->
type
,
"loop"
))
return
-
22
;
...
...
src/lxc/storage/lvm.c
View file @
be459e99
...
...
@@ -235,7 +235,7 @@ bool lvm_detect(const char *path)
int
lvm_mount
(
struct
lxc_storage
*
bdev
)
{
char
*
src
;
c
onst
c
har
*
src
;
if
(
strcmp
(
bdev
->
type
,
"lvm"
))
return
-
22
;
...
...
@@ -330,11 +330,12 @@ static int lvm_snapshot_create_new_uuid_wrapper(void *data)
static
int
lvm_snapshot
(
struct
lxc_storage
*
orig
,
const
char
*
path
,
uint64_t
size
)
{
int
ret
;
char
*
origsrc
,
*
pathdup
,
*
lv
;
char
*
lv
,
*
pathdup
;
char
sz
[
24
];
char
fstype
[
100
];
char
cmd_output
[
MAXPATHLEN
];
char
repairchar
;
const
char
*
origsrc
;
struct
lvcreate_args
cmd_args
=
{
0
};
ret
=
snprintf
(
sz
,
24
,
"%"
PRIu64
"b"
,
size
);
...
...
@@ -433,7 +434,8 @@ int lvm_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
(
const
char
*
[]){
"lvm:"
,
"dev"
,
vg
,
cname
,
NULL
},
false
);
}
else
{
char
*
dup
,
*
slider
,
*
src
;
const
char
*
src
;
char
*
dup
,
*
slider
;
src
=
lxc_storage_get_path
(
orig
->
src
,
orig
->
type
);
...
...
@@ -497,11 +499,11 @@ int lvm_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
bool
lvm_create_clone
(
struct
lxc_conf
*
conf
,
struct
lxc_storage
*
orig
,
struct
lxc_storage
*
new
,
uint64_t
newsize
)
{
char
*
src
;
const
char
*
thinpool
;
int
ret
;
const
char
*
src
;
const
char
*
thinpool
;
struct
rsync_data
data
;
char
*
cmd_args
[
2
];
c
onst
c
har
*
cmd_args
[
2
];
char
cmd_output
[
MAXPATHLEN
]
=
{
0
};
char
fstype
[
100
]
=
"ext4"
;
uint64_t
size
=
newsize
;
...
...
@@ -560,7 +562,7 @@ bool lvm_create_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
struct
lxc_storage
*
new
,
uint64_t
newsize
)
{
int
ret
;
char
*
newsrc
;
c
onst
c
har
*
newsrc
;
uint64_t
size
=
newsize
;
if
(
is_blktype
(
orig
))
{
...
...
src/lxc/storage/nbd.c
View file @
be459e99
...
...
@@ -118,7 +118,7 @@ bool nbd_detect(const char *path)
int
nbd_mount
(
struct
lxc_storage
*
bdev
)
{
int
ret
=
-
1
,
partition
;
char
*
src
;
c
onst
c
har
*
src
;
char
path
[
50
];
if
(
strcmp
(
bdev
->
type
,
"nbd"
))
...
...
src/lxc/storage/overlay.c
View file @
be459e99
...
...
@@ -54,7 +54,7 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
{
int
ret
;
char
*
src
;
c
onst
c
har
*
src
;
if
(
!
snap
)
{
ERROR
(
"The overlay storage driver can only be used for "
...
...
@@ -199,12 +199,11 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return
-
22
;
}
nsrc
=
strchr
(
osrc
,
':'
)
+
1
;
if
((
nsrc
!=
osrc
+
8
)
&&
(
nsrc
!=
osrc
+
10
))
{
ERROR
(
"Detected
\"
:
\"
in
\"
%s
\"
at wrong position"
,
osrc
);
free
(
osrc
);
return
-
22
;
}
nsrc
=
osrc
;
if
(
strncmp
(
osrc
,
"overlay:"
,
8
)
==
0
)
nsrc
+=
8
;
else
if
(
strncmp
(
osrc
,
"overlayfs:"
,
10
)
==
0
)
nsrc
+=
10
;
odelta
=
strchr
(
nsrc
,
':'
);
if
(
!
odelta
)
{
...
...
@@ -457,22 +456,17 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
int
ovl_destroy
(
struct
lxc_storage
*
orig
)
{
bool
ovl
;
char
*
upper
=
orig
->
src
;
ovl
=
!
strncmp
(
upper
,
"overlay:"
,
8
);
if
(
!
ovl
&&
strncmp
(
upper
,
"overlayfs:"
,
10
))
return
-
22
;
/* For an overlay container the rootfs is considered immutable
* and cannot be removed when restoring from a snapshot.
*/
if
(
orig
->
flags
&
LXC_STORAGE_INTERNAL_OVERLAY_RESTORE
)
return
0
;
if
(
ovl
)
if
(
strncmp
(
upper
,
"overlay:"
,
8
)
==
0
)
upper
+=
8
;
else
else
if
(
strncmp
(
upper
,
"overlayfs:"
,
10
)
==
0
)
upper
+=
10
;
upper
=
strchr
(
upper
,
':'
);
...
...
@@ -485,10 +479,10 @@ int ovl_destroy(struct lxc_storage *orig)
bool
ovl_detect
(
const
char
*
path
)
{
if
(
!
strncmp
(
path
,
"overlay
fs:"
,
10
))
if
(
!
strncmp
(
path
,
"overlay
:"
,
8
))
return
true
;
if
(
!
strncmp
(
path
,
"overlay
:"
,
8
))
if
(
!
strncmp
(
path
,
"overlay
fs:"
,
10
))
return
true
;
return
false
;
...
...
@@ -521,18 +515,19 @@ int ovl_mount(struct lxc_storage *bdev)
ERROR
(
"Failed to allocate memory"
);
return
-
1
;
}
upper
=
dup
;
lower
=
dup
;
/* support multiple lower layers */
lower
=
strstr
(
dup
,
":/"
);
if
(
!
lower
)
{
ERROR
(
"Failed to detect
\"
:/
\"
in string
\"
%s
\"
"
,
dup
);
free
(
dup
);
return
-
22
;
}
if
(
strncmp
(
dup
,
"overlay:"
,
8
)
==
0
)
lower
+=
8
;
else
if
(
strncmp
(
dup
,
"overlayfs:"
,
10
)
==
0
)
lower
+=
10
;
if
(
upper
!=
lower
)
upper
=
lower
;
lower
++
;
upper
=
lower
;
while
((
tmp
=
strstr
(
++
upper
,
":/"
)))
{
/* support multiple lower layers */
while
((
tmp
=
strstr
(
upper
,
":/"
)))
{
tmp
++
;
upper
=
tmp
;
}
...
...
@@ -688,14 +683,14 @@ int ovl_umount(struct lxc_storage *bdev)
return
ret
;
}
char
*
ovl_get_lower
(
const
char
*
rootfs_path
)
c
onst
c
har
*
ovl_get_lower
(
const
char
*
rootfs_path
)
{
c
har
*
s1
;
c
onst
char
*
s1
=
rootfs_path
;
s1
=
strstr
(
rootfs_path
,
":/"
);
if
(
!
s1
)
return
NULL
;
s1
++
;
if
(
strncmp
(
rootfs_path
,
"overlay:"
,
8
)
==
0
)
s1
+=
8
;
else
if
(
strncmp
(
rootfs_path
,
"overlayfs:"
,
10
)
==
0
)
s1
+=
10
;
s1
=
strstr
(
s1
,
":/"
);
if
(
!
s1
)
...
...
@@ -719,16 +714,20 @@ char *ovl_get_rootfs(const char *rootfs_path, size_t *rootfslen)
if
(
!
s1
)
return
NULL
;
s2
=
strstr
(
s1
,
":/"
);
if
(
s2
)
{
s2
=
s2
+
1
;
if
((
s3
=
strstr
(
s2
,
":/"
)))
*
s3
=
'\0'
;
rootfsdir
=
strdup
(
s2
);
if
(
!
rootfsdir
)
{
free
(
s1
);
return
NULL
;
}
s2
=
s1
;
if
(
strncmp
(
rootfs_path
,
"overlay:"
,
8
)
==
0
)
s2
+=
8
;
else
if
(
strncmp
(
rootfs_path
,
"overlayfs:"
,
10
)
==
0
)
s2
+=
10
;
s3
=
strstr
(
s2
,
":/"
);
if
(
s3
)
*
s3
=
'\0'
;
rootfsdir
=
strdup
(
s2
);
if
(
!
rootfsdir
)
{
free
(
s1
);
return
NULL
;
}
if
(
!
rootfsdir
)
...
...
src/lxc/storage/overlay.h
View file @
be459e99
...
...
@@ -66,7 +66,7 @@ extern int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
/* To be called from functions in lxccontainer.c: Get lower directory for
* overlay rootfs.
*/
extern
char
*
ovl_get_lower
(
const
char
*
rootfs_path
);
extern
c
onst
c
har
*
ovl_get_lower
(
const
char
*
rootfs_path
);
/* Get rootfs path for overlay backed containers. Allocated memory must be freed
* by caller.
...
...
src/lxc/storage/rbd.c
View file @
be459e99
...
...
@@ -189,7 +189,7 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n,
int
rbd_destroy
(
struct
lxc_storage
*
orig
)
{
int
ret
;
char
*
src
;
c
onst
c
har
*
src
;
char
*
rbdfullname
;
char
cmd_output
[
MAXPATHLEN
];
struct
rbd_args
args
=
{
0
};
...
...
@@ -233,7 +233,7 @@ bool rbd_detect(const char *path)
int
rbd_mount
(
struct
lxc_storage
*
bdev
)
{
char
*
src
;
c
onst
c
har
*
src
;
if
(
strcmp
(
bdev
->
type
,
"rbd"
))
return
-
22
;
...
...
src/lxc/storage/rsync.c
View file @
be459e99
...
...
@@ -87,7 +87,7 @@ int lxc_rsync_exec(const char *src, const char *dest)
int
lxc_rsync
(
struct
rsync_data
*
data
)
{
int
ret
;
char
*
dest
,
*
src
;
c
onst
c
har
*
dest
,
*
src
;
struct
lxc_storage
*
orig
=
data
->
orig
,
*
new
=
data
->
new
;
ret
=
unshare
(
CLONE_NEWNS
);
...
...
src/lxc/storage/storage.c
View file @
be459e99
This diff is collapsed.
Click to expand it.
src/lxc/storage/storage.h
View file @
be459e99
...
...
@@ -109,23 +109,24 @@ struct lxc_storage {
int
flags
;
};
extern
bool
storage_is_dir
(
struct
lxc_conf
*
conf
,
const
char
*
path
);
/**
* storage_is_dir : Check whether the roots is a directory. This function will
* trust the config file. If the config file key
* lxc.rootfs.path is set to <storage type>:<container path>
* the confile parser will have split this into <storage type>
* and <container path> and set the <bdev_type> member in the
* lxc_rootfs struct to <storage type> and the <path> member
* will be set to a clean <container path> without the <storage
* type> prefix. This is the new, clean way of handling storage
* type specifications. If the <storage type> prefix is not
* detected liblxc will try to detect the storage type.
*/
extern
bool
storage_is_dir
(
struct
lxc_conf
*
conf
);
extern
bool
storage_can_backup
(
struct
lxc_conf
*
conf
);
/* Instantiate a lxc_storage object. The src is used to determine which blockdev
* type this should be. The dst and data are optional, and will be used in case
* of mount/umount.
*
* The source will be "dir:/var/lib/lxc/c1" or "lvm:/dev/lxc/c1". For other
* backing stores, this will allow additional options. In particular,
* "overlayfs:/var/lib/lxc/canonical/rootfs:/var/lib/lxc/c1/delta" will mean use
* /var/lib/lxc/canonical/rootfs as lower dir, and /var/lib/lxc/c1/delta as the
* upper, writeable layer.
*/
extern
struct
lxc_storage
*
storage_init
(
struct
lxc_conf
*
conf
,
const
char
*
src
,
const
char
*
dst
,
const
char
*
data
);
extern
struct
lxc_storage
*
storage_init
(
struct
lxc_conf
*
conf
);
extern
struct
lxc_storage
*
storage_copy
(
struct
lxc_container
*
c
0
,
extern
struct
lxc_storage
*
storage_copy
(
struct
lxc_container
*
c
,
const
char
*
cname
,
const
char
*
lxcpath
,
const
char
*
bdevtype
,
int
flags
,
const
char
*
bdevdata
,
uint64_t
newsize
,
...
...
@@ -135,9 +136,7 @@ extern struct lxc_storage *storage_create(const char *dest, const char *type,
struct
bdev_specs
*
specs
);
extern
void
storage_put
(
struct
lxc_storage
*
bdev
);
extern
bool
storage_destroy
(
struct
lxc_conf
*
conf
);
extern
int
storage_destroy_wrapper
(
void
*
data
);
extern
bool
rootfs_is_blockdev
(
struct
lxc_conf
*
conf
);
extern
char
*
lxc_storage_get_path
(
char
*
src
,
const
char
*
prefix
);
extern
c
onst
c
har
*
lxc_storage_get_path
(
char
*
src
,
const
char
*
prefix
);
#endif
/* #define __LXC_STORAGE_H */
src/lxc/storage/storage_utils.c
View file @
be459e99
...
...
@@ -133,7 +133,7 @@ bool attach_block_device(struct lxc_conf *conf)
int
blk_getsize
(
struct
lxc_storage
*
bdev
,
uint64_t
*
size
)
{
int
fd
,
ret
;
char
*
src
;
c
onst
c
har
*
src
;
src
=
lxc_storage_get_path
(
bdev
->
src
,
bdev
->
type
);
fd
=
open
(
src
,
O_RDONLY
);
...
...
@@ -162,11 +162,15 @@ void detach_block_device(struct lxc_conf *conf)
*/
int
detect_fs
(
struct
lxc_storage
*
bdev
,
char
*
type
,
int
len
)
{
int
p
[
2
],
ret
;
int
ret
;
int
p
[
2
];
size_t
linelen
;
pid_t
pid
;
FILE
*
f
;
char
*
sp1
,
*
sp2
,
*
sp3
,
*
srcdev
,
*
line
=
NULL
;
char
*
sp1
,
*
sp2
,
*
sp3
;
const
char
*
l
,
*
srcdev
;
char
devpath
[
MAXPATHLEN
];
char
*
line
=
NULL
;
if
(
!
bdev
||
!
bdev
->
src
||
!
bdev
->
dest
)
return
-
1
;
...
...
@@ -218,9 +222,7 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len)
exit
(
1
);
}
/* if symlink, get the real dev name */
char
devpath
[
MAXPATHLEN
];
char
*
l
=
linkderef
(
srcdev
,
devpath
);
l
=
linkderef
(
srcdev
,
devpath
);
if
(
!
l
)
exit
(
1
);
f
=
fopen
(
"/proc/self/mounts"
,
"r"
);
...
...
@@ -383,7 +385,7 @@ int find_fstype_cb(char *buffer, void *data)
return
1
;
}
c
har
*
linkderef
(
char
*
path
,
char
*
dest
)
c
onst
char
*
linkderef
(
const
char
*
path
,
char
*
dest
)
{
struct
stat
sbuf
;
ssize_t
ret
;
...
...
src/lxc/storage/storage_utils.h
View file @
be459e99
...
...
@@ -45,7 +45,7 @@ extern int is_blktype(struct lxc_storage *b);
extern
int
mount_unknown_fs
(
const
char
*
rootfs
,
const
char
*
target
,
const
char
*
options
);
extern
int
find_fstype_cb
(
char
*
buffer
,
void
*
data
);
extern
c
har
*
linkderef
(
char
*
path
,
char
*
dest
);
extern
c
onst
char
*
linkderef
(
const
char
*
path
,
char
*
dest
);
extern
bool
unpriv_snap_allowed
(
struct
lxc_storage
*
b
,
const
char
*
t
,
bool
snap
,
bool
maybesnap
);
extern
bool
is_valid_storage_type
(
const
char
*
type
);
...
...
src/lxc/storage/zfs.c
View file @
be459e99
...
...
@@ -180,7 +180,8 @@ int zfs_mount(struct lxc_storage *bdev)
{
int
ret
;
size_t
oldlen
,
newlen
,
totallen
;
char
*
mntdata
,
*
src
,
*
tmp
;
char
*
mntdata
,
*
tmp
;
const
char
*
src
;
unsigned
long
mntflags
;
char
cmd_output
[
MAXPATHLEN
]
=
{
0
};
...
...
@@ -287,13 +288,13 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig,
char
cmd_output
[
MAXPATHLEN
],
option
[
MAXPATHLEN
];
struct
rsync_data
data
=
{
0
,
0
};
struct
zfs_args
cmd_args
=
{
0
};
c
har
*
argv
[]
=
{
"zfs"
,
/* 0 */
"create"
,
/* 1 */
"-o"
,
""
,
/* 2, 3 */
"-o"
,
"canmount=noauto"
,
/* 4, 5 */
"-p"
,
/* 6 */
""
,
/* 7 */
NULL
};
c
onst
char
*
argv
[]
=
{
"zfs"
,
/* 0 */
"create"
,
/* 1 */
"-o"
,
""
,
/* 2, 3 */
"-o"
,
"canmount=noauto"
,
/* 4, 5 */
"-p"
,
/* 6 */
""
,
/* 7 */
NULL
};
/* mountpoint */
ret
=
snprintf
(
option
,
MAXPATHLEN
,
"mountpoint=%s"
,
new
->
dest
);
...
...
@@ -342,7 +343,8 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
{
int
ret
;
size_t
snapshot_len
,
len
;
char
*
orig_src
,
*
tmp
,
*
snap_name
,
*
snapshot
;
char
*
tmp
,
*
snap_name
,
*
snapshot
;
const
char
*
orig_src
;
struct
zfs_args
cmd_args
=
{
0
};
char
cmd_output
[
MAXPATHLEN
]
=
{
0
},
option
[
MAXPATHLEN
];
...
...
@@ -447,8 +449,9 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
{
char
*
dataset
,
*
orig_src
,
*
tmp
;
int
ret
;
char
*
dataset
,
*
tmp
;
const
char
*
orig_src
;
size_t
dataset_len
,
len
;
char
cmd_output
[
MAXPATHLEN
]
=
{
0
};
...
...
@@ -576,7 +579,8 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
int
zfs_destroy
(
struct
lxc_storage
*
orig
)
{
int
ret
;
char
*
dataset
,
*
src
,
*
tmp
;
char
*
dataset
,
*
tmp
;
const
char
*
src
;
bool
found
;
char
*
parent_snapshot
=
NULL
;
struct
zfs_args
cmd_args
=
{
0
};
...
...
@@ -709,13 +713,13 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n,
size_t
len
;
struct
zfs_args
cmd_args
=
{
0
};
char
cmd_output
[
MAXPATHLEN
],
option
[
MAXPATHLEN
];
c
har
*
argv
[]
=
{
"zfs"
,
/* 0 */
"create"
,
/* 1 */
"-o"
,
""
,
/* 2, 3 */
"-o"
,
"canmount=noauto"
,
/* 4, 5 */
"-p"
,
/* 6 */
""
,
/* 7 */
NULL
};
c
onst
char
*
argv
[]
=
{
"zfs"
,
/* 0 */
"create"
,
/* 1 */
"-o"
,
""
,
/* 2, 3 */
"-o"
,
"canmount=noauto"
,
/* 4, 5 */
"-p"
,
/* 6 */
""
,
/* 7 */
NULL
};
if
(
!
specs
||
!
specs
->
zfs
.
zfsroot
)
zfsroot
=
lxc_global_config_value
(
"lxc.bdev.zfs.root"
);
...
...
src/lxc/utils.c
View file @
be459e99
...
...
@@ -65,7 +65,7 @@ lxc_log_define(lxc_utils, lxc);
*/
extern
bool
btrfs_try_remove_subvol
(
const
char
*
path
);
static
int
_recursive_rmdir
(
char
*
dirname
,
dev_t
pdev
,
static
int
_recursive_rmdir
(
c
onst
c
har
*
dirname
,
dev_t
pdev
,
const
char
*
exclude
,
int
level
,
bool
onedev
)
{
struct
dirent
*
direntp
;
...
...
@@ -180,18 +180,18 @@ static bool is_native_overlayfs(const char *path)
}
/* returns 0 on success, -1 if there were any failures */
extern
int
lxc_rmdir_onedev
(
char
*
path
,
const
char
*
exclude
)
extern
int
lxc_rmdir_onedev
(
c
onst
c
har
*
path
,
const
char
*
exclude
)
{
struct
stat
mystat
;
bool
onedev
=
true
;
if
(
is_native_overlayfs
(
path
))
{
if
(
is_native_overlayfs
(
path
))
onedev
=
false
;
}
if
(
lstat
(
path
,
&
mystat
)
<
0
)
{
if
(
errno
==
ENOENT
)
return
0
;
ERROR
(
"Failed to stat %s"
,
path
);
return
-
1
;
}
...
...
src/lxc/utils.h
View file @
be459e99
...
...
@@ -93,7 +93,7 @@
#define LXC_IDMAPLEN 4096
/* returns 1 on success, 0 if there were any failures */
extern
int
lxc_rmdir_onedev
(
char
*
path
,
const
char
*
exclude
);
extern
int
lxc_rmdir_onedev
(
c
onst
c
har
*
path
,
const
char
*
exclude
);
extern
int
get_u16
(
unsigned
short
*
val
,
const
char
*
arg
,
int
base
);
extern
int
mkdir_p
(
const
char
*
dir
,
mode_t
mode
);
extern
char
*
get_rundir
(
void
);
...
...
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