25 Commits

Author SHA1 Message Date
Uffe Jakobsen
b4e8e6c9da Fixes for FreeBSD 2014-09-02 10:30:43 -04:00
Michel Machado
d742672fa1 Add optional parameter --end-at=NUM to F3
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.
2014-08-15 17:30:38 -04:00
Michel Machado
c98e580b94 General code review
- Comply with C99 standard.
- Adopt compiling flag -Wextra.
- Adopt compiling flag -Wpedantic.
- Drop use of PATH_MAX constant.
2014-08-12 13:56:01 -04:00
Michel Machado
66be2fddb9 Unify Makefile
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.
2014-08-12 07:57:40 -04:00
Michel Machado
44ec7ce70e f3read: fix for Windows/Cygwin
Windows requires that the file descriptor passed to fdatasync(2)
to be writable.

Tom Hall reported the issue and proposed the solution.
2014-06-03 11:31:35 -04:00
Michel Machado
be1f587142 Adopt h2testw's file format
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.
2014-05-14 11:44:13 -04:00
Michel Machado
05eceb342d Fix report when .fff files are not fully read
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.
2013-09-23 11:24:59 -04:00
Michel Machado
f2a27db58c Add option parameter --start-at=NUM to F3
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.
2013-02-08 15:14:28 -05:00
Michel Machado
90b0bfbfcd Remove arbitrary limit on filenames
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.
2013-02-08 15:13:29 -05:00
Michel Machado
c24c098c3c Report version and copyright in help message
This was added mainly to help users to identify
the version they have installed.
2012-03-07 11:29:40 -05:00
Michel Machado
f7d57f76e0 Made f3write remove old F3 files in order
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.
2011-12-26 17:26:08 -02:00
Michel Machado
d350745fc2 Verify that "all" F3 files are present
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.
2011-12-23 22:16:19 -02:00
Michel Machado
cbadb0c91c Reviewed code 2011-12-20 14:02:17 -05:00
Michel Machado
7c0be994e1 f3write now reports proper progress
In the previous version of f3write, fdatasync(2) was used to
show the progress printouts smoothly.
However, it slows down a lot the execution, and hurts
the writing speed measurement.

This new version finds out what is the writing speed of
the memory card being tested using an algorithm that reseables
TCP's congestion control algorithm, and keeps writing at that
speed; this allows smooth progress printouts.

f3write is even faster now!
2011-12-17 18:22:50 -05:00
Michel Machado
597aa0fb3c Added progress printout in f3read 2011-12-17 17:05:12 -05:00
Michel Machado
c03cbf4b4a Advising the kernel
* f3read
	As long as the kernel honors our advice, f3read doesn't
	ever read data from the system cache instead of reading
	from the memory card, and reading speed measurement  is
	improved.

* f3write
	Progress printout goes smoothly now.
2011-12-17 17:05:03 -05:00
Michel Machado
91083d787c Improved precision of speed measurements 2011-12-17 16:59:55 -05:00
Michel Machado
0135a9bfeb Improved user feedback
- Improved format of f3read's output, example:

$ ./f3read /media/F085-0201/
                     SECTORS      ok/corrupted/changed/overwritten
Validating file 0001.fff ... 2097152/        0/      0/      0
Validating file 0002.fff ... 1904000/        0/      0/      0

  Data OK: 1.91 GB (4001152 sectors)
Data LOST: 0.00 Byte (0 sectors)
	       Corrupted: 0.00 Byte (0 sectors)
	Slightly changed: 0.00 Byte (0 sectors)
	     Overwritten: 0.00 Byte (0 sectors)
Reading speed: 15.14 MB/s

- Added progress report per file to f3write.

Both suggestions were given by Michael D. Setzer II.
2011-12-17 15:52:17 -05:00
Michel Machado
d2a1a289fd Formated code following Linux's coding style
See file Documentation/CodingStyle in Linux's source code
for a reference of the style.

Used "indent -kr -i8" to help out.

Added a .gitignore to the repository.
2011-12-14 19:09:20 -05:00
Michel Machado
8bd4f358da Copied code from GNU Library C to improve portability
This version should compile and run on Apples, but since
I don't have one, I haven't tested it.
2011-12-14 15:48:15 -05:00
Michel Machado
572af0870e Version 1.1.3
Fixed some warning issued by GCC when compiling f3read.c on 64bits machines.
Nicolai Abruzzese was the first one to report this issue.
The outputs that he obtained were as follows:

f3read.c: In function 'report':
f3read.c:126: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type 'uint64_t'
f3read.c: In function 'iterate_path':
f3read.c:166: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type 'uint64_t'
f3read.c:166: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'uint64_t'
f3read.c:166: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'uint64_t'
f3read.c:166: warning: format '%llu' expects type 'long long unsigned int', but argument 5 has type 'uint64_t'
2011-12-14 15:37:12 -05:00
Michel Machado
7d42ffabdf Version 1.1.2
Handled an I/O error reported by Misha Aizatulin.
The outputs that he obtained were as follows:

$ ./f3write /media/disk/
Free space: 122.01 GB
Creating file 0001.fff ... OK!
...
Creating file 0113.fff ... OK!
Creating file 0114.fff ... OK!
Creating file 0115.fff ... OK!
Creating file 0116.fff ... OK!
Creating file 0117.fff ... OK!
Free space: 0.00 Byte
Writing speed: 5.96 MB/s

$ ./f3read /media/disk/
                     SECTORS ok/corrupted/changed/overwritten
Validating file 0001.fff ... 0/0/0/2097152
Validating file 0002.fff ... 33280/0/0/2063872
Validating file 0003.fff ... 0/0/0/32 - NOT fully read
Validating file 0004.fff ... 0/0/0/2097152
Validating file 0005.fff ... 0/0/0/24192 - NOT fully read
Validating file 0006.fff ... 0/0/0/32 - NOT fully read
Validating file 0007.fff ... 0/0/0/32 - NOT fully read
...
Validating file 0035.fff ... 0/0/0/121984 - NOT fully read
Validating file 0036.fff ... 0/0/0/121984 - NOT fully read
Validating file 0037.fff ... 0/0/0/32 - NOT fully read
Validating file 0038.fff ... 0/0/0/32 - NOT fully read
...
Validating file 0113.fff ... 0/2097152/0/0
Validating file 0114.fff ... 0/2097152/0/0
Validating file 0115.fff ... 161888/1935264/0/0
Validating file 0116.fff ... 1980224/96768/0/20160
Validating file 0117.fff ... 265824/52416/0/0

  Data OK: 14.44 GB (30275959 sectors)
Data LOST: 13.77 GB (28874473 sectors)
               Corrupted: 9.92 GB (20793321 sectors)
        Slightly changed: 0.00 Byte (0 sectors)
             Overwritten: 3.85 GB (8081152 sectors)
WARNING: Not all data was read due to I/O error(s)
Reading speed: 15.77 MB/s
2011-12-14 15:34:09 -05:00
Michel Machado
899b3c6ca7 Version 1.1.1
Fixed some warnings issued by gcc when the parameter -Wall is
used to compile the source.
2011-12-14 15:32:33 -05:00
Michel Machado
45f50c10b2 Version 1.1
- Added a nice report at the end of the output of f3read.
- Fixed bug on large memory cards.
2011-12-14 15:28:46 -05:00
Michel Machado
48195690db The very first version of F3 (version 1.0)
It doesn't have a nice report, and due to a bug, only works properly on
2GB cards or less.
2011-12-14 15:24:43 -05:00