Skip to content

Commit 1cf3109

Browse files
NTFS: Do more detailed reporting of why we cannot mount read-write by
special casing the VOLUME_MODIFIED_BY_CHKDSK flag. Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
1 parent 78af34f commit 1cf3109

6 files changed

Lines changed: 53 additions & 29 deletions

File tree

‎Documentation/filesystems/ntfs.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,12 @@ ChangeLog
457457

458458
Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
459459

460+
2.1.26:
461+
- Implement support for sector sizes above 512 bytes (up to the maximum
462+
supported by NTFS which is 4096 bytes).
463+
- Enhance support for NTFS volumes which were supported by Windows but
464+
not by Linux due to invalid attribute list attribute flags.
465+
- A few minor updates and bug fixes.
460466
2.1.25:
461467
- Write support is now extended with write(2) being able to both
462468
overwrite existing file data and to extend files. Also, if a write

‎fs/ntfs/ChangeLog‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ ToDo/Notes:
2929
kmem_cache_t. (Pekka Enberg)
3030
- Implement support for sector sizes above 512 bytes (up to the maximum
3131
supported by NTFS which is 4096 bytes).
32+
- Do more detailed reporting of why we cannot mount read-write by
33+
special casing the VOLUME_MODIFIED_BY_CHKDSK flag.
3234
- Miscellaneous updates to layout.h.
3335
- Cope with attribute list attribute having invalid flags. Windows
3436
copes with this and even chkdsk does not detect or fix this so we

‎fs/ntfs/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
66
index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \
77
unistr.o upcase.o
88

9-
EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.25\"
9+
EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.26\"
1010

1111
ifeq ($(CONFIG_NTFS_DEBUG),y)
1212
EXTRA_CFLAGS += -DDEBUG

‎fs/ntfs/super.c‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,16 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
472472
ntfs_error(sb, "Volume is dirty and read-only%s", es);
473473
return -EROFS;
474474
}
475+
if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) {
476+
ntfs_error(sb, "Volume has been modified by chkdsk "
477+
"and is read-only%s", es);
478+
return -EROFS;
479+
}
475480
if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
476-
ntfs_error(sb, "Volume has unsupported flags set and "
477-
"is read-only%s", es);
481+
ntfs_error(sb, "Volume has unsupported flags set "
482+
"(0x%x) and is read-only%s",
483+
(unsigned)le16_to_cpu(vol->vol_flags),
484+
es);
478485
return -EROFS;
479486
}
480487
if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
@@ -1845,11 +1852,24 @@ static BOOL load_system_files(ntfs_volume *vol)
18451852
/* Make sure that no unsupported volume flags are set. */
18461853
if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
18471854
static const char *es1a = "Volume is dirty";
1848-
static const char *es1b = "Volume has unsupported flags set";
1849-
static const char *es2 = ". Run chkdsk and mount in Windows.";
1850-
const char *es1;
1851-
1852-
es1 = vol->vol_flags & VOLUME_IS_DIRTY ? es1a : es1b;
1855+
static const char *es1b = "Volume has been modified by chkdsk";
1856+
static const char *es1c = "Volume has unsupported flags set";
1857+
static const char *es2a = ". Run chkdsk and mount in Windows.";
1858+
static const char *es2b = ". Mount in Windows.";
1859+
const char *es1, *es2;
1860+
1861+
es2 = es2a;
1862+
if (vol->vol_flags & VOLUME_IS_DIRTY)
1863+
es1 = es1a;
1864+
else if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) {
1865+
es1 = es1b;
1866+
es2 = es2b;
1867+
} else {
1868+
es1 = es1c;
1869+
ntfs_warning(sb, "Unsupported volume flags 0x%x "
1870+
"encountered.",
1871+
(unsigned)le16_to_cpu(vol->vol_flags));
1872+
}
18531873
/* If a read-write mount, convert it to a read-only mount. */
18541874
if (!(sb->s_flags & MS_RDONLY)) {
18551875
if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |

‎fs/ntfs/upcase.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
* Part of the Linux-NTFS project.
44
*
55
* Copyright (c) 2001 Richard Russon <ntfs@flatcap.org>
6-
* Copyright (c) 2001-2004 Anton Altaparmakov
7-
*
8-
* Modified for mkntfs inclusion 9 June 2001 by Anton Altaparmakov.
9-
* Modified for kernel inclusion 10 September 2001 by Anton Altparmakov.
6+
* Copyright (c) 2001-2006 Anton Altaparmakov
107
*
118
* This program is free software; you can redistribute it and/or modify it
129
* under the terms of the GNU General Public License as published by the Free
@@ -75,12 +72,13 @@ ntfschar *generate_default_upcase(void)
7572
if (!uc)
7673
return uc;
7774
memset(uc, 0, default_upcase_len * sizeof(ntfschar));
75+
/* Generate the little endian Unicode upcase table used by ntfs. */
7876
for (i = 0; i < default_upcase_len; i++)
7977
uc[i] = cpu_to_le16(i);
8078
for (r = 0; uc_run_table[r][0]; r++)
8179
for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++)
82-
uc[i] = cpu_to_le16((le16_to_cpu(uc[i]) +
83-
uc_run_table[r][2]));
80+
uc[i] = cpu_to_le16(le16_to_cpu(uc[i]) +
81+
uc_run_table[r][2]);
8482
for (r = 0; uc_dup_table[r][0]; r++)
8583
for (i = uc_dup_table[r][0]; i < uc_dup_table[r][1]; i += 2)
8684
uc[i + 1] = cpu_to_le16(le16_to_cpu(uc[i + 1]) - 1);

