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
9769034f
Commit
9769034f
authored
Feb 03, 2016
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow overlay lxc.mount.entry with no rootfs
Allow lxc.mount.entry entries for containers without a rootfs. Signed-off-by:
Christian Brauner
<
christian.brauner@mailbox.org
>
parent
8d1b71bb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
41 deletions
+61
-41
lxcaufs.c
src/lxc/bdev/lxcaufs.c
+24
-17
lxcaufs.h
src/lxc/bdev/lxcaufs.h
+3
-0
lxcoverlay.c
src/lxc/bdev/lxcoverlay.c
+33
-23
conf.c
src/lxc/conf.c
+1
-1
No files found.
src/lxc/bdev/lxcaufs.c
View file @
9769034f
...
@@ -353,6 +353,7 @@ int aufs_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -353,6 +353,7 @@ int aufs_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
const
char
*
lxc_name
,
const
char
*
lxc_path
)
{
{
char
lxcpath
[
MAXPATHLEN
];
char
lxcpath
[
MAXPATHLEN
];
char
*
rootfs_path
=
NULL
;
char
*
rootfsdir
=
NULL
;
char
*
rootfsdir
=
NULL
;
char
*
scratch
=
NULL
;
char
*
scratch
=
NULL
;
char
*
tmp
=
NULL
;
char
*
tmp
=
NULL
;
...
@@ -365,11 +366,9 @@ int aufs_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -365,11 +366,9 @@ int aufs_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
size_t
len
=
0
;
size_t
len
=
0
;
size_t
rootfslen
=
0
;
size_t
rootfslen
=
0
;
/* Since we use all of these to check whether the user has given us a
/* When rootfs == NULL we have a container without a rootfs. */
* sane absolute path to create the directories needed for overlay
if
(
rootfs
&&
rootfs
->
path
)
* lxc.mount.entry entries we consider any of these missing fatal. */
rootfs_path
=
rootfs
->
path
;
if
(
!
rootfs
||
!
rootfs
->
path
||
!
lxc_name
||
!
lxc_path
)
goto
err
;
opts
=
lxc_string_split
(
mntent
->
mnt_opts
,
','
);
opts
=
lxc_string_split
(
mntent
->
mnt_opts
,
','
);
if
(
opts
)
if
(
opts
)
...
@@ -388,20 +387,28 @@ int aufs_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -388,20 +387,28 @@ int aufs_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
if
(
!
upperdir
)
if
(
!
upperdir
)
goto
err
;
goto
err
;
ret
=
snprintf
(
lxcpath
,
MAXPATHLEN
,
"%s/%s"
,
lxc_path
,
lxc_name
);
if
(
rootfs_path
)
{
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
ret
=
snprintf
(
lxcpath
,
MAXPATHLEN
,
"%s/%s"
,
lxc_path
,
lxc_name
);
goto
err
;
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
goto
err
;
rootfsdir
=
aufs_get_rootfs
(
rootfs
->
path
,
&
rootfslen
);
rootfsdir
=
aufs_get_rootfs
(
rootfs
->
path
,
&
rootfslen
);
if
(
!
rootfsdir
)
if
(
!
rootfsdir
)
goto
err
;
goto
err
;
}
/* We neither allow users to create upperdirs outside the containerdir
/*
* nor inside the rootfs. The latter might be debatable. */
* We neither allow users to create upperdirs and workdirs outside the
if
((
strncmp
(
upperdir
,
lxcpath
,
strlen
(
lxcpath
))
==
0
)
&&
(
strncmp
(
upperdir
,
rootfsdir
,
rootfslen
)
!=
0
))
* containerdir nor inside the rootfs. The latter might be debatable.
if
(
mkdir_p
(
upperdir
,
0755
)
<
0
)
{
* When we have a container without a rootfs we skip the checks.
WARN
(
"Failed to create upperdir"
);
*/
}
ret
=
0
;
if
(
!
rootfs_path
)
ret
=
mkdir_p
(
upperdir
,
0755
);
else
if
((
strncmp
(
upperdir
,
lxcpath
,
strlen
(
lxcpath
))
==
0
)
&&
(
strncmp
(
upperdir
,
rootfsdir
,
rootfslen
)
!=
0
))
ret
=
mkdir_p
(
upperdir
,
0755
);
if
(
ret
<
0
)
WARN
(
"Failed to create upperdir"
);
fret
=
0
;
fret
=
0
;
...
...
src/lxc/bdev/lxcaufs.h
View file @
9769034f
...
@@ -42,6 +42,9 @@ struct bdev_specs;
...
@@ -42,6 +42,9 @@ struct bdev_specs;
/* defined conf.h */
/* defined conf.h */
struct
lxc_conf
;
struct
lxc_conf
;
/* defined in conf.h */
struct
lxc_rootfs
;
/*
/*
* Functions associated with an aufs bdev struct.
* Functions associated with an aufs bdev struct.
*/
*/
...
...
src/lxc/bdev/lxcoverlay.c
View file @
9769034f
...
@@ -477,6 +477,7 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -477,6 +477,7 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
const
char
*
lxc_name
,
const
char
*
lxc_path
)
{
{
char
lxcpath
[
MAXPATHLEN
];
char
lxcpath
[
MAXPATHLEN
];
char
*
rootfs_path
=
NULL
;
char
*
rootfsdir
=
NULL
;
char
*
rootfsdir
=
NULL
;
char
*
upperdir
=
NULL
;
char
*
upperdir
=
NULL
;
char
*
workdir
=
NULL
;
char
*
workdir
=
NULL
;
...
@@ -489,11 +490,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -489,11 +490,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
size_t
len
=
0
;
size_t
len
=
0
;
size_t
rootfslen
=
0
;
size_t
rootfslen
=
0
;
/* Since we use all of these to check whether the user has given us a
/* When rootfs == NULL we have a container without a rootfs. */
* sane absolute path to create the directories needed for overlay
if
(
rootfs
&&
rootfs
->
path
)
* lxc.mount.entry entries we consider any of these missing fatal. */
rootfs_path
=
rootfs
->
path
;
if
(
!
rootfs
||
!
rootfs
->
path
||
!
lxc_name
||
!
lxc_path
)
goto
err
;
opts
=
lxc_string_split
(
mntent
->
mnt_opts
,
','
);
opts
=
lxc_string_split
(
mntent
->
mnt_opts
,
','
);
if
(
opts
)
if
(
opts
)
...
@@ -508,31 +507,42 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -508,31 +507,42 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
workdir
=
opts
[
i
]
+
len
;
workdir
=
opts
[
i
]
+
len
;
}
}
ret
=
snprintf
(
lxcpath
,
MAXPATHLEN
,
"%s/%s"
,
lxc_path
,
lxc_name
);
if
(
rootfs_path
)
{
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
ret
=
snprintf
(
lxcpath
,
MAXPATHLEN
,
"%s/%s"
,
lxc_path
,
lxc_name
);
goto
err
;
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
goto
err
;
rootfsdir
=
ovl_get_rootfs
(
rootfs
->
path
,
&
rootfslen
);
rootfsdir
=
ovl_get_rootfs
(
rootfs_
path
,
&
rootfslen
);
if
(
!
rootfsdir
)
if
(
!
rootfsdir
)
goto
err
;
goto
err
;
dirlen
=
strlen
(
lxcpath
);
dirlen
=
strlen
(
lxcpath
);
}
/*
/*
* We neither allow users to create upperdirs and workdirs outside the
* We neither allow users to create upperdirs and workdirs outside the
* containerdir nor inside the rootfs. The latter might be debatable.
* containerdir nor inside the rootfs. The latter might be debatable.
* When we have a container without a rootfs we skip the checks.
*/
*/
if
(
upperdir
)
ret
=
0
;
if
((
strncmp
(
upperdir
,
lxcpath
,
dirlen
)
==
0
)
&&
(
strncmp
(
upperdir
,
rootfsdir
,
rootfslen
)
!=
0
))
if
(
upperdir
)
{
if
(
mkdir_p
(
upperdir
,
0755
)
<
0
)
{
if
(
!
rootfs_path
)
WARN
(
"Failed to create upperdir"
);
ret
=
mkdir_p
(
upperdir
,
0755
);
}
else
if
((
strncmp
(
upperdir
,
lxcpath
,
dirlen
)
==
0
)
&&
(
strncmp
(
upperdir
,
rootfsdir
,
rootfslen
)
!=
0
))
ret
=
mkdir_p
(
upperdir
,
0755
);
if
(
workdir
)
if
(
ret
<
0
)
if
((
strncmp
(
workdir
,
lxcpath
,
dirlen
)
==
0
)
&&
(
strncmp
(
workdir
,
rootfsdir
,
rootfslen
)
!=
0
))
WARN
(
"Failed to create upperdir"
);
if
(
mkdir_p
(
workdir
,
0755
)
<
0
)
{
}
WARN
(
"Failed to create workdir"
);
}
ret
=
0
;
if
(
workdir
)
{
if
(
!
rootfs_path
)
ret
=
mkdir_p
(
workdir
,
0755
);
else
if
((
strncmp
(
workdir
,
lxcpath
,
dirlen
)
==
0
)
&&
(
strncmp
(
workdir
,
rootfsdir
,
rootfslen
)
!=
0
))
ret
=
mkdir_p
(
workdir
,
0755
);
if
(
ret
<
0
)
WARN
(
"Failed to create workdir"
);
}
fret
=
0
;
fret
=
0
;
...
...
src/lxc/conf.c
View file @
9769034f
...
@@ -1145,7 +1145,7 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1145,7 +1145,7 @@ static int fill_autodev(const struct lxc_rootfs *rootfs)
return
-
1
;
return
-
1
;
}
}
if
(
!
dir_exists
(
path
))
// ignore, just don't try to fill in
if
(
!
dir_exists
(
path
))
// ignore, just don't try to fill in
return
0
;
return
0
;
INFO
(
"Populating container /dev"
);
INFO
(
"Populating container /dev"
);
...
...
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