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
92f023dc
Commit
92f023dc
authored
May 20, 2013
by
Christian Seiler
Committed by
Serge Hallyn
May 20, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement simple utility functions for reading and writing to fds
Signed-off-by:
Christian Seiler
<
christian@iwakd.de
>
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
65fbbb0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
utils.c
src/lxc/utils.c
+35
-0
utils.h
src/lxc/utils.h
+5
-0
No files found.
src/lxc/utils.c
View file @
92f023dc
...
...
@@ -281,3 +281,38 @@ again:
goto
again
;
return
status
;
}
int
lxc_write_nointr
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
int
ret
;
again:
ret
=
write
(
fd
,
buf
,
count
);
if
(
ret
<
0
&&
errno
==
EINTR
)
goto
again
;
return
ret
;
}
int
lxc_read_nointr
(
int
fd
,
void
*
buf
,
size_t
count
)
{
int
ret
;
again:
ret
=
read
(
fd
,
buf
,
count
);
if
(
ret
<
0
&&
errno
==
EINTR
)
goto
again
;
return
ret
;
}
int
lxc_read_nointr_expect
(
int
fd
,
void
*
buf
,
size_t
count
,
const
void
*
expected_buf
)
{
int
ret
;
ret
=
lxc_read_nointr
(
fd
,
buf
,
count
);
if
(
ret
<=
0
)
return
ret
;
if
(
ret
!=
count
)
return
-
1
;
if
(
expected_buf
&&
memcmp
(
buf
,
expected_buf
,
count
)
!=
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
return
ret
;
}
src/lxc/utils.h
View file @
92f023dc
...
...
@@ -68,4 +68,9 @@ extern int __build_bug_on_failed;
extern
int
wait_for_pid
(
pid_t
pid
);
extern
int
lxc_wait_for_pid_status
(
pid_t
pid
);
/* send and receive buffers completely */
extern
int
lxc_write_nointr
(
int
fd
,
const
void
*
buf
,
size_t
count
);
extern
int
lxc_read_nointr
(
int
fd
,
void
*
buf
,
size_t
count
);
extern
int
lxc_read_nointr_expect
(
int
fd
,
void
*
buf
,
size_t
count
,
const
void
*
expected_buf
);
#endif
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