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.
This commit is contained in:
Michel Machado
2014-08-23 11:38:02 -04:00
parent 294fd81798
commit 73a657deec
3 changed files with 197 additions and 29 deletions

View File

@@ -34,12 +34,15 @@ 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 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);