Add f3write --keep and f3read --delete parameters#140
Add f3write --keep and f3read --delete parameters#140brianpow wants to merge 7 commits intoAltraMayor:masterfrom
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 |
AltraMayor
left a comment
There was a problem hiding this comment.
add --keep parameter to keep existing NUM.h2w files
| long end_at; | ||
| long max_read_rate; | ||
| int show_progress; | ||
| bool delete; |
There was a problem hiding this comment.
Align indentation with other fields.
AltraMayor
left a comment
There was a problem hiding this comment.
add --fix parameter to run f3fix automatically if counterfeit memory detected
A shorter title: add --fix parameter to run f3fix when needed
| 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.
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.
To clarify, the declaration of last_good_sector should be moved back to the body of the switch..case.
| printf("Skipping file %s\n", filename); | ||
| return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
Could replace the but with and? My fault, sorry.
| 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.
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.
| 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.
Break line to fit within the 80-column limit.
| 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.
- 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.
Style: drop the braces since the body of this if statement is a single line.
| 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.
To clarify, the declaration of last_good_sector should be moved back to the body of the switch..case.
| "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.
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.