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
ed41e764
Unverified
Commit
ed41e764
authored
Mar 09, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: simplify dependent mount logic
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3dd3fc31
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
conf.c
src/lxc/conf.c
+8
-7
conf.h
src/lxc/conf.h
+0
-1
start.c
src/lxc/start.c
+0
-1
No files found.
src/lxc/conf.c
View file @
ed41e764
...
@@ -3111,7 +3111,7 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf)
...
@@ -3111,7 +3111,7 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf)
}
}
/* Walk /proc/mounts and change any shared entries to dependent mounts. */
/* Walk /proc/mounts and change any shared entries to dependent mounts. */
void
turn_into_dependent_mounts
(
void
)
static
void
turn_into_dependent_mounts
(
const
struct
lxc_rootfs
*
rootfs
)
{
{
__do_free
char
*
line
=
NULL
;
__do_free
char
*
line
=
NULL
;
__do_fclose
FILE
*
f
=
NULL
;
__do_fclose
FILE
*
f
=
NULL
;
...
@@ -3120,9 +3120,10 @@ void turn_into_dependent_mounts(void)
...
@@ -3120,9 +3120,10 @@ void turn_into_dependent_mounts(void)
ssize_t
copied
;
ssize_t
copied
;
int
ret
;
int
ret
;
mntinfo_fd
=
open
(
"/proc/self/mountinfo"
,
O_RDONLY
|
O_CLOEXEC
);
mntinfo_fd
=
open_at
(
rootfs
->
dfd_host
,
"proc/self/mountinfo"
,
PROTECT_OPEN
,
(
PROTECT_LOOKUP_BENEATH_XDEV
&
~
RESOLVE_NO_SYMLINKS
),
0
);
if
(
mntinfo_fd
<
0
)
{
if
(
mntinfo_fd
<
0
)
{
SYSERROR
(
"Failed to open
\"
/proc/self/mountinfo
\"
"
);
SYSERROR
(
"Failed to open
%d/proc/self/mountinfo"
,
rootfs
->
dfd_host
);
return
;
return
;
}
}
...
@@ -3187,7 +3188,6 @@ void turn_into_dependent_mounts(void)
...
@@ -3187,7 +3188,6 @@ void turn_into_dependent_mounts(void)
SYSERROR
(
"Failed to recursively turn old root mount tree into dependent mount. Continuing..."
);
SYSERROR
(
"Failed to recursively turn old root mount tree into dependent mount. Continuing..."
);
continue
;
continue
;
}
}
TRACE
(
"Recursively turned old root mount tree into dependent mount"
);
}
}
TRACE
(
"Turned all mount table entries into dependent mount"
);
TRACE
(
"Turned all mount table entries into dependent mount"
);
}
}
...
@@ -3256,10 +3256,13 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name,
...
@@ -3256,10 +3256,13 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name,
if
(
conf
->
rootfs
.
dfd_host
<
0
)
if
(
conf
->
rootfs
.
dfd_host
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to open
\"
/
\"
"
);
return
log_error_errno
(
-
errno
,
errno
,
"Failed to open
\"
/
\"
"
);
turn_into_dependent_mounts
(
&
conf
->
rootfs
);
if
(
conf
->
rootfs_setup
)
{
if
(
conf
->
rootfs_setup
)
{
const
char
*
path
=
conf
->
rootfs
.
mount
;
const
char
*
path
=
conf
->
rootfs
.
mount
;
/* The rootfs was set up in another namespace. bind-mount it to
/*
* The rootfs was set up in another namespace. bind-mount it to
* give us a mount in our own ns so we can pivot_root to it
* give us a mount in our own ns so we can pivot_root to it
*/
*/
ret
=
mount
(
path
,
path
,
"rootfs"
,
MS_BIND
,
NULL
);
ret
=
mount
(
path
,
path
,
"rootfs"
,
MS_BIND
,
NULL
);
...
@@ -3273,8 +3276,6 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name,
...
@@ -3273,8 +3276,6 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name,
return
log_trace
(
0
,
"Bind mounted container / onto itself"
);
return
log_trace
(
0
,
"Bind mounted container / onto itself"
);
}
}
turn_into_dependent_mounts
();
ret
=
run_lxc_hooks
(
name
,
"pre-mount"
,
conf
,
NULL
);
ret
=
run_lxc_hooks
(
name
,
"pre-mount"
,
conf
,
NULL
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error
(
-
1
,
"Failed to run pre-mount hooks"
);
return
log_error
(
-
1
,
"Failed to run pre-mount hooks"
);
...
...
src/lxc/conf.h
View file @
ed41e764
...
@@ -514,7 +514,6 @@ __hidden extern int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), v
...
@@ -514,7 +514,6 @@ __hidden extern int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), v
__hidden
extern
int
parse_mntopts
(
const
char
*
mntopts
,
unsigned
long
*
mntflags
,
char
**
mntdata
);
__hidden
extern
int
parse_mntopts
(
const
char
*
mntopts
,
unsigned
long
*
mntflags
,
char
**
mntdata
);
__hidden
extern
int
parse_propagationopts
(
const
char
*
mntopts
,
unsigned
long
*
pflags
);
__hidden
extern
int
parse_propagationopts
(
const
char
*
mntopts
,
unsigned
long
*
pflags
);
__hidden
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
__hidden
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
__hidden
extern
void
turn_into_dependent_mounts
(
void
);
__hidden
extern
void
suggest_default_idmap
(
void
);
__hidden
extern
void
suggest_default_idmap
(
void
);
__hidden
extern
FILE
*
make_anonymous_mount_file
(
struct
lxc_list
*
mount
,
bool
include_nesting_helpers
);
__hidden
extern
FILE
*
make_anonymous_mount_file
(
struct
lxc_list
*
mount
,
bool
include_nesting_helpers
);
__hidden
extern
struct
lxc_list
*
sort_cgroup_settings
(
struct
lxc_list
*
cgroup_settings
);
__hidden
extern
struct
lxc_list
*
sort_cgroup_settings
(
struct
lxc_list
*
cgroup_settings
);
...
...
src/lxc/start.c
View file @
ed41e764
...
@@ -2050,7 +2050,6 @@ int __lxc_start(struct lxc_handler *handler, struct lxc_operations *ops,
...
@@ -2050,7 +2050,6 @@ int __lxc_start(struct lxc_handler *handler, struct lxc_operations *ops,
}
}
INFO
(
"Unshared CLONE_NEWNS"
);
INFO
(
"Unshared CLONE_NEWNS"
);
turn_into_dependent_mounts
();
ret
=
lxc_setup_rootfs_prepare_root
(
conf
,
name
,
lxcpath
);
ret
=
lxc_setup_rootfs_prepare_root
(
conf
,
name
,
lxcpath
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Error setting up rootfs mount as root before spawn"
);
ERROR
(
"Error setting up rootfs mount as root before spawn"
);
...
...
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