14 Commits

Author SHA1 Message Date
Michel Machado
a952fb7244 f3probe: probe with less resets
Of all three operations called on the flash drive being probed
(i.e. reading blocks, writing blocks, and resetting the drive),
the most time-consuming operation is reliably resetting the drive.

This patch reduces the number of resets writing and reading
more blocks.
2014-09-21 18:48:55 -04:00
Michel Machado
312c9170e7 f3probe: add option --min-memory
This option instructs f3probe to trade speed for less memory usage,
that is, f3probe minimizes use of memory.

Currently, this option only drops the use of the bitmap of
the safe device.
Nevertheless, this is not negligible memory.
For example, a 1TB drive whose block size is 512 Bytes requires
256MB of RAM for this bitmap:

  1TB / 512Byte/Block = 2^31Block
  2^31Block / 1Block/bit = 2^31bit
  2^31bit / 8bit/Byte = 2^28Byte = 256MB

To put it in context, 256MB of RAM was all that
Raspberry Pi Model A had.
2014-09-21 17:11:37 -04:00
Michel Machado
35a351ff39 f3probe: add option --manual-reset
The current reset method isn't supported for all USB drives,
what leads to wrong conclusions about some fake drives.

The option --manual-reset allows users to unplug and plug back
the USB drive being tested to manually reset the drive.
2014-09-21 17:09:01 -04:00
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
Michel Machado
294fd81798 f3probe: add block size to the drive model
Using the correct block size of the block device can improve
communication speed with the device.
2014-09-21 11:56:38 -04:00
Michel Machado
02a3b25fcb f3probe: fix bug at search_wrap()
search_wrap() was considering @high_bit to be in blocks,
but it was in bytes.

This patch also improves the unit test to catch the fixed bug, and
to use real geometries.
2014-09-21 11:56:38 -04:00
Michel Machado
ea938f2ff2 f3probe: rewrite file device
This patch makes file devices use the same geometry model that
probe_device() probes for.

This change helps one to test whatever probe_device() finds in
the field.
2014-09-21 11:56:38 -04:00
Michel Machado
6a63a5fff4 f3probe: improve report
- Show copyright header.
- Use friendly and precise units.
- Measure and show time to probe device.
2014-09-21 11:56:38 -04:00
Michel Machado
d940ecd19a f3probe: improve probe_device()
- It works with drives of any size.
- It precisely identifies the real size of drives.
- It identify the geometry of the drive.
2014-09-21 11:56:38 -04:00
Michel Machado
ceb79aae4e f3probe: improve debugging facility 2014-09-21 11:56:38 -04:00
Michel Machado
7f9f5972d0 f3probe: add unit test 2014-09-21 11:47:20 -04:00
Michel Machado
28808f31b5 f3probe: move (missing) action to libprobe.c 2014-09-21 11:47:19 -04:00
Michel Machado
99dab5ca08 Make all applications share the same version 2014-09-21 11:47:19 -04:00
Michel Machado
b7790256f0 Skeleton of F3 probe 2014-09-21 11:43:59 -04:00