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
a489983a
Unverified
Commit
a489983a
authored
May 08, 2017
by
Christian Brauner
Committed by
Stéphane Graber
May 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: non-functional changes lxc_fill_autodev()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2e6347d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
conf.c
src/lxc/conf.c
+21
-14
No files found.
src/lxc/conf.c
View file @
a489983a
...
...
@@ -1113,25 +1113,24 @@ static const struct lxc_devs lxc_devs[] = {
{
"console"
,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
,
5
,
1
},
};
static
int
fill_autodev
(
const
struct
lxc_rootfs
*
rootfs
,
bool
mount_console
)
static
int
lxc_
fill_autodev
(
const
struct
lxc_rootfs
*
rootfs
,
bool
mount_console
)
{
int
ret
;
char
path
[
MAXPATHLEN
];
int
i
;
mode_t
cmask
;
INFO
(
"Creating initial consoles under container /dev"
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
ERROR
(
"Error calculating container /dev location"
);
return
-
1
;
}
if
(
!
dir_exists
(
path
))
// ignore, just don't try to fill in
/* ignore, just don't try to fill in */
if
(
!
dir_exists
(
path
))
return
0
;
INFO
(
"
P
opulating container /dev"
);
INFO
(
"
p
opulating container /dev"
);
cmask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
for
(
i
=
0
;
i
<
sizeof
(
lxc_devs
)
/
sizeof
(
lxc_devs
[
0
]);
i
++
)
{
const
struct
lxc_devs
*
d
=
&
lxc_devs
[
i
];
...
...
@@ -1142,13 +1141,20 @@ static int fill_autodev(const struct lxc_rootfs *rootfs, bool mount_console)
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev/%s"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
d
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
ret
=
mknod
(
path
,
d
->
mode
,
makedev
(
d
->
maj
,
d
->
min
));
if
(
ret
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
)
{
char
hostpath
[
MAXPATHLEN
];
FILE
*
pathfile
;
// Unprivileged containers cannot create devices, so
// bind mount the device from the host
if
(
errno
==
EEXIST
)
{
DEBUG
(
"
\"
%s
\"
device already existed"
,
path
);
continue
;
}
/* Unprivileged containers cannot create devices, so
* bind mount the device from the host.
*/
ret
=
snprintf
(
hostpath
,
MAXPATHLEN
,
"/dev/%s"
,
d
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
...
...
@@ -1158,17 +1164,18 @@ static int fill_autodev(const struct lxc_rootfs *rootfs, bool mount_console)
return
-
1
;
}
fclose
(
pathfile
);
if
(
safe_mount
(
hostpath
,
path
,
0
,
MS_BIND
,
NULL
,
rootfs
->
path
?
rootfs
->
mount
:
NULL
)
!=
0
)
{
SYSERROR
(
"Failed bind mounting device %s from host into container"
,
d
->
name
);
if
(
safe_mount
(
hostpath
,
path
,
0
,
MS_BIND
,
NULL
,
rootfs
->
path
?
rootfs
->
mount
:
NULL
)
!=
0
)
{
SYSERROR
(
"Failed bind mounting device %s from host into container"
,
d
->
name
);
return
-
1
;
}
DEBUG
(
"bind mounted
\"
%s
\"
onto
\"
%s
\"
"
,
hostpath
,
path
);
}
else
{
DEBUG
(
"created device node
\"
%s
\"
"
,
path
);
}
}
umask
(
cmask
);
INFO
(
"
P
opulated container /dev"
);
INFO
(
"
p
opulated container /dev"
);
return
0
;
}
...
...
@@ -3948,7 +3955,7 @@ int lxc_setup(struct lxc_handler *handler)
ERROR
(
"failed to run autodev hooks for container '%s'."
,
name
);
return
-
1
;
}
if
(
fill_autodev
(
&
lxc_conf
->
rootfs
,
mount_console
))
{
if
(
lxc_
fill_autodev
(
&
lxc_conf
->
rootfs
,
mount_console
))
{
ERROR
(
"failed to populate /dev in the container"
);
return
-
1
;
}
...
...
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