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
594e5f24
Unverified
Commit
594e5f24
authored
Aug 09, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: switch mount_autodev() to new safe_mount_beneath() helper
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
4e2b86de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
conf.c
src/lxc/conf.c
+25
-20
No files found.
src/lxc/conf.c
View file @
594e5f24
...
@@ -1051,50 +1051,55 @@ on_error:
...
@@ -1051,50 +1051,55 @@ on_error:
static
int
mount_autodev
(
const
char
*
name
,
const
struct
lxc_rootfs
*
rootfs
,
static
int
mount_autodev
(
const
char
*
name
,
const
struct
lxc_rootfs
*
rootfs
,
int
autodevtmpfssize
,
const
char
*
lxcpath
)
int
autodevtmpfssize
,
const
char
*
lxcpath
)
{
{
__do_free
char
*
path
=
NULL
;
__do_close
int
root_mntpt_fd
=
-
EBADF
;
const
char
*
path
=
rootfs
->
path
?
rootfs
->
mount
:
NULL
;
int
ret
;
int
ret
;
size_t
clen
;
mode_t
cur_mask
;
mode_t
cur_mask
;
char
mount_options
[
128
];
char
mount_options
[
128
];
INFO
(
"Preparing
\"
/dev
\"
"
);
INFO
(
"Preparing
\"
/dev
\"
"
);
/* $(rootfs->mount) + "/dev/pts" + '\0' */
clen
=
(
rootfs
->
path
?
strlen
(
rootfs
->
mount
)
:
0
)
+
9
;
path
=
must_realloc
(
NULL
,
clen
);
sprintf
(
mount_options
,
"size=%d,mode=755"
,
(
autodevtmpfssize
!=
0
)
?
autodevtmpfssize
:
500000
);
sprintf
(
mount_options
,
"size=%d,mode=755"
,
(
autodevtmpfssize
!=
0
)
?
autodevtmpfssize
:
500000
);
DEBUG
(
"Using mount options: %s"
,
mount_options
);
DEBUG
(
"Using mount options: %s"
,
mount_options
);
r
et
=
snprintf
(
path
,
clen
,
"%s/dev"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
r
oot_mntpt_fd
=
openat
(
-
1
,
path
,
O_RDONLY
|
O_CLOEXEC
|
O_PATH
|
O_DIRECTORY
);
if
(
r
et
<
0
||
(
size_t
)
ret
>=
clen
)
if
(
r
oot_mntpt_fd
<
0
)
return
-
1
;
return
log_error_errno
(
-
errno
,
errno
,
"Failed to open
\"
%s
\"
"
,
path
)
;
cur_mask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
cur_mask
=
umask
(
S_IXUSR
|
S_IXGRP
|
S_IXOTH
);
ret
=
mkdir
(
path
,
S_IRWXU
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
);
ret
=
mkdir
at
(
root_mntpt_fd
,
"dev"
,
S_IRWXU
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create
\"
/dev
\"
directory"
);
SYSERROR
(
"Failed to create
\"
/dev
\"
directory"
);
ret
=
-
errno
;
ret
=
-
errno
;
goto
reset_umask
;
goto
reset_umask
;
}
}
ret
=
safe_mount
(
"none"
,
"dev"
,
"tmpfs"
,
0
,
mount_options
,
ret
=
safe_mount_beneath
(
path
,
"none"
,
"dev"
,
"tmpfs"
,
0
,
mount_options
);
rootfs
->
path
?
rootfs
->
mount
:
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount tmpfs on
\"
%s
\"
"
,
path
);
__do_free
char
*
fallback_path
=
NULL
;
goto
reset_umask
;
}
TRACE
(
"Mounted tmpfs on
\"
%s
\"
"
,
path
);
ret
=
snprintf
(
path
,
clen
,
"%s/dev/pts"
,
rootfs
->
path
?
rootfs
->
mount
:
""
);
if
(
errno
!=
ENOSYS
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
clen
)
{
SYSERROR
(
"Failed to mount tmpfs on
\"
%s
\"
"
,
path
);
ret
=
-
1
;
goto
reset_umask
;
goto
reset_umask
;
}
if
(
path
)
{
fallback_path
=
must_make_path
(
path
,
"/dev"
,
NULL
);
ret
=
safe_mount
(
"none"
,
fallback_path
,
"tmpfs"
,
0
,
mount_options
,
path
);
}
else
{
ret
=
safe_mount
(
"none"
,
"dev"
,
"tmpfs"
,
0
,
mount_options
,
NULL
);
}
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount tmpfs on
\"
%s
\"
"
,
path
);
goto
reset_umask
;
}
}
}
TRACE
(
"Mounted tmpfs on
\"
%s
\"
"
,
path
);
/* If we are running on a devtmpfs mapping, dev/pts may already exist.
/* If we are running on a devtmpfs mapping, dev/pts may already exist.
* If not, then create it and exit if that fails...
* If not, then create it and exit if that fails...
*/
*/
ret
=
mkdir
(
path
,
S_IRWXU
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
);
ret
=
mkdir
at
(
root_mntpt_fd
,
"dev/pts"
,
S_IRWXU
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
path
);
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
path
);
ret
=
-
errno
;
ret
=
-
errno
;
...
...
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