diff options
author | Colin Walters <walters@verbum.org> | 2016-01-10 21:46:45 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2016-01-10 21:46:45 -0500 |
commit | 3c470803d08477dab9c7faada29a5f4c59dd519e (patch) | |
tree | b47fb01da09e1228ea85e04d4f65229ed7cb1d88 | |
parent | 91e060699f5559c49335ce19f4b23ba70dfd6bb3 (diff) | |
download | libglnx-3c470803d08477dab9c7faada29a5f4c59dd519e.tar.gz |
fdio: Export loop_write
I plan to use this in rpm-ostree. Sad how many times this gets
reinvented. Should probably stick a copy in `glib-unix.h` or so.
-rw-r--r-- | glnx-fdio.c | 6 | ||||
-rw-r--r-- | glnx-fdio.h | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/glnx-fdio.c b/glnx-fdio.c index 7db33c4..466cbc4 100644 --- a/glnx-fdio.c +++ b/glnx-fdio.c @@ -354,7 +354,7 @@ static int btrfs_reflink(int infd, int outfd) { return 0; } -static int loop_write(int fd, const void *buf, size_t nbytes) { +int glnx_loop_write(int fd, const void *buf, size_t nbytes) { const uint8_t *p = buf; g_return_val_if_fail(fd >= 0, -1); @@ -437,7 +437,7 @@ static int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) { if (n == 0) /* EOF */ break; - r = loop_write(fdt, buf, (size_t) n); + r = glnx_loop_write(fdt, buf, (size_t) n); if (r < 0) return r; } @@ -685,7 +685,7 @@ glnx_file_replace_contents_with_perms_at (int dfd, goto out; } - if ((r = loop_write (fd, buf, len)) != 0) + if ((r = glnx_loop_write (fd, buf, len)) != 0) { errno = -r; glnx_set_error_from_errno (error); diff --git a/glnx-fdio.h b/glnx-fdio.h index a90544a..c0fd4e4 100644 --- a/glnx-fdio.h +++ b/glnx-fdio.h @@ -102,6 +102,9 @@ glnx_readlinkat_malloc (int dfd, GCancellable *cancellable, GError **error); +int +glnx_loop_write (int fd, const void *buf, size_t nbytes); + typedef enum { GLNX_FILE_COPY_OVERWRITE, GLNX_FILE_COPY_NOXATTRS, |