diff -Nru dosfstools-3.0.12/debian/changelog dosfstools-3.0.12/debian/changelog --- dosfstools-3.0.12/debian/changelog 2013-01-18 13:08:46.000000000 +0000 +++ dosfstools-3.0.12/debian/changelog 2015-04-07 10:20:35.000000000 +0000 @@ -1,3 +1,11 @@ +dosfstools (3.0.12-1ubuntu1.2) precise; urgency=medium + + * Add git-check-dirty-bit.patch: Check boot sector for dirty bit, to allow + dosfsck to repair partitions which didn't get unmounted properly. + (LP: #1322976) + + -- Martin Pitt Tue, 07 Apr 2015 12:19:39 +0200 + dosfstools (3.0.12-1ubuntu1.1) precise; urgency=low * Add dosfstools-udeb package, mainly so that we can use mkdosfs in d-i diff -Nru dosfstools-3.0.12/debian/patches/git-check-dirty-bit.patch dosfstools-3.0.12/debian/patches/git-check-dirty-bit.patch --- dosfstools-3.0.12/debian/patches/git-check-dirty-bit.patch 1970-01-01 00:00:00.000000000 +0000 +++ dosfstools-3.0.12/debian/patches/git-check-dirty-bit.patch 2015-04-07 10:19:00.000000000 +0000 @@ -0,0 +1,98 @@ +From ce2f8dc349a8a6b2c26d1b3892cc9b5f0408bd34 Mon Sep 17 00:00:00 2001 +From: Oleksij Rempel +Date: Wed, 23 Jan 2013 12:35:13 +0100 +Subject: [PATCH] Checking boot sector for dirty bit. + +Some OSos use reseved byte of boot sector to set state of the file +system. If first bit set, then filesystem is proably damaged - write +operation was not finished/cache not snycted/... + +Signed-off-by: Oleksij Rempel +Signed-off-by: Daniel Baumann +--- + src/boot.c | 41 +++++++++++++++++++++++++++++++++++++++++ + src/dosfsck.h | 2 ++ + 2 files changed, 43 insertions(+) + +diff --git a/src/boot.c b/src/boot.c +index 3d6b4e4..55d5875 100644 +--- a/src/boot.c ++++ b/src/boot.c +@@ -291,6 +291,45 @@ static void read_fsinfo(DOS_FS * fs, struct boot_sector *b, int lss) + fs->free_clusters = CF_LE_L(i.free_clusters); + } + ++static char print_fat_dirty_state(void) ++{ ++ printf("Dirty bit is set. Fs was not properly unmounted and" ++ " some data may be corrupt.\n"); ++ ++ if (interactive) { ++ printf("1) Remove dirty bit\n" ++ "2) No action\n"); ++ return get_key("12", "?"); ++ } else ++ printf(" Automaticaly removing dirty bit.\n"); ++ return '1'; ++} ++ ++static void check_fat_state_bit (DOS_FS *fs, void *b) ++{ ++ if (fs->fat_bits == 32) { ++ struct boot_sector *b32 = b; ++ ++ if (b32->reserved3 & FAT_STATE_DIRTY) { ++ printf("0x41: "); ++ if (print_fat_dirty_state() == '1') { ++ b32->reserved3 &= ~FAT_STATE_DIRTY; ++ fs_write(0, sizeof(*b32), b32); ++ } ++ } ++ } else { ++ struct boot_sector_16 *b16 = b; ++ ++ if (b16->reserved2 & FAT_STATE_DIRTY) { ++ printf("0x25: "); ++ if (print_fat_dirty_state() == '1') { ++ b16->reserved2 &= ~FAT_STATE_DIRTY; ++ fs_write(0, sizeof(*b16), b16); ++ } ++ } ++ } ++} ++ + void read_boot(DOS_FS * fs) + { + struct boot_sector b; +@@ -363,6 +402,7 @@ void read_boot(DOS_FS * fs) + " This may lead to problems on some systems.\n", + fs->clusters, FAT16_THRESHOLD); + ++ check_fat_state_bit(fs, &b); + fs->backupboot_start = CF_LE_W(b.backup_boot) * logical_sector_size; + check_backup_boot(fs, &b, logical_sector_size); + +@@ -373,6 +413,7 @@ void read_boot(DOS_FS * fs) + fs->fat_bits = (fs->clusters >= FAT12_THRESHOLD) ? 16 : 12; + if (fs->clusters >= FAT16_THRESHOLD) + die("Too many clusters (%lu) for FAT16 filesystem.", fs->clusters); ++ check_fat_state_bit(fs, &b); + } else { + /* On Atari, things are more difficult: GEMDOS always uses 12bit FATs + * on floppies, and always 16 bit on harddisks. */ +diff --git a/src/dosfsck.h b/src/dosfsck.h +index 6eb42fb..9fe103a 100644 +--- a/src/dosfsck.h ++++ b/src/dosfsck.h +@@ -57,6 +57,8 @@ + + #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) + ++#define FAT_STATE_DIRTY 0x01 ++ + /* ++roman: Use own definition of boot sector structure -- the kernel headers' + * name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */ + struct boot_sector { +-- +1.8.2.1 + diff -Nru dosfstools-3.0.12/debian/patches/series dosfstools-3.0.12/debian/patches/series --- dosfstools-3.0.12/debian/patches/series 2011-12-19 23:24:17.000000000 +0000 +++ dosfstools-3.0.12/debian/patches/series 2015-04-07 10:19:31.000000000 +0000 @@ -1 +1,2 @@ +git-check-dirty-bit.patch 02_fat32_label.patch