‎fs/ntfs/volume.h‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* volume.h - Defines for volume structures in NTFS Linux kernel driver. Part
33
* of the Linux-NTFS project.
44
*
5-
* Copyright (c) 2001-2005 Anton Altaparmakov
5+
* Copyright (c) 2001-2006 Anton Altaparmakov
66
* Copyright (c) 2002 Richard Russon
77
*
88
* This program/include file is free software; you can redistribute it and/or
@@ -41,10 +41,8 @@ typedef struct {
4141
* structure has stabilized... (AIA)
4242
*/
4343
/* Device specifics. */
44-
struct super_block *sb; /* Pointer back to the super_block,
45-
so we don't have to get the offset
46-
every time. */
47-
LCN nr_blocks; /* Number of NTFS_BLOCK_SIZE bytes
44+
struct super_block *sb; /* Pointer back to the super_block. */
45+
LCN nr_blocks; /* Number of sb->s_blocksize bytes
4846
sized blocks on the device. */
4947
/* Configuration provided by user at mount time. */
5048
unsigned long flags; /* Miscellaneous flags, see below. */
@@ -141,8 +139,8 @@ typedef enum {
141139
NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */
142140
NV_CaseSensitive, /* 1: Treat file names as case sensitive and
143141
create filenames in the POSIX namespace.
144-
Otherwise be case insensitive and create
145-
file names in WIN32 namespace. */
142+
Otherwise be case insensitive but still
143+
create file names in POSIX namespace. */
146144
NV_LogFileEmpty, /* 1: $LogFile journal is empty. */
147145
NV_QuotaOutOfDate, /* 1: $Quota is out of date. */
148146
NV_UsnJrnlStamped, /* 1: $UsnJrnl has been stamped. */
@@ -153,7 +151,7 @@ typedef enum {
153151
* Macro tricks to expand the NVolFoo(), NVolSetFoo(), and NVolClearFoo()
154152
* functions.
155153
*/
156-
#define NVOL_FNS(flag) \
154+
#define DEFINE_NVOL_BIT_OPS(flag) \
157155
static inline int NVol##flag(ntfs_volume *vol) \
158156
{ \
159157
return test_bit(NV_##flag, &(vol)->flags); \
@@ -168,12 +166,12 @@ static inline void NVolClear##flag(ntfs_volume *vol) \
168166
}
169167

170168
/* Emit the ntfs volume bitops functions. */
171-
NVOL_FNS(Errors)
172-
NVOL_FNS(ShowSystemFiles)
173-
NVOL_FNS(CaseSensitive)
174-
NVOL_FNS(LogFileEmpty)
175-
NVOL_FNS(QuotaOutOfDate)
176-
NVOL_FNS(UsnJrnlStamped)
177-
NVOL_FNS(SparseEnabled)
169+
DEFINE_NVOL_BIT_OPS(Errors)
170+
DEFINE_NVOL_BIT_OPS(ShowSystemFiles)
171+
DEFINE_NVOL_BIT_OPS(CaseSensitive)
172+
DEFINE_NVOL_BIT_OPS(LogFileEmpty)
173+
DEFINE_NVOL_BIT_OPS(QuotaOutOfDate)
174+
DEFINE_NVOL_BIT_OPS(UsnJrnlStamped)
175+
DEFINE_NVOL_BIT_OPS(SparseEnabled)
178176

179177
#endif /* _LINUX_NTFS_VOLUME_H */

0 commit comments

Comments
 (0)