Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

323 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. attrlist.hxx
  5. Abstract:
  6. This module contains the declarations for NTFS_ATTRIBUTE_LIST,
  7. which models an ATTRIBUTE_LIST Attribute in an NTFS File Record
  8. Segment.
  9. If a file has any external attributes (i.e. if it has more than
  10. one File Record Segment), then it will have an ATTRIBUTE_LIST
  11. attribute. This attribute's value consists of a series of
  12. Attribute List Entries, which describe the attribute records
  13. in the file's File Record Segments. There is an entry for each
  14. attribute record attached to the file, including the attribute
  15. records in the base File Record Segment, and in particular
  16. including the attribute records which describe the ATTRIBUTE_LIST
  17. attribute itself.
  18. An entry in the Attribute List gives the type code and name (if any)
  19. of the attribute, along with the LowestVcn of the attribute record
  20. (zero if the attribute record is Resident) and a segment reference
  21. (which combines an MFT VCN with a sequence number) showing where
  22. the attribute record may be found.
  23. The entries in the Attribute List are sorted first by attribute
  24. type code and then by name. Note that two attributes can have the
  25. same type code and name only if they can be distinguished by
  26. value.
  27. Author:
  28. Bill McJohn (billmc) 12-Aug-1991
  29. Environment:
  30. ULIB, User Mode
  31. --*/
  32. #if !defined( NTFS_ATTRIBUTE_LIST_DEFN )
  33. #define NTFS_ATTRIBUTE_LIST_DEFN
  34. #include "attrib.hxx"
  35. #include "hmem.hxx"
  36. #include "volume.hxx"
  37. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  38. DECLARE_CLASS( WSTRING );
  39. DECLARE_CLASS( NTFS_ATTRIBUTE_RECORD );
  40. DECLARE_CLASS( NTFS_ATTRIBUTE_RECORD_LIST );
  41. DECLARE_CLASS( NTFS_BITMAP );
  42. DECLARE_CLASS( NTFS_UPCASE_TABLE );
  43. DECLARE_CLASS( NTFS_ATTRIBUTE_LIST );
  44. // This macro produces a pointer to the wide-character name of an attribute
  45. // list entry from a pointer to an attribute list entry.
  46. #define NameFromEntry( x ) ((PWSTR)((PBYTE)(x)+(x)->AttributeNameOffset))
  47. // This macro produces a pointer to the attribute list entry
  48. // following x
  49. #define NextEntry( x ) \
  50. ((PATTRIBUTE_LIST_ENTRY)((PBYTE)(x) + (x)->RecordLength))
  51. typedef struct _ATTR_LIST_CURR_ENTRY {
  52. PATTRIBUTE_LIST_ENTRY CurrentEntry;
  53. ULONG CurrentOffset;
  54. };
  55. DEFINE_TYPE( _ATTR_LIST_CURR_ENTRY, ATTR_LIST_CURR_ENTRY );
  56. class NTFS_ATTRIBUTE_LIST : public NTFS_ATTRIBUTE {
  57. public:
  58. UNTFS_EXPORT
  59. DECLARE_CONSTRUCTOR( NTFS_ATTRIBUTE_LIST );
  60. VIRTUAL
  61. UNTFS_EXPORT
  62. ~NTFS_ATTRIBUTE_LIST(
  63. );
  64. NONVIRTUAL
  65. BOOLEAN
  66. Initialize (
  67. IN OUT PLOG_IO_DP_DRIVE Drive,
  68. IN ULONG ClusterFactor,
  69. IN PNTFS_UPCASE_TABLE UpcaseTable
  70. );
  71. NONVIRTUAL
  72. BOOLEAN
  73. Initialize (
  74. IN OUT PLOG_IO_DP_DRIVE Drive,
  75. IN ULONG ClusterFactor,
  76. IN PCNTFS_ATTRIBUTE_RECORD AttributeRecord,
  77. IN PNTFS_UPCASE_TABLE UpcaseTable
  78. );
  79. NONVIRTUAL
  80. BOOLEAN
  81. VerifyAndFix(
  82. IN FIX_LEVEL FixLevel,
  83. IN OUT PNTFS_BITMAP VolumeBitmap,
  84. IN OUT PMESSAGE Message,
  85. IN VCN FileNumber,
  86. OUT PBOOLEAN Tube,
  87. IN OUT PBOOLEAN DiskErrorsFound DEFAULT NULL
  88. );
  89. NONVIRTUAL
  90. BOOLEAN
  91. AddEntry(
  92. IN ATTRIBUTE_TYPE_CODE Type,
  93. IN VCN LowestVcn,
  94. IN PCMFT_SEGMENT_REFERENCE SegmentReference,
  95. IN USHORT InstanceTag,
  96. IN PCWSTRING Name DEFAULT NULL
  97. );
  98. NONVIRTUAL
  99. BOOLEAN
  100. DeleteEntry(
  101. IN ATTRIBUTE_TYPE_CODE Type,
  102. IN VCN LowestVcn,
  103. IN PCWSTRING Name DEFAULT NULL,
  104. IN PCMFT_SEGMENT_REFERENCE SegmentReference DEFAULT NULL
  105. );
  106. NONVIRTUAL
  107. BOOLEAN
  108. DeleteEntry(
  109. IN ULONG EntryIndex
  110. );
  111. NONVIRTUAL
  112. BOOLEAN
  113. DeleteCurrentEntry(
  114. IN PATTR_LIST_CURR_ENTRY Entry
  115. );
  116. NONVIRTUAL
  117. BOOLEAN
  118. DeleteEntries(
  119. IN ATTRIBUTE_TYPE_CODE Type,
  120. IN PCWSTRING Name DEFAULT NULL
  121. );
  122. NONVIRTUAL
  123. BOOLEAN
  124. IsInList(
  125. IN ATTRIBUTE_TYPE_CODE Type,
  126. IN PCWSTRING Name DEFAULT NULL
  127. ) CONST;
  128. #if 0
  129. NONVIRTUAL
  130. UNTFS_EXPORT
  131. BOOLEAN
  132. QueryEntry(
  133. IN ULONG EntryIndex,
  134. OUT PATTRIBUTE_TYPE_CODE Type,
  135. OUT PVCN LowestVcn,
  136. OUT PMFT_SEGMENT_REFERENCE SegmentReference,
  137. OUT PUSHORT InstanceTag,
  138. OUT PWSTRING Name
  139. ) CONST;
  140. #endif
  141. NONVIRTUAL
  142. UNTFS_EXPORT
  143. BOOLEAN
  144. QueryNextEntry(
  145. IN OUT PATTR_LIST_CURR_ENTRY CurrEntry,
  146. OUT PATTRIBUTE_TYPE_CODE Type,
  147. OUT PVCN LowestVcn,
  148. OUT PMFT_SEGMENT_REFERENCE SegmentReference,
  149. OUT PUSHORT InstanceTag,
  150. OUT PWSTRING Name
  151. ) CONST;
  152. NONVIRTUAL
  153. BOOLEAN
  154. QueryEntry(
  155. IN MFT_SEGMENT_REFERENCE SegmentReference,
  156. IN USHORT InstanceTag,
  157. OUT PATTRIBUTE_TYPE_CODE Type,
  158. OUT PVCN LowestVcn,
  159. OUT PWSTRING Name
  160. ) CONST;
  161. NONVIRTUAL
  162. UNTFS_EXPORT
  163. PCATTRIBUTE_LIST_ENTRY
  164. GetNextAttributeListEntry(
  165. IN PCATTRIBUTE_LIST_ENTRY CurrentEntry
  166. ) CONST;
  167. NONVIRTUAL
  168. BOOLEAN
  169. QueryExternalReference(
  170. IN ATTRIBUTE_TYPE_CODE Type,
  171. OUT PMFT_SEGMENT_REFERENCE SegmentReference,
  172. OUT PULONG EntryIndex,
  173. IN PCWSTRING Name DEFAULT NULL,
  174. IN PVCN DesiredVcn DEFAULT NULL,
  175. OUT PVCN StartingVcn DEFAULT NULL
  176. ) CONST;
  177. NONVIRTUAL
  178. BOOLEAN
  179. QueryNextAttribute(
  180. IN OUT PATTRIBUTE_TYPE_CODE TypeCode,
  181. IN OUT PWSTRING Name
  182. ) CONST;
  183. NONVIRTUAL
  184. UNTFS_EXPORT
  185. BOOLEAN
  186. ReadList(
  187. );
  188. NONVIRTUAL
  189. BOOLEAN
  190. WriteList(
  191. PNTFS_BITMAP VolumeBitmap
  192. );
  193. NONVIRTUAL
  194. BOOLEAN
  195. QueryAttributeRecord(
  196. OUT PVOID AttributeRecordData,
  197. IN ULONG MaximumLength,
  198. OUT PNTFS_ATTRIBUTE_RECORD AttributeRecord
  199. ) CONST;
  200. NONVIRTUAL
  201. BOOLEAN
  202. ModifyInstanceTag(
  203. IN PCNTFS_ATTRIBUTE_RECORD AttributeRecord,
  204. IN MFT_SEGMENT_REFERENCE SegmentReference,
  205. IN USHORT NewInstanceTag
  206. );
  207. private:
  208. NONVIRTUAL
  209. VOID
  210. Construct (
  211. );
  212. NONVIRTUAL
  213. VOID
  214. Destroy(
  215. );
  216. NONVIRTUAL
  217. PATTRIBUTE_LIST_ENTRY
  218. FindEntry(
  219. IN ATTRIBUTE_TYPE_CODE Type,
  220. IN PCWSTRING Name,
  221. IN VCN LowestVcn,
  222. OUT PULONG EntryOffset DEFAULT NULL,
  223. OUT PULONG EntryIndex DEFAULT NULL
  224. ) CONST;
  225. NONVIRTUAL
  226. BOOLEAN
  227. Sort(
  228. OUT PBOOLEAN Changes
  229. );
  230. HMEM _Mem;
  231. ULONG _LengthOfList;
  232. PNTFS_UPCASE_TABLE _UpcaseTable;
  233. };
  234. INLINE
  235. BOOLEAN
  236. NTFS_ATTRIBUTE_LIST::WriteList(
  237. IN OUT PNTFS_BITMAP VolumeBitmap
  238. )
  239. /*++
  240. Routine Description:
  241. This method writes the list to disk.
  242. Arguments:
  243. None.
  244. Return Value:
  245. TRUE upon successful completion.
  246. --*/
  247. {
  248. ULONG BytesWritten;
  249. return( Resize( _LengthOfList, VolumeBitmap ) &&
  250. Write( _Mem.GetBuf(),
  251. 0,
  252. _LengthOfList,
  253. &BytesWritten,
  254. VolumeBitmap ) &&
  255. BytesWritten == _LengthOfList );
  256. }
  257. #endif