summaryrefslogtreecommitdiffstats
path: root/ctdb/common/system_util.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-07-30 20:50:59 +1000
committerAmitay Isaacs <amitay@samba.org>2014-08-21 04:46:13 +0200
commitfcd6ee1eac8627e75f72019027513cc46429a3a9 (patch)
tree4fec864fc6dad9658a6740ca6fdf85f0323a7273 /ctdb/common/system_util.c
parent72fa984423b77eaddb16b63e6c3857600e054836 (diff)
downloadsamba-fcd6ee1eac8627e75f72019027513cc46429a3a9.tar.gz
samba-fcd6ee1eac8627e75f72019027513cc46429a3a9.tar.xz
samba-fcd6ee1eac8627e75f72019027513cc46429a3a9.zip
ctdb-common: Copy functions sys_read() and sys_write() from source3
We really should extricate these from source3 and into some common code. However, just copy them for now to help get rid of a lot of warnings. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/common/system_util.c')
-rw-r--r--ctdb/common/system_util.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c
index fe0f403f48..344e7d797e 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system_util.c
@@ -369,3 +369,37 @@ void mkdir_p_or_die(const char *dir, int mode)
exit(1);
}
}
+
+/* A read wrapper that will deal with EINTR. For now, copied from
+ * source3/lib/system.c
+ */
+ssize_t sys_read(int fd, void *buf, size_t count)
+{
+ ssize_t ret;
+
+ do {
+ ret = read(fd, buf, count);
+#if defined(EWOULDBLOCK)
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
+#else
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+#endif
+ return ret;
+}
+
+/* A write wrapper that will deal with EINTR. For now, copied from
+ * source3/lib/system.c
+ */
+ssize_t sys_write(int fd, const void *buf, size_t count)
+{
+ ssize_t ret;
+
+ do {
+ ret = write(fd, buf, count);
+#if defined(EWOULDBLOCK)
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
+#else
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+#endif
+ return ret;
+}