3 * Copyright (C) 2002,2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/filesystem/ntfs/attrib.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMER: Eric Kohl
24 * Updated by Valentin Verkhovsky 2003/09/12
27 /* INCLUDES *****************************************************************/
34 /* GLOBALS *****************************************************************/
37 /* FUNCTIONS ****************************************************************/
43 return(*run
& 0x0f) + ((*run
>> 4) & 0x0f) + 1;
51 UCHAR n1
= *run
& 0x0f;
52 UCHAR n2
= (*run
>> 4) & 0x0f;
53 LONGLONG lcn
= (n2
== 0) ? 0 : (CHAR
)(run
[n1
+ n2
]);
56 for (i
= n1
+n2
- 1; i
> n1
; i
--)
57 lcn
= (lcn
<< 8) + run
[i
];
70 for (i
= n
; i
> 0; i
--)
71 count
= (count
<< 8) + run
[i
];
77 FindRun(PNONRESIDENT_ATTRIBUTE NresAttr
,
83 ULONGLONG base
= NresAttr
->StartVcn
;
85 if (vcn
< NresAttr
->StartVcn
|| vcn
> NresAttr
->LastVcn
)
90 for (run
= (PUCHAR
)((ULONG_PTR
)NresAttr
+ NresAttr
->RunArrayOffset
);
91 *run
!= 0; run
+= RunLength(run
))
94 *count
= RunCount(run
);
96 if (base
<= vcn
&& vcn
< base
+ *count
)
98 *lcn
= (RunLCN(run
) == 0) ? 0 : *lcn
+ vcn
- base
;
99 *count
-= (ULONG
)(vcn
- base
);
115 NtfsDumpFileNameAttribute(PATTRIBUTE Attribute
)
117 PRESIDENT_ATTRIBUTE ResAttr
;
118 PFILENAME_ATTRIBUTE FileNameAttr
;
120 DbgPrint(" $FILE_NAME ");
122 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
123 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
125 FileNameAttr
= (PFILENAME_ATTRIBUTE
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
126 DbgPrint(" '%.*S' ", FileNameAttr
->NameLength
, FileNameAttr
->Name
);
132 NtfsDumpVolumeNameAttribute(PATTRIBUTE Attribute
)
134 PRESIDENT_ATTRIBUTE ResAttr
;
137 DbgPrint(" $VOLUME_NAME ");
139 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
140 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
142 VolumeName
= (PWCHAR
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
143 DbgPrint(" '%.*S' ", ResAttr
->ValueLength
/ sizeof(WCHAR
), VolumeName
);
149 NtfsDumpVolumeInformationAttribute(PATTRIBUTE Attribute
)
151 PRESIDENT_ATTRIBUTE ResAttr
;
152 PVOLINFO_ATTRIBUTE VolInfoAttr
;
154 DbgPrint(" $VOLUME_INFORMATION ");
156 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
157 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
159 VolInfoAttr
= (PVOLINFO_ATTRIBUTE
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
160 DbgPrint(" NTFS Version %u.%u Flags 0x%04hx ",
161 VolInfoAttr
->MajorVersion
,
162 VolInfoAttr
->MinorVersion
,
169 NtfsDumpAttribute (PATTRIBUTE Attribute
)
171 PNONRESIDENT_ATTRIBUTE NresAttr
;
175 ULONGLONG runcount
= 0;
177 switch (Attribute
->AttributeType
)
179 case AttributeFileName
:
180 NtfsDumpFileNameAttribute(Attribute
);
183 case AttributeStandardInformation
:
184 DbgPrint(" $STANDARD_INFORMATION ");
187 case AttributeAttributeList
:
188 DbgPrint(" $ATTRIBUTE_LIST ");
191 case AttributeObjectId
:
192 DbgPrint(" $OBJECT_ID ");
195 case AttributeSecurityDescriptor
:
196 DbgPrint(" $SECURITY_DESCRIPTOR ");
199 case AttributeVolumeName
:
200 NtfsDumpVolumeNameAttribute(Attribute
);
203 case AttributeVolumeInformation
:
204 NtfsDumpVolumeInformationAttribute(Attribute
);
209 //DataBuf = ExAllocatePool(NonPagedPool,AttributeLengthAllocated(Attribute));
212 case AttributeIndexRoot
:
213 DbgPrint(" $INDEX_ROOT ");
216 case AttributeIndexAllocation
:
217 DbgPrint(" $INDEX_ALLOCATION ");
220 case AttributeBitmap
:
221 DbgPrint(" $BITMAP ");
224 case AttributeReparsePoint
:
225 DbgPrint(" $REPARSE_POINT ");
228 case AttributeEAInformation
:
229 DbgPrint(" $EA_INFORMATION ");
236 case AttributePropertySet
:
237 DbgPrint(" $PROPERTY_SET ");
240 case AttributeLoggedUtilityStream
:
241 DbgPrint(" $LOGGED_UTILITY_STREAM ");
245 DbgPrint(" Attribute %lx ",
246 Attribute
->AttributeType
);
250 if (Attribute
->NameLength
!= 0)
252 Name
.Length
= Attribute
->NameLength
* sizeof(WCHAR
);
253 Name
.MaximumLength
= Name
.Length
;
254 Name
.Buffer
= (PWCHAR
)((ULONG_PTR
)Attribute
+ Attribute
->NameOffset
);
256 DbgPrint("'%wZ' ", &Name
);
260 Attribute
->Nonresident
? "non-resident" : "resident");
262 if (Attribute
->Nonresident
)
264 NresAttr
= (PNONRESIDENT_ATTRIBUTE
)Attribute
;
266 FindRun(NresAttr
,0,&lcn
, &runcount
);
268 DbgPrint(" AllocatedSize %I64u DataSize %I64u\n",
269 NresAttr
->AllocatedSize
, NresAttr
->DataSize
);
270 DbgPrint(" logical clusters: %I64u - %I64u\n",
271 lcn
, lcn
+ runcount
- 1);
277 NtfsDumpFileAttributes(PFILE_RECORD_HEADER FileRecord
)
279 PATTRIBUTE Attribute
;
281 Attribute
= (PATTRIBUTE
)((ULONG_PTR
)FileRecord
+ FileRecord
->AttributeOffset
);
282 while (Attribute
< (PATTRIBUTE
)((ULONG_PTR
)FileRecord
+ FileRecord
->BytesInUse
) &&
283 Attribute
->AttributeType
!= (ATTRIBUTE_TYPE
)-1)
285 NtfsDumpAttribute(Attribute
);
287 Attribute
= (PATTRIBUTE
)((ULONG_PTR
)Attribute
+ Attribute
->Length
);