25 Commits

Author SHA1 Message Date
Michel Machado
4d913c1442 f3probe: handle failures in usb_fd_from_block_dev()
Function usb_fd_from_block_dev() wasn't releasing resources
if any error happened.

Reported-by: Peter Skensved
2015-03-30 07:36:11 -04:00
Michel Machado
902db294ef f3probe: align buffers with devices' block sizes
This patch should address issue discussed here:
https://github.com/AltraMayor/f3/issues/13

Reported-by: Dingyuan Wang
2015-02-14 10:36:07 -05:00
Michel Machado
4f13815dfc f3probe: use physical block size
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.
2015-02-14 09:56:04 -05:00
Michel Machado
ea4b33e275 f3probe: fix segmentation fault during manual reset 2015-02-04 16:48:20 -05:00
Michel Machado
d74ef39bdd f3probe: rename a variable for readability 2015-02-04 16:37:46 -05:00
Michel Machado
c3db1edd7c f3probe: improve error handling during resets 2015-02-02 14:41:17 -05:00
Michel Machado
8001dfdadd f3probe: make read_all() return negative errors
bdev_read_block(), who calls read_all(), is
expected to return negative errors.
2015-02-02 13:31:00 -05:00
Michel Machado
ac2d89a0b9 f3probe: improve manual reset
This patch handles the edge case in wich
the drive changes its size after a reset.
2015-02-02 13:31:00 -05:00
Michel Machado
ca59ef530d f3probe: deal with USB devices that support multilple drives
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.
2015-02-01 16:59:02 -05:00
Michel Machado
85d15520d4 f3probe: fix manual reset when card is removed
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.
2015-02-01 15:56:43 -05:00
Michel Machado
b70b9ce914 f3probe: improve I/O error handling 2015-01-31 20:35:26 -05:00
Michel Machado
6fbe096089 f3probe: report if the device changes its filename
Due to the resets, the device might move its filename.
For example, from `/dev/sdb' to `/dev/sdc'.
2014-12-24 10:54:44 -03:00
Michel Machado
919451abb9 f3probe: improve messages to users 2014-12-18 08:34:17 -03:00
Michel Machado
263ea4f68e f3probe: reduce code of the manual reset
One doesn't have to wait for the remove event,
only for the add event.
2014-12-18 08:30:55 -03:00
Michel Machado
506730b83f f3probe: ignore return of udev_device_unref()
It is not predictable how udev library handles
its reference counters.
2014-12-17 11:15:15 -05:00
Michel Machado
d603f2e90a f3probe: rebrand --debug-block-order to --block-order
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!
2014-12-17 11:15:15 -05:00
Michel Machado
f7ff381eaf f3probe: make error message friendlier
when the user can't run f3probe as root, direct her to
f3write/f3read.
2014-12-17 08:46:19 -05:00
Michel Machado
dd6ebe6b99 f3probe: make sure that the block device is a disk
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...
2014-12-17 08:37:18 -05:00
Michel Machado
783ef37213 f3probe: drop old manual reset
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.
2014-12-17 06:41:37 -05:00
Michel Machado
12b44e1068 f3probe: add semiautomatic reset method
This new reset method monitors the USB subsytem to know
when the drive was unplugged and when it was plugged back
to continue instead of waiting for a key to be pressed after
those actions.

The following URLs were very useful to implement this patch:

http://www.signal11.us/oss/udev/
http://www.freedesktop.org/software/systemd/libudev/
2014-12-17 06:32:30 -05:00
Michel Machado
3853dbc998 f3probe: map_block_to_usb_dev() avoids enumeration
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.
2014-12-16 13:30:45 -05:00
Michel Machado
fb8c784670 f3probe: make it more uniform to add reset methods 2014-12-16 12:01:52 -05:00
Michel Machado
f2ac688edd f3probe: issue friendly message when no access
This patch makes f3probe issue a friendly error message
when the user doesn't have access to the device to be tested.
2014-12-16 09:41:12 -05:00
Michel Machado
5e3ad28613 f3probe: improve handling of write errors 2014-10-10 14:24:39 -04:00
Michel Machado
751b5a609f add f3brew (experimental)
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.
2014-10-10 09:54:39 -04:00