summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/fs_backing_store.c6
-rw-r--r--utils/config.h20
-rw-r--r--utils/utils.c32
3 files changed, 53 insertions, 5 deletions
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c
index 963fd5439..f2e6a387f 100644
--- a/content/fs_backing_store.c
+++ b/content/fs_backing_store.c
@@ -35,6 +35,8 @@
*
*/
+#include "utils/config.h"
+
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
@@ -1606,7 +1608,7 @@ static nserror store_write_block(struct store_state *state,
wr, bse->elem[elem_idx].size, bse->elem[elem_idx].data,
offst, bse->elem[elem_idx].block));
- if (wr != bse->elem[elem_idx].size) {
+ if (wr != (ssize_t)bse->elem[elem_idx].size) {
return NSERROR_SAVE_FAILED;
}
@@ -1754,7 +1756,7 @@ static nserror store_read_block(struct store_state *state,
rd, bse->elem[elem_idx].size, bse->elem[elem_idx].data,
offst, bse->elem[elem_idx].block));
- if (rd != bse->elem[elem_idx].size) {
+ if (rd != (ssize_t)bse->elem[elem_idx].size) {
return NSERROR_SAVE_FAILED;
}
diff --git a/utils/config.h b/utils/config.h
index c45b865fe..cfb9d83c3 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -39,7 +39,7 @@ char *strcasestr(const char *haystack, const char *needle);
#endif
/* Although these platforms might have strftime or strptime they
- * appear not to support the time_t seconds format specifier.
+ * appear not to support the time_t seconds format specifier.
*/
#if (defined(_WIN32) || defined(riscos) || defined(__HAIKU__) || defined(__BEOS__) || defined(__amigaos4__) || defined(__AMIGA__) || defined(__MINT__))
#undef HAVE_STRPTIME
@@ -49,8 +49,9 @@ char *strcasestr(const char *haystack, const char *needle);
#define HAVE_STRFTIME
#endif
-/* For some reason, UnixLib defines this unconditionally.
- * Assume we're using UnixLib if building for RISC OS. */
+/* For some reason, UnixLib defines this unconditionally. Assume we're using
+ * UnixLib if building for RISC OS.
+ */
#if ((defined(_GNU_SOURCE) && !defined(__APPLE__)) || defined(riscos))
#define HAVE_STRCHRNUL
#else
@@ -58,6 +59,19 @@ char *strcasestr(const char *haystack, const char *needle);
char *strchrnul(const char *s, int c);
#endif
+/* Although these are in POSIX and implemented most places, RISC OS is
+ * missing them.
+ */
+#if (defined(riscos))
+#undef HAVE_PREAD
+#undef HAVE_PWRITE
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+#else
+#define HAVE_PREAD
+#define HAVE_PWRITE
+#endif
+
#define HAVE_SYS_SELECT
#define HAVE_INETATON
#if (defined(_WIN32))
diff --git a/utils/utils.c b/utils/utils.c
index 5c8acd6f0..722e32302 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -32,6 +32,7 @@
#include <regex.h>
#include <time.h>
#include <errno.h>
+#include <unistd.h>
#include "utils/config.h"
#include "utils/log.h"
@@ -628,3 +629,34 @@ nserror nsc_snptimet(char *str, size_t size, time_t *timep)
return NSERROR_OK;
}
+
+#ifndef HAVE_PREAD
+
+ssize_t pread(int fd, void *buf, size_t count, off_t offset)
+{
+ off_t sk;
+
+ sk = lseek(fd, offset, SEEK_SET);
+ if (sk == -1) {
+ return (off_t)-1;
+ }
+ return read(fd, buf, count);
+}
+
+#endif
+
+
+#ifndef HAVE_PWRITE
+
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+ off_t sk;
+
+ sk = lseek(fd, offset, SEEK_SET);
+ if (sk == (off_t)-1) {
+ return -1;
+ }
+ return write(fd, buf, count);
+}
+
+#endif