From a307be2b9cbfd0ed8c10dab79044cf6c7426ea18 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Wed, 23 Jan 2013 12:36:56 +0100 Subject: [PATCH] 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 Signed-off-by: Daniel Baumann --- src/boot.c | 2 +- src/dosfsck.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/boot.c b/src/boot.c index 55d5875..9c7483e 100644 --- a/src/boot.c +++ b/src/boot.c @@ -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; diff --git a/src/dosfsck.c b/src/dosfsck.c index b2f6da0..2750953 100644 --- a/src/dosfsck.c +++ b/src/dosfsck.c @@ -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)