diff options
| -rw-r--r-- | fs/ntfs/ChangeLog | 1 | ||||
| -rw-r--r-- | fs/ntfs/attrib.c | 21 | ||||
| -rw-r--r-- | fs/ntfs/layout.h | 42 | ||||
| -rw-r--r-- | fs/ntfs/ntfs.h | 3 |
4 files changed, 40 insertions, 27 deletions
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 8ff6ea778fbd..52f868a9662b 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog | |||
| @@ -110,6 +110,7 @@ ToDo/Notes: | |||
| 110 | only emit a warning when the checksum is incorrect rather than | 110 | only emit a warning when the checksum is incorrect rather than |
| 111 | refusing the mount. Thanks to Bernd Casimir for pointing this | 111 | refusing the mount. Thanks to Bernd Casimir for pointing this |
| 112 | problem out. | 112 | problem out. |
| 113 | - Update attribute definition handling. | ||
| 113 | 114 | ||
| 114 | 2.1.22 - Many bug and race fixes and error handling improvements. | 115 | 2.1.22 - Many bug and race fixes and error handling improvements. |
| 115 | 116 | ||
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index 1b95f39234a3..23ca3bdfb89a 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c | |||
| @@ -1138,28 +1138,21 @@ int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPE type, | |||
| 1138 | * Check whether the attribute of @type on the ntfs volume @vol is allowed to | 1138 | * Check whether the attribute of @type on the ntfs volume @vol is allowed to |
| 1139 | * be non-resident. This information is obtained from $AttrDef system file. | 1139 | * be non-resident. This information is obtained from $AttrDef system file. |
| 1140 | * | 1140 | * |
| 1141 | * Return 0 if the attribute is allowed to be non-resident, -EPERM if not, or | 1141 | * Return 0 if the attribute is allowed to be non-resident, -EPERM if not, and |
| 1142 | * -ENOENT if the attribute is not listed in $AttrDef. | 1142 | * -ENOENT if the attribute is not listed in $AttrDef. |
| 1143 | */ | 1143 | */ |
| 1144 | int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPE type) | 1144 | int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPE type) |
| 1145 | { | 1145 | { |
| 1146 | ATTR_DEF *ad; | 1146 | ATTR_DEF *ad; |
| 1147 | 1147 | ||
| 1148 | /* | ||
| 1149 | * $DATA and $EA are always allowed to be non-resident even if $AttrDef | ||
| 1150 | * does not specify this in the flags of the $DATA attribute definition | ||
| 1151 | * record. | ||
| 1152 | */ | ||
| 1153 | if (type == AT_DATA || type == AT_EA) | ||
| 1154 | return 0; | ||
| 1155 | /* Find the attribute definition record in $AttrDef. */ | 1148 | /* Find the attribute definition record in $AttrDef. */ |
| 1156 | ad = ntfs_attr_find_in_attrdef(vol, type); | 1149 | ad = ntfs_attr_find_in_attrdef(vol, type); |
| 1157 | if (unlikely(!ad)) | 1150 | if (unlikely(!ad)) |
| 1158 | return -ENOENT; | 1151 | return -ENOENT; |
| 1159 | /* Check the flags and return the result. */ | 1152 | /* Check the flags and return the result. */ |
| 1160 | if (ad->flags & CAN_BE_NON_RESIDENT) | 1153 | if (ad->flags & ATTR_DEF_RESIDENT) |
| 1161 | return 0; | 1154 | return -EPERM; |
| 1162 | return -EPERM; | 1155 | return 0; |
| 1163 | } | 1156 | } |
| 1164 | 1157 | ||
| 1165 | /** | 1158 | /** |
| @@ -1182,9 +1175,9 @@ int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPE type) | |||
| 1182 | */ | 1175 | */ |
| 1183 | int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPE type) | 1176 | int ntfs_attr_can_be_resident(const ntfs_volume *vol, const ATTR_TYPE type) |
| 1184 | { | 1177 | { |
| 1185 | if (type != AT_INDEX_ALLOCATION && type != AT_EA) | 1178 | if (type == AT_INDEX_ALLOCATION || type == AT_EA) |
| 1186 | return 0; | 1179 | return -EPERM; |
| 1187 | return -EPERM; | 1180 | return 0; |
| 1188 | } | 1181 | } |
| 1189 | 1182 | ||
| 1190 | /** | 1183 | /** |
diff --git a/fs/ntfs/layout.h b/fs/ntfs/layout.h index 8d1f1326612f..458cb541d4dd 100644 --- a/fs/ntfs/layout.h +++ b/fs/ntfs/layout.h | |||
| @@ -547,26 +547,44 @@ enum { | |||
| 547 | COLLATION_NTOFS_ULONG = const_cpu_to_le32(0x10), | 547 | COLLATION_NTOFS_ULONG = const_cpu_to_le32(0x10), |
| 548 | COLLATION_NTOFS_SID = const_cpu_to_le32(0x11), | 548 | COLLATION_NTOFS_SID = const_cpu_to_le32(0x11), |
| 549 | COLLATION_NTOFS_SECURITY_HASH = const_cpu_to_le32(0x12), | 549 | COLLATION_NTOFS_SECURITY_HASH = const_cpu_to_le32(0x12), |
| 550 | COLLATION_NTOFS_ULONGS = const_cpu_to_le32(0x13) | 550 | COLLATION_NTOFS_ULONGS = const_cpu_to_le32(0x13), |
| 551 | }; | 551 | }; |
| 552 | 552 | ||
| 553 | typedef le32 COLLATION_RULE; | 553 | typedef le32 COLLATION_RULE; |
| 554 | 554 | ||
| 555 | /* | 555 | /* |
| 556 | * The flags (32-bit) describing attribute properties in the attribute | 556 | * The flags (32-bit) describing attribute properties in the attribute |
| 557 | * definition structure. FIXME: This information is from Regis's information | 557 | * definition structure. FIXME: This information is based on Regis's |
| 558 | * and, according to him, it is not certain and probably incomplete. | 558 | * information and, according to him, it is not certain and probably |
| 559 | * The INDEXABLE flag is fairly certainly correct as only the file name | 559 | * incomplete. The INDEXABLE flag is fairly certainly correct as only the file |
| 560 | * attribute has this flag set and this is the only attribute indexed in NT4. | 560 | * name attribute has this flag set and this is the only attribute indexed in |
| 561 | * NT4. | ||
| 561 | */ | 562 | */ |
| 562 | enum { | 563 | enum { |
| 563 | INDEXABLE = const_cpu_to_le32(0x02), /* Attribute can be | 564 | ATTR_DEF_INDEXABLE = const_cpu_to_le32(0x02), /* Attribute can be |
| 564 | indexed. */ | 565 | indexed. */ |
| 565 | NEED_TO_REGENERATE = const_cpu_to_le32(0x40), /* Need to regenerate | 566 | ATTR_DEF_MULTIPLE = const_cpu_to_le32(0x04), /* Attribute type |
| 566 | during regeneration | 567 | can be present multiple times in the |
| 567 | phase. */ | 568 | mft records of an inode. */ |
| 568 | CAN_BE_NON_RESIDENT = const_cpu_to_le32(0x80), /* Attribute can be | 569 | ATTR_DEF_NOT_ZERO = const_cpu_to_le32(0x08), /* Attribute value |
| 569 | non-resident. */ | 570 | must contain at least one non-zero |
| 571 | byte. */ | ||
| 572 | ATTR_DEF_INDEXED_UNIQUE = const_cpu_to_le32(0x10), /* Attribute must be | ||
| 573 | indexed and the attribute value must be | ||
| 574 | unique for the attribute type in all of | ||
| 575 | the mft records of an inode. */ | ||
| 576 | ATTR_DEF_NAMED_UNIQUE = const_cpu_to_le32(0x20), /* Attribute must be | ||
| 577 | named and the name must be unique for | ||
| 578 | the attribute type in all of the mft | ||
| 579 | records of an inode. */ | ||
| 580 | ATTR_DEF_RESIDENT = const_cpu_to_le32(0x40), /* Attribute must be | ||
| 581 | resident. */ | ||
| 582 | ATTR_DEF_ALWAYS_LOG = const_cpu_to_le32(0x80), /* Always log | ||
| 583 | modifications to this attribute, | ||
| 584 | regardless of whether it is resident or | ||
| 585 | non-resident. Without this, only log | ||
| 586 | modifications if the attribute is | ||
| 587 | resident. */ | ||
| 570 | }; | 588 | }; |
| 571 | 589 | ||
| 572 | typedef le32 ATTR_DEF_FLAGS; | 590 | typedef le32 ATTR_DEF_FLAGS; |
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index a0bf706797bb..e85f6e928b1e 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * ntfs.h - Defines for NTFS Linux kernel driver. Part of the Linux-NTFS | 2 | * ntfs.h - Defines for NTFS Linux kernel driver. Part of the Linux-NTFS |
| 3 | * project. | 3 | * project. |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2001-2004 Anton Altaparmakov | 5 | * Copyright (c) 2001-2005 Anton Altaparmakov |
| 6 | * Copyright (C) 2002 Richard Russon | 6 | * Copyright (C) 2002 Richard Russon |
| 7 | * | 7 | * |
| 8 | * This program/include file is free software; you can redistribute it and/or | 8 | * This program/include file is free software; you can redistribute it and/or |
| @@ -41,6 +41,7 @@ typedef enum { | |||
| 41 | NTFS_BLOCK_SIZE_BITS = 9, | 41 | NTFS_BLOCK_SIZE_BITS = 9, |
| 42 | NTFS_SB_MAGIC = 0x5346544e, /* 'NTFS' */ | 42 | NTFS_SB_MAGIC = 0x5346544e, /* 'NTFS' */ |
| 43 | NTFS_MAX_NAME_LEN = 255, | 43 | NTFS_MAX_NAME_LEN = 255, |
| 44 | NTFS_MAX_ATTR_NAME_LEN = 255, | ||
| 44 | } NTFS_CONSTANTS; | 45 | } NTFS_CONSTANTS; |
| 45 | 46 | ||
| 46 | /* Global variables. */ | 47 | /* Global variables. */ |
