[libglnx] fdio: Export loop_write



commit 3c470803d08477dab9c7faada29a5f4c59dd519e
Author: Colin Walters <walters verbum org>
Date:   Sun Jan 10 21:46:45 2016 -0500

    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.

 glnx-fdio.c |    6 +++---
 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]