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
2095b6d8
Unverified
Commit
2095b6d8
authored
Jun 04, 2018
by
Serge Hallyn
Committed by
GitHub
Jun 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2374 from brauner/2018-06-04/fix_remount_all_slave
conf: copy mountinfo for remount_all_slave()
parents
fe96566a
6a49f05e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
3 deletions
+56
-3
conf.c
src/lxc/conf.c
+56
-3
No files found.
src/lxc/conf.c
View file @
2095b6d8
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/param.h>
#include <sys/prctl.h>
#include <sys/prctl.h>
#include <sys/sendfile.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/syscall.h>
...
@@ -3178,14 +3179,63 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf)
...
@@ -3178,14 +3179,63 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf)
/* Walk /proc/mounts and change any shared entries to slave. */
/* Walk /proc/mounts and change any shared entries to slave. */
void
remount_all_slave
(
void
)
void
remount_all_slave
(
void
)
{
{
int
memfd
,
mntinfo_fd
,
ret
;
ssize_t
copied
;
FILE
*
f
;
FILE
*
f
;
size_t
len
=
0
;
size_t
len
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
f
=
fopen
(
"/proc/self/mountinfo"
,
"r"
);
mntinfo_fd
=
open
(
"/proc/self/mountinfo"
,
O_RDONLY
|
O_CLOEXEC
);
if
(
mntinfo_fd
<
0
)
return
;
memfd
=
memfd_create
(
".lxc_mountinfo"
,
MFD_CLOEXEC
);
if
(
memfd
<
0
)
{
char
template
[]
=
P_tmpdir
"/.lxc_mountinfo_XXXXXX"
;
if
(
errno
!=
ENOSYS
)
{
close
(
mntinfo_fd
);
WARN
(
"Failed to create temporary in-memory file"
);
return
;
}
memfd
=
lxc_make_tmpfile
(
template
,
true
);
}
if
(
memfd
<
0
)
{
close
(
mntinfo_fd
);
WARN
(
"Failed to create temporary file"
);
return
;
}
#define __LXC_SENDFILE_MAX 0x7ffff000
/* maximum number of bytes sendfile can handle */
again:
copied
=
sendfile
(
memfd
,
mntinfo_fd
,
NULL
,
__LXC_SENDFILE_MAX
);
if
(
copied
<
0
)
{
if
(
errno
==
EINTR
)
goto
again
;
close
(
mntinfo_fd
);
close
(
memfd
);
WARN
(
"Failed to copy
\"
/proc/self/mountinfo
\"
"
);
return
;
}
close
(
mntinfo_fd
);
/* After a successful fdopen() memfd will be closed when calling
* fclose(f). Calling close(memfd) afterwards is undefined.
*/
ret
=
lseek
(
memfd
,
0
,
SEEK_SET
);
if
(
ret
<
0
)
{
close
(
memfd
);
WARN
(
"%s - Failed to reset file descriptor offset"
,
strerror
(
errno
));
return
;
}
f
=
fdopen
(
memfd
,
"r"
);
if
(
!
f
)
{
if
(
!
f
)
{
SYSERROR
(
"Failed to open
\"
/proc/self/mountinfo
\"
to mark all shared"
);
WARN
(
"Failed to open copy of
\"
/proc/self/mountinfo
\"
to mark "
ERROR
(
"Continuing container startup..."
);
"all shared. Continuing"
);
close
(
memfd
);
return
;
return
;
}
}
...
@@ -3210,10 +3260,13 @@ void remount_all_slave(void)
...
@@ -3210,10 +3260,13 @@ void remount_all_slave(void)
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to make
\"
%s
\"
MS_SLAVE"
,
target
);
SYSERROR
(
"Failed to make
\"
%s
\"
MS_SLAVE"
,
target
);
ERROR
(
"Continuing..."
);
ERROR
(
"Continuing..."
);
continue
;
}
}
TRACE
(
"Remounted
\"
%s
\"
as MS_SLAVE"
,
target
);
}
}
fclose
(
f
);
fclose
(
f
);
free
(
line
);
free
(
line
);
TRACE
(
"Remounted all mount table entries as MS_SLAVE"
);
}
}
static
int
lxc_execute_bind_init
(
struct
lxc_handler
*
handler
)
static
int
lxc_execute_bind_init
(
struct
lxc_handler
*
handler
)
...
...
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