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
5e64d01b
Unverified
Commit
5e64d01b
authored
Jul 05, 2018
by
Serge Hallyn
Committed by
GitHub
Jul 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2450 from brauner/2018-07-05/use_mknod
conf: use mknod() to create dummy mount targets
parents
9449f425
31ae1655
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
30 deletions
+15
-30
conf.c
src/lxc/conf.c
+15
-25
terminal.c
src/lxc/terminal.c
+0
-5
No files found.
src/lxc/conf.c
View file @
5e64d01b
...
@@ -892,7 +892,7 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
...
@@ -892,7 +892,7 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
lxcpath
))
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
lxcpath
))
return
-
1
;
return
-
1
;
ret
=
mknod
(
path
,
S_IFREG
,
0
);
ret
=
mknod
(
path
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create
\"
%s
\"
"
,
lxcpath
);
SYSERROR
(
"Failed to create
\"
%s
\"
"
,
lxcpath
);
return
-
1
;
return
-
1
;
...
@@ -1303,7 +1303,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
...
@@ -1303,7 +1303,7 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs)
can_mknod
=
0
;
can_mknod
=
0
;
}
}
ret
=
mknod
(
path
,
S_IFREG
,
0
);
ret
=
mknod
(
path
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create file
\"
%s
\"
"
,
path
);
SYSERROR
(
"Failed to create file
\"
%s
\"
"
,
path
);
return
-
1
;
return
-
1
;
...
@@ -1593,12 +1593,11 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
...
@@ -1593,12 +1593,11 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
}
}
/* Create dummy /dev/ptmx file as bind mountpoint for /dev/pts/ptmx. */
/* Create dummy /dev/ptmx file as bind mountpoint for /dev/pts/ptmx. */
ret
=
open
(
"/dev/ptmx"
,
O_CREAT
,
0666
);
ret
=
mknod
(
"/dev/ptmx"
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
SYSERROR
(
"Failed to create dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
return
-
1
;
return
-
1
;
}
}
close
(
ret
);
DEBUG
(
"Created dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
DEBUG
(
"Created dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
/* Fallback option: create symlink /dev/ptmx -> /dev/pts/ptmx */
/* Fallback option: create symlink /dev/ptmx -> /dev/pts/ptmx */
...
@@ -1680,12 +1679,10 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
...
@@ -1680,12 +1679,10 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
* taken care of creating /dev/console.
* taken care of creating /dev/console.
*/
*/
ret
=
mknod
(
path
,
S_IFREG
|
0000
,
0
);
ret
=
mknod
(
path
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create console"
);
SYSERROR
(
"Failed to create console"
);
return
-
errno
;
return
-
errno
;
}
}
}
ret
=
fchmod
(
console
->
slave
,
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
ret
=
fchmod
(
console
->
slave
,
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -1708,7 +1705,7 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
...
@@ -1708,7 +1705,7 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
const
struct
lxc_terminal
*
console
,
const
struct
lxc_terminal
*
console
,
char
*
ttydir
)
char
*
ttydir
)
{
{
int
ret
,
fd
;
int
ret
;
char
path
[
MAXPATHLEN
],
lxcpath
[
MAXPATHLEN
];
char
path
[
MAXPATHLEN
],
lxcpath
[
MAXPATHLEN
];
char
*
rootfs_path
=
rootfs
->
path
?
rootfs
->
mount
:
""
;
char
*
rootfs_path
=
rootfs
->
path
?
rootfs
->
mount
:
""
;
...
@@ -1731,13 +1728,11 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
...
@@ -1731,13 +1728,11 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
lxcpath
))
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
lxcpath
))
return
-
1
;
return
-
1
;
ret
=
creat
(
lxcpath
,
066
0
);
ret
=
mknod
(
lxcpath
,
S_IFREG
|
0000
,
0
);
if
(
ret
==
-
1
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create
\"
%s
\"
"
,
lxcpath
);
SYSERROR
(
"Failed to create
\"
%s
\"
"
,
lxcpath
);
return
-
errno
;
return
-
errno
;
}
}
if
(
ret
>=
0
)
close
(
ret
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/console"
,
rootfs_path
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/console"
,
rootfs_path
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
...
@@ -1753,17 +1748,13 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
...
@@ -1753,17 +1748,13 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
}
}
}
}
fd
=
open
(
path
,
O_CREAT
|
O_EXCL
,
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
ret
=
mknod
(
path
,
S_IFREG
|
0000
,
0
);
if
(
fd
<
0
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create console"
);
SYSERROR
(
"Failed to create console"
);
return
-
errno
;
return
-
errno
;
}
}
}
else
{
close
(
fd
);
}
ret
=
chmod
(
console
->
nam
e
,
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
ret
=
fchmod
(
console
->
slav
e
,
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set mode
\"
0%o
\"
to
\"
%s
\"
"
,
SYSERROR
(
"Failed to set mode
\"
0%o
\"
to
\"
%s
\"
"
,
S_IXUSR
|
S_IXGRP
|
S_IXOTH
,
console
->
name
);
S_IXUSR
|
S_IXGRP
|
S_IXOTH
,
console
->
name
);
...
@@ -2079,7 +2070,7 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
...
@@ -2079,7 +2070,7 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
const
struct
lxc_rootfs
*
rootfs
,
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
const
char
*
lxc_name
,
const
char
*
lxc_path
)
{
{
int
fd
,
ret
;
int
ret
;
char
*
p1
,
*
p2
;
char
*
p1
,
*
p2
;
if
(
strncmp
(
mntent
->
mnt_type
,
"overlay"
,
7
)
==
0
)
{
if
(
strncmp
(
mntent
->
mnt_type
,
"overlay"
,
7
)
==
0
)
{
...
@@ -2116,10 +2107,9 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
...
@@ -2116,10 +2107,9 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
return
-
1
;
return
-
1
;
}
}
fd
=
open
(
path
,
O_CREAT
,
0644
);
ret
=
mknod
(
path
,
S_IFREG
|
0000
,
0
);
if
(
fd
<
0
)
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
-
1
;
return
-
errno
;
close
(
fd
);
return
0
;
return
0
;
}
}
...
...
src/lxc/terminal.c
View file @
5e64d01b
...
@@ -922,7 +922,6 @@ int lxc_terminal_setup(struct lxc_conf *conf)
...
@@ -922,7 +922,6 @@ int lxc_terminal_setup(struct lxc_conf *conf)
{
{
int
ret
;
int
ret
;
struct
lxc_terminal
*
terminal
=
&
conf
->
console
;
struct
lxc_terminal
*
terminal
=
&
conf
->
console
;
struct
termios
oldtios
;
if
(
terminal
->
path
&&
strcmp
(
terminal
->
path
,
"none"
)
==
0
)
{
if
(
terminal
->
path
&&
strcmp
(
terminal
->
path
,
"none"
)
==
0
)
{
INFO
(
"No terminal requested"
);
INFO
(
"No terminal requested"
);
...
@@ -933,10 +932,6 @@ int lxc_terminal_setup(struct lxc_conf *conf)
...
@@ -933,10 +932,6 @@ int lxc_terminal_setup(struct lxc_conf *conf)
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
ret
=
lxc_setup_tios
(
terminal
->
master
,
&
oldtios
);
if
(
ret
<
0
)
return
-
1
;
ret
=
lxc_terminal_create_log_file
(
terminal
);
ret
=
lxc_terminal_create_log_file
(
terminal
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
err
;
goto
err
;
...
...
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