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
a5a08920
Unverified
Commit
a5a08920
authored
Feb 04, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: s/dev_mntpt_fd/dfd_dev/g
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
8ea5110c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
conf.c
src/lxc/conf.c
+26
-26
conf.h
src/lxc/conf.h
+2
-2
No files found.
src/lxc/conf.c
View file @
a5a08920
...
...
@@ -787,11 +787,11 @@ static int lxc_setup_dev_symlinks(const struct lxc_rootfs *rootfs)
* Stat the path first. If we don't get an error accept it as
* is and don't try to create it
*/
ret
=
fstatat
(
rootfs
->
d
ev_mntpt_fd
,
d
->
name
,
&
s
,
0
);
ret
=
fstatat
(
rootfs
->
d
fd_dev
,
d
->
name
,
&
s
,
0
);
if
(
ret
==
0
)
continue
;
ret
=
symlinkat
(
d
->
oldpath
,
rootfs
->
d
ev_mntpt_fd
,
d
->
name
);
ret
=
symlinkat
(
d
->
oldpath
,
rootfs
->
d
fd_dev
,
d
->
name
);
if
(
ret
)
{
switch
(
errno
)
{
case
EROFS
:
...
...
@@ -1149,7 +1149,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
mode_t
cmask
;
int
use_mknod
=
LXC_DEVNODE_MKNOD
;
if
(
rootfs
->
d
ev_mntpt_fd
<
0
)
if
(
rootfs
->
d
fd_dev
<
0
)
return
log_info
(
0
,
"No /dev directory found, skipping setup"
);
INFO
(
"Populating
\"
/dev
\"
"
);
...
...
@@ -1160,7 +1160,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
const
struct
lxc_device_node
*
device
=
&
lxc_devices
[
i
];
if
(
use_mknod
>=
LXC_DEVNODE_MKNOD
)
{
ret
=
mknodat
(
rootfs
->
d
ev_mntpt_fd
,
device
->
name
,
device
->
mode
,
makedev
(
device
->
maj
,
device
->
min
));
ret
=
mknodat
(
rootfs
->
d
fd_dev
,
device
->
name
,
device
->
mode
,
makedev
(
device
->
maj
,
device
->
min
));
if
(
ret
==
0
||
(
ret
<
0
&&
errno
==
EEXIST
))
{
DEBUG
(
"Created device node
\"
%s
\"
"
,
device
->
name
);
}
else
if
(
ret
<
0
)
{
...
...
@@ -1180,7 +1180,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
* - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=55956b59df336f6738da916dbb520b6e37df9fbd
* - https://lists.linuxfoundation.org/pipermail/containers/2018-June/039176.html
*/
fd
=
open_at
(
rootfs
->
d
ev_mntpt_fd
,
device
->
name
,
PROTECT_OPEN
,
PROTECT_LOOKUP_BENEATH
,
0
);
fd
=
open_at
(
rootfs
->
d
fd_dev
,
device
->
name
,
PROTECT_OPEN
,
PROTECT_LOOKUP_BENEATH
,
0
);
if
(
fd
>=
0
)
{
/* Device nodes are fully useable. */
use_mknod
=
LXC_DEVNODE_OPEN
;
...
...
@@ -1198,7 +1198,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
* nodes the prio mknod() call will have created the
* device node so we can use it as a bind-mount target.
*/
ret
=
mknodat
(
rootfs
->
d
ev_mntpt_fd
,
device
->
name
,
S_IFREG
|
0000
,
0
);
ret
=
mknodat
(
rootfs
->
d
fd_dev
,
device
->
name
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create file
\"
%s
\"
"
,
device
->
name
);
}
...
...
@@ -1211,7 +1211,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
ret
=
mount_from_at
(
rootfs
->
dfd_root_host
,
device_path
,
PROTECT_OPATH_FILE
,
PROTECT_LOOKUP_BENEATH_XDEV
,
rootfs
->
d
ev_mntpt_fd
,
device
->
name
,
rootfs
->
d
fd_dev
,
device
->
name
,
PROTECT_OPATH_FILE
,
PROTECT_LOOKUP_BENEATH
,
NULL
/* fstype */
,
...
...
@@ -1225,7 +1225,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
"Failed to mount %d(%s) to %d(%s)"
,
rootfs
->
dfd_root_host
,
device_path
,
rootfs
->
d
ev_mntpt_fd
,
rootfs
->
d
fd_dev
,
device
->
name
);
ret
=
snprintf
(
device_path
,
sizeof
(
device_path
),
"/dev/%s"
,
device
->
name
);
...
...
@@ -1243,7 +1243,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
DEBUG
(
"Bind mounted host device node
\"
%s
\"
to
\"
%s
\"
"
,
device_path
,
path
);
continue
;
}
DEBUG
(
"Bind mounted host device %d(%s) to %d(%s)"
,
rootfs
->
dfd_root_host
,
device_path
,
rootfs
->
d
ev_mntpt_fd
,
device
->
name
);
DEBUG
(
"Bind mounted host device %d(%s) to %d(%s)"
,
rootfs
->
dfd_root_host
,
device_path
,
rootfs
->
d
fd_dev
,
device
->
name
);
}
(
void
)
umask
(
cmask
);
...
...
@@ -1542,7 +1542,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
(
void
)
umount2
(
"/dev/pts"
,
MNT_DETACH
);
/* Create mountpoint for devpts instance. */
ret
=
mkdirat
(
rootfs
->
d
ev_mntpt_fd
,
"pts"
,
0755
);
ret
=
mkdirat
(
rootfs
->
d
fd_dev
,
"pts"
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create
\"
/dev/pts
\"
directory"
);
...
...
@@ -1572,7 +1572,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount new devpts instance"
);
DEBUG
(
"Mount new devpts instance with options
\"
%s
\"
"
,
*
opts
);
devpts_fd
=
open_at
(
rootfs
->
d
ev_mntpt_fd
,
"pts"
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
devpts_fd
=
open_at
(
rootfs
->
d
fd_dev
,
"pts"
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
devpts_fd
<
0
)
{
devpts_fd
=
-
EBADF
;
TRACE
(
"Failed to create detached devpts mount"
);
...
...
@@ -1586,7 +1586,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
TRACE
(
"Sent devpts file descriptor %d to parent"
,
devpts_fd
);
/* Remove any pre-existing /dev/ptmx file. */
ret
=
unlinkat
(
rootfs
->
d
ev_mntpt_fd
,
"ptmx"
,
0
);
ret
=
unlinkat
(
rootfs
->
d
fd_dev
,
"ptmx"
,
0
);
if
(
ret
<
0
)
{
if
(
errno
!=
ENOENT
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove existing
\"
/dev/ptmx
\"
file"
);
...
...
@@ -1595,7 +1595,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
}
/* Create dummy /dev/ptmx file as bind mountpoint for /dev/pts/ptmx. */
ret
=
mknodat
(
rootfs
->
d
ev_mntpt_fd
,
"ptmx"
,
S_IFREG
|
0000
,
0
);
ret
=
mknodat
(
rootfs
->
d
fd_dev
,
"ptmx"
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
DEBUG
(
"Created dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
...
...
@@ -1609,12 +1609,12 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
ERROR
(
"Failed to bind mount
\"
/dev/pts/ptmx
\"
to
\"
/dev/ptmx
\"
"
);
/* Remove the dummy /dev/ptmx file we created above. */
ret
=
unlinkat
(
rootfs
->
d
ev_mntpt_fd
,
"ptmx"
,
0
);
ret
=
unlinkat
(
rootfs
->
d
fd_dev
,
"ptmx"
,
0
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove existing
\"
/dev/ptmx
\"
"
);
/* Fallback option: Create symlink /dev/ptmx -> /dev/pts/ptmx. */
ret
=
symlinkat
(
"/dev/pts/ptmx"
,
rootfs
->
d
ev_mntpt_fd
,
"/dev/ptmx"
);
ret
=
symlinkat
(
"/dev/pts/ptmx"
,
rootfs
->
d
fd_dev
,
"/dev/ptmx"
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create symlink from
\"
/dev/ptmx
\"
to
\"
/dev/pts/ptmx
\"
"
);
...
...
@@ -1660,7 +1660,7 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
* When we are asked to setup a console we remove any previous
* /dev/console bind-mounts.
*/
if
(
exists_file_at
(
rootfs
->
d
ev_mntpt_fd
,
"console"
))
{
if
(
exists_file_at
(
rootfs
->
d
fd_dev
,
"console"
))
{
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/console"
,
rootfs_path
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
return
-
1
;
...
...
@@ -1676,7 +1676,7 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
* For unprivileged containers autodev or automounts will already have
* taken care of creating /dev/console.
*/
ret
=
mknodat
(
rootfs
->
d
ev_mntpt_fd
,
"console"
,
S_IFREG
|
0000
,
0
);
ret
=
mknodat
(
rootfs
->
d
fd_dev
,
"console"
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create console"
);
...
...
@@ -1685,19 +1685,19 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
return
log_error_errno
(
-
errno
,
errno
,
"Failed to set mode
\"
0%o
\"
to
\"
%s
\"
"
,
S_IXUSR
|
S_IXGRP
,
console
->
name
);
if
(
pty_mnt_fd
>=
0
)
{
ret
=
move_mount
(
pty_mnt_fd
,
""
,
rootfs
->
d
ev_mntpt_fd
,
"console"
,
MOVE_MOUNT_F_EMPTY_PATH
);
ret
=
move_mount
(
pty_mnt_fd
,
""
,
rootfs
->
d
fd_dev
,
"console"
,
MOVE_MOUNT_F_EMPTY_PATH
);
if
(
!
ret
)
{
DEBUG
(
"Moved mount
\"
%s
\"
onto %d(console)"
,
console
->
name
,
rootfs
->
d
ev_mntpt_fd
);
DEBUG
(
"Moved mount
\"
%s
\"
onto %d(console)"
,
console
->
name
,
rootfs
->
d
fd_dev
);
return
0
;
}
if
(
ret
&&
errno
!=
ENOSYS
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount %d(%s) on %d(console)"
,
pty_mnt_fd
,
console
->
name
,
rootfs
->
d
ev_mntpt_fd
);
pty_mnt_fd
,
console
->
name
,
rootfs
->
d
fd_dev
);
}
ret
=
safe_mount_beneath_at
(
rootfs
->
d
ev_mntpt_fd
,
console
->
name
,
"console"
,
NULL
,
MS_BIND
,
NULL
);
ret
=
safe_mount_beneath_at
(
rootfs
->
d
fd_dev
,
console
->
name
,
"console"
,
NULL
,
MS_BIND
,
NULL
);
if
(
ret
<
0
)
{
if
(
errno
==
ENOSYS
)
{
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/console"
,
rootfs_path
);
...
...
@@ -2634,7 +2634,7 @@ struct lxc_conf *lxc_conf_init(void)
}
new
->
rootfs
.
managed
=
true
;
new
->
rootfs
.
mntpt_fd
=
-
EBADF
;
new
->
rootfs
.
d
ev_mntpt_fd
=
-
EBADF
;
new
->
rootfs
.
d
fd_dev
=
-
EBADF
;
new
->
rootfs
.
dfd_root_host
=
-
EBADF
;
new
->
logfd
=
-
1
;
lxc_list_init
(
&
new
->
cgroup
);
...
...
@@ -3415,10 +3415,10 @@ int lxc_setup(struct lxc_handler *handler)
return
log_error
(
-
1
,
"Failed to mount
\"
/dev
\"
"
);
}
lxc_conf
->
rootfs
.
d
ev_mntpt_fd
=
open_at
(
lxc_conf
->
rootfs
.
mntpt_fd
,
"dev"
,
lxc_conf
->
rootfs
.
d
fd_dev
=
open_at
(
lxc_conf
->
rootfs
.
mntpt_fd
,
"dev"
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
lxc_conf
->
rootfs
.
d
ev_mntpt_fd
<
0
&&
errno
!=
ENOENT
)
if
(
lxc_conf
->
rootfs
.
d
fd_dev
<
0
&&
errno
!=
ENOENT
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to open
\"
/dev
\"
"
);
/* Do automatic mounts (mainly /proc and /sys), but exclude those that
...
...
@@ -3541,7 +3541,7 @@ int lxc_setup(struct lxc_handler *handler)
}
close_prot_errno_disarm
(
lxc_conf
->
rootfs
.
mntpt_fd
)
close_prot_errno_disarm
(
lxc_conf
->
rootfs
.
d
ev_mntpt_fd
)
close_prot_errno_disarm
(
lxc_conf
->
rootfs
.
d
fd_dev
)
close_prot_errno_disarm
(
lxc_conf
->
rootfs
.
dfd_root_host
)
NOTICE
(
"The container
\"
%s
\"
is set up"
,
name
);
...
...
@@ -3907,7 +3907,7 @@ void lxc_conf_free(struct lxc_conf *conf)
free
(
conf
->
rootfs
.
path
);
free
(
conf
->
rootfs
.
data
);
close_prot_errno_disarm
(
conf
->
rootfs
.
mntpt_fd
);
close_prot_errno_disarm
(
conf
->
rootfs
.
d
ev_mntpt_fd
);
close_prot_errno_disarm
(
conf
->
rootfs
.
d
fd_dev
);
close_prot_errno_disarm
(
conf
->
rootfs
.
dfd_root_host
);
free
(
conf
->
logfile
);
if
(
conf
->
logfd
!=
-
1
)
...
...
src/lxc/conf.h
View file @
a5a08920
...
...
@@ -191,12 +191,12 @@ struct lxc_tty_info {
* @data : the portion of @options that are not flags
* @managed : whether it is managed by LXC
* @mntpt_fd : fd for @mount
* @d
ev_mntpt_fd
: fd for /dev of the container
* @d
fd_dev
: fd for /dev of the container
*/
struct
lxc_rootfs
{
int
dfd_root_host
;
int
mntpt_fd
;
int
d
ev_mntpt_fd
;
int
d
fd_dev
;
char
*
path
;
char
*
mount
;
char
buf
[
PATH_MAX
];
...
...
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