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
49f453ae
Unverified
Commit
49f453ae
authored
Aug 01, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Aug 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: lxc_fill_autodev()
non-functional changes Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3b474fb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
conf.c
src/lxc/conf.c
+21
-13
No files found.
src/lxc/conf.c
View file @
49f453ae
...
@@ -1052,29 +1052,30 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1052,29 +1052,30 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
int
i
;
int
i
;
mode_t
cmask
;
mode_t
cmask
;
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev"
,
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
rootfs
->
path
?
rootfs
->
mount
:
""
);
ERROR
(
"Error calculating container /dev location"
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
}
/* ignore, just don't try to fill in */
/* ignore, just don't try to fill in */
if
(
!
dir_exists
(
path
))
if
(
!
dir_exists
(
path
))
return
0
;
return
0
;
INFO
(
"populating container /dev"
);
INFO
(
"Populating
\"
/dev
\"
"
);
cmask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
cmask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
for
(
i
=
0
;
i
<
sizeof
(
lxc_devs
)
/
sizeof
(
lxc_devs
[
0
]);
i
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
lxc_devs
)
/
sizeof
(
lxc_devs
[
0
]);
i
++
)
{
const
struct
lxc_devs
*
d
=
&
lxc_devs
[
i
];
const
struct
lxc_devs
*
d
=
&
lxc_devs
[
i
];
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev/%s"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
d
->
name
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"%s/dev/%s"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
d
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
ret
=
mknod
(
path
,
d
->
mode
,
makedev
(
d
->
maj
,
d
->
min
));
ret
=
mknod
(
path
,
d
->
mode
,
makedev
(
d
->
maj
,
d
->
min
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
char
hostpath
[
MAXPATHLEN
];
FILE
*
pathfile
;
FILE
*
pathfile
;
char
hostpath
[
MAXPATHLEN
];
if
(
errno
==
EEXIST
)
{
if
(
errno
==
EEXIST
)
{
DEBUG
(
"
\"
%s
\"
device already existed"
,
path
);
DEBUG
(
"
\"
%s
\"
device already existed"
,
path
);
...
@@ -1087,24 +1088,31 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1087,24 +1088,31 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
ret
=
snprintf
(
hostpath
,
MAXPATHLEN
,
"/dev/%s"
,
d
->
name
);
ret
=
snprintf
(
hostpath
,
MAXPATHLEN
,
"/dev/%s"
,
d
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
pathfile
=
fopen
(
path
,
"wb"
);
pathfile
=
fopen
(
path
,
"wb"
);
if
(
!
pathfile
)
{
if
(
!
pathfile
)
{
SYSERROR
(
"Failed to create
device mount target '%s'
"
,
path
);
SYSERROR
(
"Failed to create
file
\"
%s
\"
"
,
path
);
return
-
1
;
return
-
1
;
}
}
fclose
(
pathfile
);
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
);
ret
=
safe_mount
(
hostpath
,
path
,
0
,
MS_BIND
,
NULL
,
rootfs
->
path
?
rootfs
->
mount
:
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to bind mount
\"
%s
\"
from "
"host into container"
,
d
->
name
);
return
-
1
;
return
-
1
;
}
}
DEBUG
(
"bind mounted
\"
%s
\"
onto
\"
%s
\"
"
,
hostpath
,
path
);
DEBUG
(
"Bind mounted
\"
%s
\"
onto
\"
%s
\"
"
,
hostpath
,
path
);
}
else
{
}
else
{
DEBUG
(
"
c
reated device node
\"
%s
\"
"
,
path
);
DEBUG
(
"
C
reated device node
\"
%s
\"
"
,
path
);
}
}
}
}
umask
(
cmask
);
umask
(
cmask
);
INFO
(
"
populated container /dev
"
);
INFO
(
"
Populated
\"
/dev
\"
"
);
return
0
;
return
0
;
}
}
...
...
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