f3probe was using a kernel-recommended logical block size.
This patch allows f3probe to always find
the last good physical block of devices.
This patch also renames option --block-order to --debug-block-order
since f3probe detects the physical block size of devices.
During manual resets, the drive was being identified by
idVendor, idProduct, and serial, what is NOT enough when
the USB device combines two or more drives.
For example the card reader Kingston MobileLite G3
supports two memory cards at the same time.
Discussion on the fixed issue is available here:
https://github.com/AltraMayor/f3/issues/10
User @derekchal was the first to report this problem.
When the memory card in a card reader is removed,
the device is kept, not removed like in the case
the reader itself is unplugged.
This patch handles the `change' events that are generated in
the card-removal case.
The new parameter allows users to test drives with
forced block sizes.
This parameter is only meant to help testing drives whose
*real* sizes are not multiples of their block sizes;
this should be rather rare!
This patch makes f3probe test that the block device passed is
a disk, not a partition or something else.
If the block device is a partition,
the correct disk device is reported.
Example of this new protection in action:
$ sudo f3probe /dev/sdb1
[sudo] password for michel:
F3 probe 4.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.
Device `/dev/sdb1' is a partition of disk device `/dev/sdb'.
You can run this program as follows:
f3probe /dev/sdb
Application cannot continue, finishing...
The code of the old manual reset couldn't handle the case of
the drive changing its filename, i.e. "/dev/sdb" becomes
"/dev/sdc" after the drive is unplugged and plugged back.
Not only this is a bug, in the rare case the user is
testing multiple drives at the same time, this would lead
to bad behavior.
Function map_block_to_usb_dev() was enumerating all USB devices and
comparing their properties to find the one we need.
The new code directly resolves the device from major and minor
number of the block device.
f3brew, f3 block read write, tests block devices
writing and reading blocks directly to devices.
This is a not-functional version of f3brew.
The main contribution of this patch is to reorganize libprobe.{h,c},
so f3brew, and any future application, can reuse the library.