]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/failtest.h
failtest: save and restore file state inside child (on-demand)
[ccan] / ccan / failtest / failtest.h
index b304917bc6b0eece40039d6390f91c4020117811..5c80bfeea82cf74302517c0569d146561a139c68 100644 (file)
@@ -48,6 +48,7 @@ enum failtest_call_type {
        FAILTEST_WRITE,
        FAILTEST_FCNTL,
        FAILTEST_MMAP,
+       FAILTEST_LSEEK
 };
 
 struct calloc_call {
@@ -72,6 +73,10 @@ struct open_call {
        const char *pathname;
        int flags;
        mode_t mode;
+       bool always_save;
+       bool closed;
+       /* This is used for O_TRUNC opens on existing files. */
+       struct contents_saved *saved;
 };
 
 struct close_call {
@@ -98,6 +103,9 @@ struct write_call {
        const void *buf;
        size_t count;
        off_t off;
+       bool is_pwrite;
+       struct failtest_call *opener;
+       struct contents_saved *saved;
 };
 
 struct fcntl_call {
@@ -119,6 +127,16 @@ struct mmap_call {
        int flags;
        int fd;
        off_t offset;
+       struct failtest_call *opener;
+       struct contents_saved *saved;
+};
+
+struct lseek_call {
+       ssize_t ret;
+       int fd;
+       off_t offset;
+       int whence;
+       off_t old_off;
 };
 
 /**
@@ -147,7 +165,9 @@ struct failtest_call {
        /* What we set errno to. */
        int error;
        /* How do we clean this up? */
-       void (*cleanup)(void *u);
+       void (*cleanup)(void *u, bool restore);
+       /* Should their program have cleaned up? */
+       bool can_leak;
        /* Backtrace of call chain. */
        void **backtrace;
        unsigned int backtrace_num;
@@ -163,6 +183,7 @@ struct failtest_call {
                struct write_call write;
                struct fcntl_call fcntl;
                struct mmap_call mmap;
+               struct lseek_call lseek;
        } u;
 };