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
4de4ec76
Unverified
Commit
4de4ec76
authored
Apr 21, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Apr 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: non-functional changes to setup_pts()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
4645c74c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
25 deletions
+42
-25
conf.c
src/lxc/conf.c
+42
-25
No files found.
src/lxc/conf.c
View file @
4de4ec76
...
@@ -1394,50 +1394,67 @@ static int setup_pivot_root(const struct lxc_rootfs *rootfs)
...
@@ -1394,50 +1394,67 @@ static int setup_pivot_root(const struct lxc_rootfs *rootfs)
return
0
;
return
0
;
}
}
static
int
setup_pts
(
int
pts
)
static
int
lxc_setup_devpts
(
int
num_
pts
)
{
{
int
ret
;
char
target
[
PATH_MAX
];
char
target
[
PATH_MAX
];
char
*
devpts_mntopts
=
"newinstance,ptmxmode=0666,mode=0620,gid=5"
;
if
(
!
pts
)
if
(
!
num_pts
)
{
DEBUG
(
"no new devpts instance will be mounted since no pts "
"devices are requested"
);
return
0
;
return
0
;
if
(
!
access
(
"/dev/pts/ptmx"
,
F_OK
)
&&
umount
(
"/dev/pts"
))
{
SYSERROR
(
"failed to umount 'dev/pts'"
);
return
-
1
;
}
}
if
(
mkdir
(
"/dev/pts"
,
0755
))
{
ret
=
access
(
"/dev/pts/ptmx"
,
F_OK
);
if
(
errno
!=
EEXIST
)
{
if
(
!
ret
)
{
SYSERROR
(
"failed to create '/dev/pts'"
);
/* Unmount old devpts instance. */
return
-
1
;
ret
=
umount
(
"/dev/pts"
);
if
(
ret
<
0
)
{
SYSERROR
(
"failed to unmount old devpts instance"
);
return
-
1
;
}
}
DEBUG
(
"unmounted old /dev/pts instance"
);
}
}
if
(
mount
(
"devpts"
,
"/dev/pts"
,
"devpts"
,
MS_MGC_VAL
,
/* Create mountpoint for devpts instance. */
"newinstance,ptmxmode=0666,mode=0620,gid=5"
))
{
ret
=
mkdir
(
"/dev/pts"
,
0755
);
SYSERROR
(
"failed to mount a new instance of '/dev/pts'"
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"failed to create the
\"
/dev/pts
\"
directory"
);
return
-
1
;
return
-
1
;
}
}
if
(
access
(
"/dev/ptmx"
,
F_OK
))
{
/* Mount new devpts instance. */
if
(
!
symlink
(
"/dev/pts/ptmx"
,
"/dev/ptmx"
))
ret
=
mount
(
"devpts"
,
"/dev/pts"
,
"devpts"
,
MS_MGC_VAL
,
devpts_mntopts
);
goto
out
;
if
(
ret
<
0
)
{
SYSERROR
(
"failed to symlink '/dev/pts/ptmx'->'/dev/ptmx'"
);
SYSERROR
(
"failed to mount new devpts instance"
);
return
-
1
;
}
ret
=
access
(
"/dev/ptmx"
,
F_OK
);
if
(
ret
<
0
)
{
ret
=
symlink
(
"/dev/pts/ptmx"
,
"/dev/ptmx"
);
if
(
!
ret
)
{
DEBUG
(
"created symlink
\"
/dev/ptmx
\"
->
\"
/dev/pts/ptmx
\"
"
);
goto
success
;
}
SYSERROR
(
"failed to create symlink
\"
/dev/ptmx
\"
->
\"
/dev/pts/ptmx
\"
"
);
return
-
1
;
return
-
1
;
}
}
/* Check if any existing symlink is valid. */
if
(
realpath
(
"/dev/ptmx"
,
target
)
&&
!
strcmp
(
target
,
"/dev/pts/ptmx"
))
if
(
realpath
(
"/dev/ptmx"
,
target
)
&&
!
strcmp
(
target
,
"/dev/pts/ptmx"
))
goto
out
;
goto
success
;
/* fallback here, /dev/pts/ptmx exists just mount bind */
/* Fallback here, /dev/pts/ptmx exists so just bind mount it. */
if
(
mount
(
"/dev/pts/ptmx"
,
"/dev/ptmx"
,
"none"
,
MS_BIND
,
0
))
{
ret
=
mount
(
"/dev/pts/ptmx"
,
"/dev/ptmx"
,
"none"
,
MS_BIND
,
0
);
SYSERROR
(
"mount failed '/dev/pts/ptmx'->'/dev/ptmx'"
);
if
(
ret
<
0
)
{
SYSERROR
(
"failed to bind mount
\"
/dev/pts/ptmx
\"
to
\"
/dev/ptmx
\"
"
);
return
-
1
;
return
-
1
;
}
}
INFO
(
"created new pts instance"
);
success:
INFO
(
"created new devpts instance"
);
out:
return
0
;
return
0
;
}
}
...
@@ -4015,7 +4032,7 @@ int lxc_setup(struct lxc_handler *handler)
...
@@ -4015,7 +4032,7 @@ int lxc_setup(struct lxc_handler *handler)
return
-
1
;
return
-
1
;
}
}
if
(
setup_
pts
(
lxc_conf
->
pts
))
{
if
(
lxc_setup_dev
pts
(
lxc_conf
->
pts
))
{
ERROR
(
"failed to setup the new pts instance"
);
ERROR
(
"failed to setup the new pts instance"
);
return
-
1
;
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