-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add f3write --keep and f3read --delete parameters #140
base: master
Are you sure you want to change the base?
Conversation
Hi @brianpow, Before we go through code review, could you describe the use case that this pull request intends to help? It doesn't need to be formal or long, I'm just looking for a brief description of the situation in which someone would want to use the parameter Thank you. |
Hi. If the flash memory is overheated, your computer is suspended or the test is interrupted accidentally, we can keep the existing files and continue f3write instead of creating everything from beginning. |
now f3read can delete corrupted NUM.h2w. It makes my life easier if corrupted file was found and I want to tested again by recreating only those corrupted file. So I can easily run these command without counting around the start or end number. for f3probe, with --fix parameter, again user doesn't need to mark down the sectors and run f3fix. Both changes are good for unattended test/fix too |
Having Let's start making this pull request coherent. First, create a second pull request and move patch Please add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add --keep parameter to keep existing NUM.h2w files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add --delete parameter to delete corrupted NUM.h2w file
Please add an s
to file
in the title of this patch.
@@ -48,6 +50,7 @@ struct args { | |||
long end_at; | |||
long max_read_rate; | |||
int show_progress; | |||
bool delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align indentation with other fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've missed this item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add --fix parameter to run f3fix automatically if counterfeit memory detected
A shorter title: add --fix parameter to run f3fix when needed
@@ -373,8 +382,8 @@ static int test_device(struct args *args) | |||
uint64_t read_count, read_time_us; | |||
uint64_t write_count, write_time_us; | |||
uint64_t reset_count, reset_time_us; | |||
uint64_t last_good_sector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of moving the declaration of last_good_sector
here, declare char *fix_cmd = NULL;
More details in other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've missed this item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, the declaration of last_good_sector
should be moved back to the body of the switch..case
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f3write: code cleanup
printf("Skipping file %s\n", filename); | ||
return false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: drop this new blank line.
free(full_fn); | ||
return false; | ||
} | ||
err(errno, "Unexpectedly found file %s, but option --keep is not in use", full_fn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could replace the but
with and
? My fault, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f3read: code cleanup
@@ -386,11 +386,13 @@ static void iterate_files(const char *path, const long *files, | |||
tot_overwritten += stats.secs_overwritten; | |||
tot_size += stats.bytes_read; | |||
and_read_all = and_read_all && stats.read_all; | |||
if (stats.secs_corrupted && delete) { | |||
if (delete && (stats.secs_corrupted || tot_changed || tot_overwritten)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace tot_changed
with stats.secs_changed
and tot_overwritten
with stats.secs_overwritten
. My fault, again.
Break the line as needed to fit within the 80-column limit.
@@ -485,6 +486,7 @@ static int test_device(struct args *args) | |||
case FKTY_CHAIN: { | |||
last_good_sector = (real_size_byte >> 9) - 1; | |||
assert(block_order >= 9); | |||
assert(asprintf(&fix_cmd, "f3fix --last-sec=%" PRIu64 " %s", last_good_sector, final_dev_filename) > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break line to fit within the 80-column limit.
@@ -485,6 +486,7 @@ static int test_device(struct args *args) | |||
case FKTY_CHAIN: { | |||
last_good_sector = (real_size_byte >> 9) - 1; | |||
assert(block_order >= 9); | |||
assert(asprintf(&fix_cmd, "f3fix --last-sec=%" PRIu64 " %s", last_good_sector, final_dev_filename) > 0); | |||
printf("Bad news: The device `%s' is a counterfeit of type %s\n\n" | |||
"You can \"fix\" this device using the following command:\n" | |||
"f3fix --last-sec=%" PRIu64 " %s\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Replace the line
"f3fix --last-sec=%" PRIu64 " %s\n",
with"%s\n",
. - Replace the line
last_good_sector, final_dev_filename);
below withfix_cmd);
.
if (args->fix && fix_cmd) { | ||
system(fix_cmd); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: drop the braces since the body of this if
statement is a single line.
@@ -373,8 +382,8 @@ static int test_device(struct args *args) | |||
uint64_t read_count, read_time_us; | |||
uint64_t write_count, write_time_us; | |||
uint64_t reset_count, reset_time_us; | |||
uint64_t last_good_sector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, the declaration of last_good_sector
should be moved back to the body of the switch..case
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f3probe: code cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f3write: code cleanup
@@ -39,8 +39,8 @@ static struct argp_option options[] = { | |||
"Maximum write rate", 0}, | |||
{"show-progress", 'p', "NUM", 0, | |||
"Show progress if NUM is not zero", 0}, | |||
{"keep", 'k', 0, 0, | |||
"Keep existing NUM.h2w file, otherwise all NUM.h2w files will be removed in each run", 0}, | |||
{"keep", 'k', 0, 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the first 0
after 'k'
with NULL
.
@AltraMayor |
I'm going to leave this pull request open, so someone else can pick it up if the need for it comes. Good luck on your new project! |
No description provided.