mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 15:25:21 +00:00
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: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
391efc9d7e
commit
91b689a3a4
@@ -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);
|
||||||
|
|
||||||
|
15
util.c
15
util.c
@@ -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)) {
|
||||||
|
Reference in New Issue
Block a user