Commit 91b689a3 authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Pavel Emelyanov

Introduce the read_into_buffer helper

This will be required for page-cache and page-proxy set.

Signed-off-by: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 391efc9d
...@@ -267,6 +267,7 @@ FILE *fopenat(int dirfd, char *path, char *cflags); ...@@ -267,6 +267,7 @@ FILE *fopenat(int dirfd, char *path, char *cflags);
void split(char *str, char token, char ***out, int *n); void split(char *str, char token, char ***out, int *n);
int fd_has_data(int lfd); int fd_has_data(int lfd);
size_t read_into_buffer(int fd, char *buff, size_t size);
int make_yard(char *path); int make_yard(char *path);
......
...@@ -872,6 +872,21 @@ int fd_has_data(int lfd) ...@@ -872,6 +872,21 @@ int fd_has_data(int lfd)
return ret; return ret;
} }
size_t read_into_buffer(int fd, char *buff, size_t size)
{
size_t n = 0;
size_t curr = 0;
while (1) {
n = read(fd, buff + curr, size - curr);
if (n < 1)
return n;
curr += n;
if (curr == size)
return size;
}
}
int make_yard(char *path) int make_yard(char *path)
{ {
if (mount("none", path, "tmpfs", 0, NULL)) { if (mount("none", path, "tmpfs", 0, NULL)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment