Files
f3-mirror/libprobe.h
Michel Machado 73a657deec f3probe: protect block device
This patch makes f3probe read and save in memory
the content of all written blocks before writting them
during the probe, and restore the original content of those blocks
after probing the device.
In order words, f3probe behaves likes the probed device were
read only.

All the necessary memory to protect the probed device is
preallocated, so an on-going probe does not fail due to
lack of memory.

Although this feature adds an important protection layer,
users should be conscious that things can go wrong, and
the data will be lost.

This patch also adds option --debug-keep-file to help debugging
the new code this patch adds, and option --destructive to disable
the protection.
2014-09-21 13:02:03 -04:00

50 lines
1.2 KiB
C

#ifndef HEADER_LIBPROBE_H
#define HEADER_LIBPROBE_H
#include <stdint.h>
enum fake_type {
/* Device is good. */
FKTY_GOOD,
/* Device is at least partially damaged. */
FKTY_BAD,
/* Device discards data after a given limit. */
FKTY_LIMBO,
/* Device overwrites data after a given limit. */
FKTY_WRAPAROUND,
/* Device is a sequence of wraparound and limbo regions. */
FKTY_CHAIN,
FKTY_MAX,
};
const char *fake_type_to_name(enum fake_type fake_type);
int dev_param_valid(uint64_t real_size_byte,
uint64_t announced_size_byte, int wrap, int block_order);
enum fake_type dev_param_to_type(uint64_t real_size_byte,
uint64_t announced_size_byte, int wrap, int block_order);
struct device;
struct device *create_file_device(const char *filename,
uint64_t real_size_byte, uint64_t fake_size_byte, int wrap,
int block_order, int keep_file);
struct device *create_block_device(const char *filename);
struct device *create_safe_device(struct device *dev, int max_blocks);
void free_device(struct device *dev);
int probe_device_max_blocks(struct device *dev);
void probe_device(struct device *dev, uint64_t *preal_size_byte,
uint64_t *pannounced_size_byte, int *pwrap, int *block_order);
#endif /* HEADER_LIBPROBE_H */