]> err.no Git - util-linux/commitdiff
mkswap: move write_all() to include/writeall.h
authorKarel Zak <kzak@redhat.com>
Thu, 1 Apr 2010 14:17:17 +0000 (16:17 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 1 Apr 2010 14:17:17 +0000 (16:17 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c
include/Makefile.am
include/writeall.h [new file with mode: 0644]

index 2bf07ddb2e7506e3322d5b87ecff3ebc06f5cd4f..54951991ef857ccc0c04ee604b99b2b32b8016eb 100644 (file)
@@ -53,6 +53,7 @@
 #include "blkdev.h"
 #include "pathnames.h"
 #include "wholedisk.h"
+#include "writeall.h"
 
 #ifdef HAVE_LIBUUID
 # ifdef HAVE_UUID_UUID_H
@@ -370,24 +371,6 @@ check_mount(void) {
        return 1;
 }
 
-
-static int
-write_all(int fd, const void *buf, size_t count) {
-       while(count) {
-               ssize_t tmp;
-
-               errno = 0;
-               tmp = write(fd, buf, count);
-               if (tmp > 0) {
-                       count -= tmp;
-                       if (count)
-                               buf += tmp;
-               } else if (errno != EINTR && errno != EAGAIN)
-                       return -1;
-       }
-       return 0;
-}
-
 static void
 zap_bootbits(int fd, const char *devname, int force)
 {
index 65e447d51afb19449855a3995e0936a704c9d3f3..067523d7be471c52ee1c06d75766312f51869a64 100644 (file)
@@ -23,4 +23,5 @@ dist_noinst_HEADERS = \
        crc32.h \
        mangle.h \
        strtosize.h \
-       xstrncpy.h
+       xstrncpy.h \
+       writeall.h
diff --git a/include/writeall.h b/include/writeall.h
new file mode 100644 (file)
index 0000000..a04496d
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef UTIL_LINUX_WRITEALL_H
+#define UTIL_LINUX_WRITEALL_H
+
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+static inline int write_all(int fd, const void *buf, size_t count)
+{
+       while(count) {
+               ssize_t tmp;
+
+               errno = 0;
+               tmp = write(fd, buf, count);
+               if (tmp > 0) {
+                       count -= tmp;
+                       if (count)
+                               buf += tmp;
+               } else if (errno != EINTR && errno != EAGAIN)
+                       return -1;
+       }
+       return 0;
+}
+
+#endif /* UTIL_LINUX_WRITEALL_H */