Skip to content

Instantly share code, notes, and snippets.

@ThomasWaldmann
ThomasWaldmann / faultread2.c
Created September 3, 2026 21:40
Reproducer for FreeBSD vn_io_fault1() returning more bytes than requested for >= 2 GiB read()/write() (freebsd-src PR #2407)
/*
* faultread2.c - reproduce the FreeBSD vn_io_fault1() bug: the EFAULT-redo offset
* (resid - uio->uio_resid, a size_t) is passed to uiomove(void *, int, struct uio *),
* so a first attempt that copied out >= 2 GiB before hitting a non-resident user page
* leaves the clone un-advanced and the retry loop double-counts the progress.
*
* Usage: faultread2 <file> <resident_prefix_bytes> [file_offset=18]
* The user buffer is a fresh anonymous mapping; only the first <resident_prefix_bytes>
* are touched before the read(), so the first non-resident page sits right after them.
*/
@ThomasWaldmann
ThomasWaldmann / gist:a6611d97c746fb85bc6c
Created September 12, 2015 21:19
trying to fix cython error msg
diff --git a/borg/hashindex.pyx b/borg/hashindex.pyx
index 6652e05..0b4dc26 100644
--- a/borg/hashindex.pyx
+++ b/borg/hashindex.pyx
@@ -37,7 +37,8 @@ cdef class IndexBase:
def __cinit__(self, capacity=0, path=None, key_size=32):
self.key_size = key_size
if path:
- self.index = hashindex_read(os.fsencode(path))
+ path = os.fsencode(path)