From 2e55bedc45e836899a18ea7f4a488f50597afad5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 21 Sep 2024 19:31:16 +0200 Subject: misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'common.h') diff --git a/common.h b/common.h index 241f280..ad4b8a8 100644 --- a/common.h +++ b/common.h @@ -40,17 +40,23 @@ struct status { int write_average_i; struct timespec write_average_begin_times[WRAVG_STEPS]; off_t write_average_amounts[WRAVG_STEPS]; + + size_t nspans; + size_t span_off; + size_t spans_size; + struct span *spans; }; #define STATUS_INIT {.pass_nr = 1, .last_success = {-1, 0}, .direction = FORWARDS} - - -/* deadshred.c */ -extern struct status status; -extern _Atomic volatile sig_atomic_t exiting; +#define STATUS_TRANSFER_SIZE (offsetof(struct status, nspans) + sizeof(size_t)) /* io.c */ +void writeall(int fd, const void *data, size_t n, const char *fname); +void filecpy(int fd, off_t src, off_t len, const char *fname); off_t filesize(int fd, const char *fname); +#if defined(__linux__) +char *get_device_name(unsigned int devmajor, unsigned int devminor); +#endif /* fmt.c */ @@ -62,6 +68,7 @@ __attribute__((__pure__)) off_t unhumansize(const char *s, char flag); const char *durationstr(const struct timespec *dur, char *buf, int second_decimals); const char *humanbytespersecond(double bytes_per_second, char *buf); +const char *exact_and_human_size(off_t bytes, char *buf, int with_unit); /* text.c */ @@ -87,6 +94,19 @@ void used_random(ssize_t amount); /* sig.c */ +extern _Atomic volatile sig_atomic_t exiting; void setup_sighandler(void); void block_sigs(void); void unblock_sigs(void); + + +/* ask.c */ +int confirm(const char *device, off_t off, off_t len, off_t end); + + +/* map.c */ +void add_span(struct status *status, off_t off, off_t amount, size_t blocksize, int try_join); +void dump_map(int fd, const struct status *status, const char *fname); +off_t measure_map_dump(const struct status *status); +off_t load_map(int fd, struct status *status, enum direction direction, const char *fname); +void update_map(int fd, const struct status *status, const char *fname); -- cgit v1.2.3-70-g09d2