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
7e009d52
Unverified
Commit
7e009d52
authored
Jun 04, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bdev: "detect" loop file
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
9aa76a17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
bdev.c
src/lxc/bdev/bdev.c
+9
-2
lxcloop.c
src/lxc/bdev/lxcloop.c
+19
-1
No files found.
src/lxc/bdev/bdev.c
View file @
7e009d52
...
@@ -854,12 +854,16 @@ static const struct bdev_type *get_bdev_by_name(const char *name)
...
@@ -854,12 +854,16 @@ static const struct bdev_type *get_bdev_by_name(const char *name)
return
NULL
;
return
NULL
;
}
}
static
const
struct
bdev_type
*
bdev_query
(
struct
lxc_conf
*
conf
,
const
char
*
src
)
static
const
struct
bdev_type
*
bdev_query
(
struct
lxc_conf
*
conf
,
const
char
*
src
)
{
{
size_t
i
;
size_t
i
;
if
(
conf
->
rootfs
.
bdev_type
)
if
(
conf
->
rootfs
.
bdev_type
)
{
DEBUG
(
"config file specified rootfs type
\"
%s
\"
"
,
conf
->
rootfs
.
bdev_type
);
return
get_bdev_by_name
(
conf
->
rootfs
.
bdev_type
);
return
get_bdev_by_name
(
conf
->
rootfs
.
bdev_type
);
}
for
(
i
=
0
;
i
<
numbdevs
;
i
++
)
{
for
(
i
=
0
;
i
<
numbdevs
;
i
++
)
{
int
r
;
int
r
;
...
@@ -870,6 +874,9 @@ static const struct bdev_type *bdev_query(struct lxc_conf *conf, const char *src
...
@@ -870,6 +874,9 @@ static const struct bdev_type *bdev_query(struct lxc_conf *conf, const char *src
if
(
i
==
numbdevs
)
if
(
i
==
numbdevs
)
return
NULL
;
return
NULL
;
DEBUG
(
"detected rootfs type
\"
%s
\"
"
,
bdevs
[
i
].
name
);
return
&
bdevs
[
i
];
return
&
bdevs
[
i
];
}
}
...
...
src/lxc/bdev/lxcloop.c
View file @
7e009d52
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#include <linux/loop.h>
#include <linux/loop.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
#include "bdev.h"
#include "bdev.h"
...
@@ -157,8 +158,19 @@ int loop_destroy(struct bdev *orig)
...
@@ -157,8 +158,19 @@ int loop_destroy(struct bdev *orig)
int
loop_detect
(
const
char
*
path
)
int
loop_detect
(
const
char
*
path
)
{
{
int
ret
;
struct
stat
s
;
if
(
strncmp
(
path
,
"loop:"
,
5
)
==
0
)
if
(
strncmp
(
path
,
"loop:"
,
5
)
==
0
)
return
1
;
return
1
;
ret
=
stat
(
path
,
&
s
);
if
(
ret
<
0
)
return
0
;
if
(
__S_ISTYPE
(
s
.
st_mode
,
S_IFREG
))
return
1
;
return
0
;
return
0
;
}
}
...
@@ -166,13 +178,19 @@ int loop_mount(struct bdev *bdev)
...
@@ -166,13 +178,19 @@ int loop_mount(struct bdev *bdev)
{
{
int
ret
,
loopfd
;
int
ret
,
loopfd
;
char
loname
[
MAXPATHLEN
];
char
loname
[
MAXPATHLEN
];
char
*
src
=
bdev
->
src
;
if
(
strcmp
(
bdev
->
type
,
"loop"
))
if
(
strcmp
(
bdev
->
type
,
"loop"
))
return
-
22
;
return
-
22
;
if
(
!
bdev
->
src
||
!
bdev
->
dest
)
if
(
!
bdev
->
src
||
!
bdev
->
dest
)
return
-
22
;
return
-
22
;
loopfd
=
lxc_prepare_loop_dev
(
bdev
->
src
+
5
,
loname
,
LO_FLAGS_AUTOCLEAR
);
/* skip prefix */
if
(
!
strncmp
(
bdev
->
src
,
"loop:"
,
5
))
src
+=
5
;
loopfd
=
lxc_prepare_loop_dev
(
src
,
loname
,
LO_FLAGS_AUTOCLEAR
);
if
(
loopfd
<
0
)
if
(
loopfd
<
0
)
return
-
1
;
return
-
1
;
DEBUG
(
"prepared loop device
\"
%s
\"
"
,
loname
);
DEBUG
(
"prepared loop device
\"
%s
\"
"
,
loname
);
...
...
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