summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2018-02-27 12:55:31 -0500
committerJan Kara <jack@suse.cz>2018-03-02 08:22:57 -0500
commitb72e632c6c7e29343651b0e26539b2e01444dfe6 (patch)
tree01198315b8b563c7c359aff8cbd6992fb39e96ef /fs
parent7b1f641776e0c8b824fb10135168e4b683a9e2ba (diff)
udf: Do not mark possibly inconsistent filesystems as closed
If logical volume integrity descriptor contains non-closed integrity type when mounting the volume, there are high chances that the volume is not consistent (device was detached before the filesystem was unmounted). Don't touch integrity type of such volume so that fsck can recognize it and check such filesystem. Reported-by: Pali Rohár <pali.rohar@gmail.com> Reviewed-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/super.c8
-rw-r--r--fs/udf/udf_sb.h1
2 files changed, 7 insertions, 2 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 2d4929fa884d..bf5f6084dcb2 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1988,7 +1988,10 @@ static void udf_open_lvid(struct super_block *sb)
1988 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; 1988 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1989 ktime_get_real_ts(&ts); 1989 ktime_get_real_ts(&ts);
1990 udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); 1990 udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
1991 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); 1991 if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE)
1992 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
1993 else
1994 UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT);
1992 1995
1993 lvid->descTag.descCRC = cpu_to_le16( 1996 lvid->descTag.descCRC = cpu_to_le16(
1994 crc_itu_t(0, (char *)lvid + sizeof(struct tag), 1997 crc_itu_t(0, (char *)lvid + sizeof(struct tag),
@@ -2028,7 +2031,8 @@ static void udf_close_lvid(struct super_block *sb)
2028 lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); 2031 lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
2029 if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) 2032 if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
2030 lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); 2033 lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
2031 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); 2034 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
2035 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
2032 2036
2033 lvid->descTag.descCRC = cpu_to_le16( 2037 lvid->descTag.descCRC = cpu_to_le16(
2034 crc_itu_t(0, (char *)lvid + sizeof(struct tag), 2038 crc_itu_t(0, (char *)lvid + sizeof(struct tag),
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 9dcb475fc74e..9dd3e1b9619e 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -29,6 +29,7 @@
29#define UDF_FLAG_SESSION_SET 15 29#define UDF_FLAG_SESSION_SET 15
30#define UDF_FLAG_LASTBLOCK_SET 16 30#define UDF_FLAG_LASTBLOCK_SET 16
31#define UDF_FLAG_BLOCKSIZE_SET 17 31#define UDF_FLAG_BLOCKSIZE_SET 17
32#define UDF_FLAG_INCONSISTENT 18
32 33
33#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 34#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001
34#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 35#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002