From 7c6f3ece662709ab596469d173ec5f4826e601ce Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Thu, 20 Aug 2015 15:55:12 +0100 Subject: [PATCH 1/3] Initialize chunker fd to -1, so it's not equal to STDIN_FILENO (0) --- borg/_chunker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/borg/_chunker.c b/borg/_chunker.c index 5e599ed89..9dbed1fa5 100644 --- a/borg/_chunker.c +++ b/borg/_chunker.c @@ -96,6 +96,7 @@ chunker_init(int window_size, int chunk_mask, int min_size, int max_size, uint32 c->table = buzhash_init_table(seed); c->buf_size = max_size; c->data = malloc(c->buf_size); + c->fh = -1; return c; } From ce3e67cb96f5a189a2f93d5d4847d7dd4b5aea78 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Thu, 20 Aug 2015 17:19:48 +0100 Subject: [PATCH 2/3] chunker - fix 4GB files on 32-bit systems From code inspection - effect not actually tested. --- borg/_chunker.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/borg/_chunker.c b/borg/_chunker.c index 9dbed1fa5..8242a2243 100644 --- a/borg/_chunker.c +++ b/borg/_chunker.c @@ -83,7 +83,8 @@ typedef struct { PyObject *fd; int fh; int done, eof; - size_t remaining, bytes_read, bytes_yielded, position, last; + size_t remaining, position, last; + off_t bytes_read, bytes_yielded; } Chunker; static Chunker * From 59a44296e4e6aace3c0fe0154fc1a27a7a75bee6 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Thu, 20 Aug 2015 17:48:59 +0100 Subject: [PATCH 3/3] chunker - cast from size_t to off_t can now be removed Sorry, this should really have been part of the previous commit - it's why I noticed a problem. --- borg/_chunker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/borg/_chunker.c b/borg/_chunker.c index 8242a2243..23abf1e6c 100644 --- a/borg/_chunker.c +++ b/borg/_chunker.c @@ -163,7 +163,7 @@ chunker_fill(Chunker *c) // size limit) kick out data from the cache that might be still useful // for the OS or other processes. if (length > 0) { - posix_fadvise(c->fh, (off_t) offset, (off_t) length, POSIX_FADV_DONTNEED); + posix_fadvise(c->fh, offset, length, POSIX_FADV_DONTNEED); } #endif }