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.
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.
The code is based on udev_example.c available on the following page:
libudev and Sysfs Tutorial
http://www.signal11.us/oss/udev/
f3probe nows requires library libudev.
This patch also updates the following files to reflect
the dependency of f3probe on libudev, and
the experimental status of f3probe: Makefile and README.
The internal cache of the USB drive was keeping all recent writes,
so subsequents reads were correct even when the underlying
storage was faulty.
The code is based on usbreset.c available on the following page:
How do you reset a USB device from the command line?
http://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line
- Addopt -ggdb to add debugging information to binary.
- Add cscope target to help navigating the code.
- Add cscope.out to .gitignore.
- Add *.swp to .gitignore.
- Change compiling flag -Wpedantic to -pedantic.
Flag -Wpedantic is not available in older versions of gcc,
what makes the life of some users unnecessarily harder.
Not to mention that both flags work fine for F3.
- Allow make variable CC to be set externally.
Some platforms favor other C compilers.
For example, FreeBSD defaults to clang.
- Allow make variable CFLAGS to be extended externally.
This helps packaging.
- Target clean to also remove *.d files.
The three first improvements were suggested by
Thomas Fischer and Uffe Jakobsen.
The discussion is available here:
https://github.com/AltraMayor/f3/issues/4
This patch improves the progress percentage and estimate of
time to finish when option --end-at requires f3write to write
less than the amount of free space available.
The previous version of f3write.h2w didn't recognize
parameters --start-at= and --end-at=.
The new code of f3write.h2w also avoids overwritting
the environment variable PATH.
This parameter allows users to execute F3 concurrently.
Moreover, users Mark and Wolfi have asked for similar parameters to
help analyzing very large flash drives.
This rewrite of the Makefile takes advantage of the fact that
the Makefile has been unified for all supported operating systems
to properly express source-file dependencies.
The source now identifies the operating system with the help of
macros defined by GCC.
The macros are documented here:
http://sourceforge.net/p/predef/wiki/OperatingSystems/
This patch was inspired by a suggestion from Max Justicz.
Now F3 and h2testw share the same file format.
Guenter Knauf has suggested this feature and
got the random-number generator used in h2testw from
Harald Bogeholz, the author of h2testw.
This change also addresses the issue that
the original random-number generator only fills
the first 32 bits of the 64 bits of the random numbers on
64-bit machines.
Besides the lower entropy on 64-bit machines, this issue was
making files generated on 32-bit and 64-bit machines incompatible.
Anselm Distelrath was the first to report this issue.
Two things could go wrong when .fff files are not fully read:
1. The constraint "assert(*read_all || errno == EIO);"
could fail because, according to the manual,
feof(3) does not set errno(3), but gettimeofday(2),
which is called after fread(3), does.
2. The tail message "NOT fully read" was never issued because
the test was "read_all", and variable read_all was a pointer.
Thus, the test was always true.
The not-fully-read error message now adds the output of
strerror(3) to guide the diagnose of the failure.
These bugs must be rare because they have been lurking around for
more than two years according to git's log.
They were only found due to a bug report by John Lussmyer on
September 21st, 2013.
This parameter became important because F3 now can be used on
very large storages and one may want to resume the test process
from a failure or interruption.
The filenames were from 0001.fff to 9999.fff.
This limit hasn't been a problem, but Anselm Distelrath reported
on February 8th, 2013 that isn't enough to test his system:
a RAID 6 with 18 hard drives of 3TB each.
Now filenames are from 1.fff to <INT_MAX>.fff.
Messages like "Removing old file 0001.fff ..." were issued in
a file system dependent order.
This is a cosmetic change that takes advantage of
the function ls_my_files previously created for f3read.
The original algorithm had a slow reaction when there was
a large variation on the flow capacity.
The new algorithm even removed the need for the call to sync(2)
at beginning.
If an F3 file (i.e. *.fff) but the last one is missing,
f3read will report the missing file with a warning similar to this one:
Missing file 0001.fff
AND the following warning will be presented at the end of the report:
WARNING: Not all F3 files are available
Kenneth Arnold suggested this feature in an e-mail:
"I also noticed that if one of the files is completely missing, f3read
will still report no errors. The chance that this will happen on its
own without messing something else up is too small to worry about,
except possibly in the case that the device was actually read-only and
no files actually got created. In that case, f3read succeeds with 0
sectors OK and 0 sectors lost."
The last F3 file, if missing, is not reported because
it can be confusing.
The following example gives an idea of the problem:
a memory card wasn't empty when f3write was called and
the last F3 file created was 0010.fff with exactly 1GB;
here none F3 file is missing.
Then, some non-F3 files were removed, and f3read is called.
f3read would report a missing file even when non-F3 files were
removed!
The problem gets a little bit uglier if 0010.fff in the example
is less that 1GB, or the file system doesn't let f3write to
fill it up for a few bytes (this should be very rare, but
there's no guarantee that it cannot happen).
Finally, the implementation of this feature has a positive
side effect: f3read processes F3 files in ascending order,
that is, 0001.fff, 0002.fff, ..., NNNN.fff.
Before the order was file system dependent.
Magic numbers related to the number of digits in the F3 files'
names were eliminated.