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 /* FUNCTIONS ****************************************************************/
40 return(*run
& 0x0f) + ((*run
>> 4) & 0x0f) + 1;
48 UCHAR n1
= *run
& 0x0f;
49 UCHAR n2
= (*run
>> 4) & 0x0f;
50 LONGLONG lcn
= (n2
== 0) ? 0 : (CHAR
)(run
[n1
+ n2
]);
53 for (i
= n1
+n2
- 1; i
> n1
; i
--)
54 lcn
= (lcn
<< 8) + run
[i
];
67 for (i
= n
; i
> 0; i
--)
68 count
= (count
<< 8) + run
[i
];
74 FindRun(PNONRESIDENT_ATTRIBUTE NresAttr
,
80 ULONGLONG base
= NresAttr
->StartVcn
;
82 if (vcn
< NresAttr
->StartVcn
|| vcn
> NresAttr
->LastVcn
)
87 for (run
= (PUCHAR
)((ULONG_PTR
)NresAttr
+ NresAttr
->RunArrayOffset
);
88 *run
!= 0; run
+= RunLength(run
))
91 *count
= RunCount(run
);
93 if (base
<= vcn
&& vcn
< base
+ *count
)
95 *lcn
= (RunLCN(run
) == 0) ? 0 : *lcn
+ vcn
- base
;
96 *count
-= (ULONG
)(vcn
- base
);
112 NtfsDumpFileNameAttribute(PATTRIBUTE Attribute
)
114 PRESIDENT_ATTRIBUTE ResAttr
;
115 PFILENAME_ATTRIBUTE FileNameAttr
;
117 DbgPrint(" $FILE_NAME ");
119 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
120 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
122 FileNameAttr
= (PFILENAME_ATTRIBUTE
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
123 DbgPrint(" '%.*S' ", FileNameAttr
->NameLength
, FileNameAttr
->Name
);
129 NtfsDumpVolumeNameAttribute(PATTRIBUTE Attribute
)
131 PRESIDENT_ATTRIBUTE ResAttr
;
134 DbgPrint(" $VOLUME_NAME ");
136 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
137 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
139 VolumeName
= (PWCHAR
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
140 DbgPrint(" '%.*S' ", ResAttr
->ValueLength
/ sizeof(WCHAR
), VolumeName
);
146 NtfsDumpVolumeInformationAttribute(PATTRIBUTE Attribute
)
148 PRESIDENT_ATTRIBUTE ResAttr
;
149 PVOLINFO_ATTRIBUTE VolInfoAttr
;
151 DbgPrint(" $VOLUME_INFORMATION ");
153 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
154 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
156 VolInfoAttr
= (PVOLINFO_ATTRIBUTE
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
157 DbgPrint(" NTFS Version %u.%u Flags 0x%04hx ",
158 VolInfoAttr
->MajorVersion
,
159 VolInfoAttr
->MinorVersion
,
166 NtfsDumpAttribute (PATTRIBUTE Attribute
)
168 PNONRESIDENT_ATTRIBUTE NresAttr
;
172 ULONGLONG runcount
= 0;
174 switch (Attribute
->AttributeType
)
176 case AttributeFileName
:
177 NtfsDumpFileNameAttribute(Attribute
);
180 case AttributeStandardInformation
:
181 DbgPrint(" $STANDARD_INFORMATION ");
184 case AttributeAttributeList
:
185 DbgPrint(" $ATTRIBUTE_LIST ");
188 case AttributeObjectId
:
189 DbgPrint(" $OBJECT_ID ");
192 case AttributeSecurityDescriptor
:
193 DbgPrint(" $SECURITY_DESCRIPTOR ");
196 case AttributeVolumeName
:
197 NtfsDumpVolumeNameAttribute(Attribute
);
200 case AttributeVolumeInformation
:
201 NtfsDumpVolumeInformationAttribute(Attribute
);
206 //DataBuf = ExAllocatePool(NonPagedPool,AttributeLengthAllocated(Attribute));
209 case AttributeIndexRoot
:
210 DbgPrint(" $INDEX_ROOT ");
213 case AttributeIndexAllocation
:
214 DbgPrint(" $INDEX_ALLOCATION ");
217 case AttributeBitmap
:
218 DbgPrint(" $BITMAP ");
221 case AttributeReparsePoint
:
222 DbgPrint(" $REPARSE_POINT ");
225 case AttributeEAInformation
:
226 DbgPrint(" $EA_INFORMATION ");
233 case AttributePropertySet
:
234 DbgPrint(" $PROPERTY_SET ");
237 case AttributeLoggedUtilityStream
:
238 DbgPrint(" $LOGGED_UTILITY_STREAM ");
242 DbgPrint(" Attribute %lx ",
243 Attribute
->AttributeType
);
247 if (Attribute
->NameLength
!= 0)
249 Name
.Length
= Attribute
->NameLength
* sizeof(WCHAR
);
250 Name
.MaximumLength
= Name
.Length
;
251 Name
.Buffer
= (PWCHAR
)((ULONG_PTR
)Attribute
+ Attribute
->NameOffset
);
253 DbgPrint("'%wZ' ", &Name
);
257 Attribute
->Nonresident
? "non-resident" : "resident");
259 if (Attribute
->Nonresident
)
261 NresAttr
= (PNONRESIDENT_ATTRIBUTE
)Attribute
;
263 FindRun(NresAttr
,0,&lcn
, &runcount
);
265 DbgPrint(" AllocatedSize %I64u DataSize %I64u\n",
266 NresAttr
->AllocatedSize
, NresAttr
->DataSize
);
267 DbgPrint(" logical clusters: %I64u - %I64u\n",
268 lcn
, lcn
+ runcount
- 1);
274 NtfsDumpFileAttributes(PFILE_RECORD_HEADER FileRecord
)
276 PATTRIBUTE Attribute
;
278 Attribute
= (PATTRIBUTE
)((ULONG_PTR
)FileRecord
+ FileRecord
->AttributeOffset
);
279 while (Attribute
< (PATTRIBUTE
)((ULONG_PTR
)FileRecord
+ FileRecord
->BytesInUse
) &&
280 Attribute
->AttributeType
!= (ATTRIBUTE_TYPE
)-1)
282 NtfsDumpAttribute(Attribute
);
284 Attribute
= (PATTRIBUTE
)((ULONG_PTR
)Attribute
+ Attribute
->Length
);