Adding option for bootsector read-only check.

Most boot sectors may contains marker for filesystem state. We can this
bit on every mount and warn user if some thing wrong, without checking
complete filesystem.

Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
This commit is contained in:
Oleksij Rempel 2013-01-23 12:36:56 +01:00 committed by Daniel Baumann
parent ce2f8dc349
commit a307be2b9c
2 changed files with 15 additions and 4 deletions

View File

@ -305,7 +305,7 @@ static char print_fat_dirty_state(void)
return '1';
}
static void check_fat_state_bit (DOS_FS *fs, void *b)
static void check_fat_state_bit(DOS_FS *fs, void *b)
{
if (fs->fat_bits == 32) {
struct boot_sector *b32 = b;

View File

@ -42,16 +42,17 @@
#include "check.h"
int interactive = 0, rw = 0, list = 0, test = 0, verbose = 0, write_immed = 0;
int atari_format = 0;
int atari_format = 0, boot_only = 0;
unsigned n_files = 0;
void *mem_queue = NULL;
static void usage(char *name)
{
fprintf(stderr, "usage: %s [-aAflrtvVwy] [-d path -d ...] "
fprintf(stderr, "usage: %s [-aAbflrtvVwy] [-d path -d ...] "
"[-u path -u ...]\n%15sdevice\n", name, "");
fprintf(stderr, " -a automatically repair the file system\n");
fprintf(stderr, " -A toggle Atari file system format\n");
fprintf(stderr, " -b make read-only boot sector check\n");
fprintf(stderr, " -d path drop that file\n");
fprintf(stderr, " -f salvage unused chains to files\n");
fprintf(stderr, " -l list path names\n");
@ -108,7 +109,7 @@ int main(int argc, char **argv)
interactive = 1;
check_atari();
while ((c = getopt(argc, argv, "Aad:flnprtu:vVwy")) != EOF)
while ((c = getopt(argc, argv, "Aad:bflnprtu:vVwy")) != EOF)
switch (c) {
case 'A': /* toggle Atari format */
atari_format = !atari_format;
@ -120,6 +121,11 @@ int main(int argc, char **argv)
interactive = 0;
salvage_files = 1;
break;
case 'b':
rw = 0;
interactive = 0;
boot_only = 1;
break;
case 'd':
file_add(optarg, fdt_drop);
break;
@ -165,7 +171,11 @@ int main(int argc, char **argv)
printf("dosfsck " VERSION ", " VERSION_DATE ", FAT32, LFN\n");
fs_open(argv[optind], rw);
read_boot(&fs);
if (boot_only)
goto exit;
if (verify)
printf("Starting check/repair pass.\n");
while (read_fat(&fs), scan_root(&fs))
@ -190,6 +200,7 @@ int main(int argc, char **argv)
n_files_verify = n_files;
}
exit:
if (fs_changed()) {
if (rw) {
if (interactive)