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
cf5b450f
Unverified
Commit
cf5b450f
authored
Jun 01, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: handle EINTR in some read()/write()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
75fd0b34
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
28 deletions
+35
-28
conf.c
src/lxc/conf.c
+34
-27
start.c
src/lxc/start.c
+1
-1
No files found.
src/lxc/conf.c
View file @
cf5b450f
...
@@ -2253,42 +2253,49 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount)
...
@@ -2253,42 +2253,49 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount)
int
ret
;
int
ret
;
char
*
mount_entry
;
char
*
mount_entry
;
struct
lxc_list
*
iterator
;
struct
lxc_list
*
iterator
;
FILE
*
f
;
int
fd
=
-
1
;
int
fd
=
-
1
;
fd
=
memfd_create
(
"lxc_mount_file"
,
MFD_CLOEXEC
);
fd
=
memfd_create
(
"
.
lxc_mount_file"
,
MFD_CLOEXEC
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
char
template
[]
=
P_tmpdir
"/.lxc_mount_file_XXXXXX"
;
if
(
errno
!=
ENOSYS
)
if
(
errno
!=
ENOSYS
)
return
NULL
;
return
NULL
;
f
=
tmpfile
();
fd
=
lxc_make_tmpfile
(
template
,
true
);
if
(
fd
<
0
)
{
SYSERROR
(
"Could not create temporary mount file"
);
return
NULL
;
}
TRACE
(
"Created temporary mount file"
);
TRACE
(
"Created temporary mount file"
);
}
else
{
f
=
fdopen
(
fd
,
"r+"
);
TRACE
(
"Created anonymous mount file"
);
}
}
if
(
!
f
)
{
lxc_list_for_each
(
iterator
,
mount
)
{
SYSERROR
(
"Could not create mount file"
);
size_t
len
;
if
(
fd
!=
-
1
)
close
(
fd
);
return
NULL
;
}
lxc_list_for_each
(
iterator
,
mount
)
{
mount_entry
=
iterator
->
elem
;
mount_entry
=
iterator
->
elem
;
ret
=
fprintf
(
f
,
"%s
\n
"
,
mount_entry
);
len
=
strlen
(
mount_entry
);
if
(
ret
<
strlen
(
mount_entry
))
WARN
(
"Could not write mount entry to mount file"
);
}
ret
=
fseek
(
f
,
0
,
SEEK_SET
);
ret
=
lxc_write_nointr
(
fd
,
mount_entry
,
len
);
if
(
ret
<
0
)
{
if
(
ret
!=
len
)
SYSERROR
(
"Failed to seek mount file"
);
goto
on_error
;
fclose
(
f
);
return
NULL
;
ret
=
lxc_write_nointr
(
fd
,
"
\n
"
,
1
);
if
(
ret
!=
1
)
goto
on_error
;
}
}
return
f
;
ret
=
lseek
(
fd
,
0
,
SEEK_SET
);
if
(
ret
<
0
)
goto
on_error
;
return
fdopen
(
fd
,
"r+"
);
on_error:
SYSERROR
(
"Failed to write mount entry to temporary mount file"
);
close
(
fd
);
return
NULL
;
}
}
static
int
setup_mount_entries
(
const
struct
lxc_conf
*
conf
,
static
int
setup_mount_entries
(
const
struct
lxc_conf
*
conf
,
...
@@ -3638,7 +3645,7 @@ static int run_userns_fn(void *data)
...
@@ -3638,7 +3645,7 @@ static int run_userns_fn(void *data)
/* Wait for parent to finish establishing a new mapping in the user
/* Wait for parent to finish establishing a new mapping in the user
* namespace we are executing in.
* namespace we are executing in.
*/
*/
if
(
read
(
d
->
p
[
0
],
&
c
,
1
)
!=
1
)
if
(
lxc_read_nointr
(
d
->
p
[
0
],
&
c
,
1
)
!=
1
)
return
-
1
;
return
-
1
;
/* Close read end of the pipe. */
/* Close read end of the pipe. */
...
@@ -3909,7 +3916,7 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
...
@@ -3909,7 +3916,7 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
}
}
/* Tell child to proceed. */
/* Tell child to proceed. */
if
(
write
(
p
[
1
],
&
c
,
1
)
!=
1
)
{
if
(
lxc_write_nointr
(
p
[
1
],
&
c
,
1
)
!=
1
)
{
SYSERROR
(
"Failed telling child process
\"
%d
\"
to proceed"
,
pid
);
SYSERROR
(
"Failed telling child process
\"
%d
\"
to proceed"
,
pid
);
goto
on_error
;
goto
on_error
;
}
}
...
@@ -4087,8 +4094,8 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
...
@@ -4087,8 +4094,8 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
}
}
/* Tell child to proceed. */
/* Tell child to proceed. */
if
(
write
(
p
[
1
],
&
c
,
1
)
!=
1
)
{
if
(
lxc_write_nointr
(
p
[
1
],
&
c
,
1
)
!=
1
)
{
SYSERROR
(
"
f
ailed telling child process
\"
%d
\"
to proceed"
,
pid
);
SYSERROR
(
"
F
ailed telling child process
\"
%d
\"
to proceed"
,
pid
);
goto
on_error
;
goto
on_error
;
}
}
...
...
src/lxc/start.c
View file @
cf5b450f
...
@@ -307,7 +307,7 @@ static int signal_handler(int fd, uint32_t events, void *data,
...
@@ -307,7 +307,7 @@ static int signal_handler(int fd, uint32_t events, void *data,
struct
signalfd_siginfo
siginfo
;
struct
signalfd_siginfo
siginfo
;
struct
lxc_handler
*
hdlr
=
data
;
struct
lxc_handler
*
hdlr
=
data
;
ret
=
read
(
fd
,
&
siginfo
,
sizeof
(
siginfo
));
ret
=
lxc_read_nointr
(
fd
,
&
siginfo
,
sizeof
(
siginfo
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to read signal info from signal file descriptor %d"
,
fd
);
ERROR
(
"Failed to read signal info from signal file descriptor %d"
,
fd
);
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