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
79019997
Unverified
Commit
79019997
authored
Feb 03, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: fd-only operations in lxc_setup_dev_symlinks()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
81498328
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
conf.c
src/lxc/conf.c
+17
-18
No files found.
src/lxc/conf.c
View file @
79019997
...
...
@@ -781,31 +781,30 @@ static const struct dev_symlinks dev_symlinks[] = {
static
int
lxc_setup_dev_symlinks
(
const
struct
lxc_rootfs
*
rootfs
)
{
int
i
,
ret
;
char
path
[
PATH_MAX
];
struct
stat
s
;
for
(
i
=
0
;
i
<
sizeof
(
dev_symlinks
)
/
sizeof
(
dev_symlinks
[
0
]);
i
++
)
{
for
(
int
i
=
0
;
i
<
sizeof
(
dev_symlinks
)
/
sizeof
(
dev_symlinks
[
0
]);
i
++
)
{
int
ret
;
struct
stat
s
;
const
struct
dev_symlinks
*
d
=
&
dev_symlinks
[
i
];
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/%s"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
d
->
name
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
return
-
1
;
/* Stat the path first. If we don't get an error accept it as
/*
* Stat the path first. If we don't get an error accept it as
* is and don't try to create it
*/
ret
=
stat
(
path
,
&
s
);
ret
=
fstatat
(
rootfs
->
dev_mntpt_fd
,
d
->
name
,
&
s
,
0
);
if
(
ret
==
0
)
continue
;
ret
=
symlink
(
d
->
oldpath
,
path
);
if
(
ret
&&
errno
!=
EEXIST
)
{
if
(
errno
==
EROFS
)
WARN
(
"Failed to create
\"
%s
\"
. Read-only filesystem"
,
path
);
else
return
log_error_errno
(
-
1
,
errno
,
"Failed to create
\"
%s
\"
"
,
path
);
ret
=
symlinkat
(
d
->
oldpath
,
rootfs
->
dev_mntpt_fd
,
d
->
name
);
if
(
ret
)
{
switch
(
errno
)
{
case
EROFS
:
WARN
(
"Failed to create
\"
%s
\"
on read-only filesystem"
,
d
->
name
);
__fallthrough
;
case
EEXIST
:
break
;
default:
return
log_error_errno
(
-
errno
,
errno
,
"Failed to create
\"
%s
\"
"
,
d
->
name
);
}
}
}
...
...
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