The code of the applications f3probe, f3brew, and f3fix is now
mature, and they have not received any significant bug report for
about six months.
From now on, one needs to compile these applications with
```make extra```
Replace parse_args() with argp_parse() from argp.h
it also adda option "--show-progress" to force program displaying the progress even when STDOUT is not a TTY (see #21).
When using -O2, GCC was issuing the following warning:
cc -O2 -std=c99 -Wall -Wextra -pedantic -MMD -ggdb -c -o f3probe.o f3probe.c
f3probe.c: In function ‘main’:
f3probe.c:446:13: warning: ‘sdev’ may be used uninitialized in this function [-Wmaybe-uninitialized]
sdev_flush(sdev);
^
f3probe.c:369:30: note: ‘sdev’ was declared here
struct device *dev, *pdev, *sdev;
^
NOTE: The warning was wrong.
GCC could not follow that @args->save being true implied
@sdev to not be NULL.
This patch addresses one of the issues discussed here:
https://github.com/AltraMayor/f3/issues/34
When using -O2, GCC was issuing the following warning:
cc -O2 -std=c99 -Wall -Wextra -pedantic -MMD -ggdb -c -o f3read.o f3read.c
f3read.c: In function ‘validate_file’:
f3read.c:95:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
offset = *((uint64_t *) sector);
^
This patch makes f3probe issue single calls of
sequential reads and writes wherever is possible to speed up
the non-destructive (i.e. conservative) mode.
Notice that the non-destructive mode only recovers the usable
blocks of fake drives, and all blocks of legit drives.
Although I (Michel) am not 100% sure, the kernel seemed to be
allowing reads to get data from an internal cache in the kernel;
the condition is tricky to reproduce, and trickier to be sure
since fake drives are not reliable or preditable.
The results seems more stable with this patch, though.
f3probe was using just 3 writes to make a decision on how to
balance resets and writes.
When the first 3 writes were faster than normal,
the next pass would go for an unrealistic number of writes.
This patch requires at least 10 writes;
in practice, it will uses 15 writes.
The larger number of writes allows for a better balance.
probe_device_max_blocks() was returning an int that once multiplied
by block_size was out range.
This patch just enforces probe_device_max_blocks() to return
an uint64_t, and does the needed adjustments in the code.
libdevs.c had error messages that mentioned f3probe.
Given that f3brew also uses libdevs.c, this was causing nonsense
error messages such as the following:
==================================================================
$ ./f3brew /dev/sdc
F3 brew 5.0
Copyright (C) 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.
Your username doesn't have access to device `/dev/sdc'.
Try to run this program as root:
sudo f3probe /dev/sdc
In case you don't have access to root, use f3write/f3read.
Application cannot continue, finishing...
==================================================================
F3 users have identified fake flashes that reserve a portion of
their good memory to use as a permanent cache.
This patch adds this feature to our model in order to allow us to
develop a new probe algorithm to deal with it.
f3brew were working at sector level because
it was borrowing code from f3write/f3read which work at that level.
This patch writes new functions to fill out, and validate blocks.
This change is important because
f3probe needs to validate blocks as well for its coming features.
A side effect of this patch is that all experimental applications
(i.e. f3probe, f3brew, and f3fix) no longer depend on
code from f3write and f3read.
When a non-root user called f3brew on a device,
f3brew would issue the following error message:
Your username doesn't have access to device `/dev/sdc'.
Try to run this program as root:
sudo f3probe /dev/sdc
In case you don't have access to root, use f3write/f3read.
f3brew: f3brew.c:484: main: Assertion `dev' failed.
Aborted (core dumped)
This patch avoids the assert().
f3probe does not try to find the real amount of memory that
a fake card has, but the usable about of memory, that is,
the memory from the first block (i.e. block zero) to
the block before the first failed block.
A fake card may have more memory, but it would be spread among
failed blocks, so it is not usable.