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
2b5e0b8b
Unverified
Commit
2b5e0b8b
authored
Feb 02, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file_utils: add lxc_read_try_buf_at()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
6de35cd9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
file_utils.c
src/lxc/file_utils.c
+26
-0
file_utils.h
src/lxc/file_utils.h
+2
-0
No files found.
src/lxc/file_utils.c
View file @
2b5e0b8b
...
...
@@ -122,6 +122,32 @@ int lxc_read_from_file(const char *filename, void *buf, size_t count)
return
ret
;
}
ssize_t
lxc_read_try_buf_at
(
int
dfd
,
const
char
*
path
,
void
*
buf
,
size_t
count
)
{
__do_close
int
fd
=
-
EBADF
;
ssize_t
ret
;
fd
=
open_at
(
dfd
,
path
,
PROTECT_OPEN_W
,
PROTECT_LOOKUP_BENEATH
,
0
);
if
(
fd
<
0
)
return
-
errno
;
if
(
!
buf
||
!
count
)
{
char
buf2
[
100
];
size_t
count2
=
0
;
while
((
ret
=
lxc_read_nointr
(
fd
,
buf2
,
100
))
>
0
)
count2
+=
ret
;
if
(
ret
>=
0
)
ret
=
count2
;
}
else
{
memset
(
buf
,
0
,
count
);
ret
=
lxc_read_nointr
(
fd
,
buf
,
count
);
}
return
ret
;
}
ssize_t
lxc_write_nointr
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
ssize_t
ret
;
...
...
src/lxc/file_utils.h
View file @
2b5e0b8b
...
...
@@ -94,5 +94,7 @@ __hidden int fd_make_nonblocking(int fd);
__hidden
extern
char
*
read_file_at
(
int
dfd
,
const
char
*
fnam
,
unsigned
int
o_flags
,
unsigned
resolve_flags
);
__hidden
extern
ssize_t
lxc_read_try_buf_at
(
int
dfd
,
const
char
*
path
,
void
*
buf
,
size_t
count
);
#endif
/* __LXC_FILE_UTILS_H */
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