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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: drivers/fs/ntfs/attrib.c
24 * PURPOSE: NTFS filesystem driver
25 * PROGRAMMER: Eric Kohl
26 * Updated by Valentin Verkhovsky 2003/09/12
29 /* INCLUDES *****************************************************************/
36 /* GLOBALS *****************************************************************/
39 /* FUNCTIONS ****************************************************************/
46 return(*run
& 0x0f) + ((*run
>> 4) & 0x0f) + 1;
53 UCHAR n1
= *run
& 0x0f;
54 UCHAR n2
= (*run
>> 4) & 0x0f;
55 LONGLONG lcn
= (n2
== 0) ? 0 : (CHAR
)(run
[n1
+ n2
]);
58 for (i
= n1
+n2
- 1; i
> n1
; i
--)
59 lcn
= (lcn
<< 8) + run
[i
];
72 for (i
= n
; i
> 0; i
--)
73 count
= (count
<< 8) + run
[i
];
79 FindRun (PNONRESIDENT_ATTRIBUTE NresAttr
,
86 ULONGLONG base
= NresAttr
->StartVcn
;
88 if (vcn
< NresAttr
->StartVcn
|| vcn
> NresAttr
->LastVcn
)
93 for (run
= (PUCHAR
)((ULONG
)NresAttr
+ NresAttr
->RunArrayOffset
);
94 *run
!= 0; run
+= RunLength(run
))
97 *count
= RunCount(run
);
99 if (base
<= vcn
&& vcn
< base
+ *count
)
101 *lcn
= (RunLCN(run
) == 0) ? 0 : *lcn
+ vcn
- base
;
102 *count
-= (ULONG
)(vcn
- base
);
117 NtfsDumpFileNameAttribute(PATTRIBUTE Attribute
)
119 PRESIDENT_ATTRIBUTE ResAttr
;
120 PFILENAME_ATTRIBUTE FileNameAttr
;
122 DbgPrint(" $FILE_NAME ");
124 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
125 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
127 FileNameAttr
= (PFILENAME_ATTRIBUTE
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
128 DbgPrint(" '%.*S' ", FileNameAttr
->NameLength
, FileNameAttr
->Name
);
133 NtfsDumpVolumeNameAttribute(PATTRIBUTE Attribute
)
135 PRESIDENT_ATTRIBUTE ResAttr
;
138 DbgPrint(" $VOLUME_NAME ");
140 ResAttr
= (PRESIDENT_ATTRIBUTE
)Attribute
;
141 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
143 VolumeName
= (PWCHAR
)((ULONG_PTR
)ResAttr
+ ResAttr
->ValueOffset
);
144 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
,
168 NtfsDumpAttribute (PATTRIBUTE Attribute
)
170 PNONRESIDENT_ATTRIBUTE NresAttr
;
176 switch (Attribute
->AttributeType
)
178 case AttributeFileName
:
179 NtfsDumpFileNameAttribute(Attribute
);
182 case AttributeStandardInformation
:
183 DbgPrint(" $STANDARD_INFORMATION ");
186 case AttributeAttributeList
:
187 DbgPrint(" $ATTRIBUTE_LIST ");
190 case AttributeObjectId
:
191 DbgPrint(" $OBJECT_ID ");
194 case AttributeSecurityDescriptor
:
195 DbgPrint(" $SECURITY_DESCRIPTOR ");
198 case AttributeVolumeName
:
199 NtfsDumpVolumeNameAttribute(Attribute
);
202 case AttributeVolumeInformation
:
203 NtfsDumpVolumeInformationAttribute(Attribute
);
208 //DataBuf = ExAllocatePool(NonPagedPool,AttributeLengthAllocated(Attribute));
211 case AttributeIndexRoot
:
212 DbgPrint(" $INDEX_ROOT ");
215 case AttributeIndexAllocation
:
216 DbgPrint(" $INDEX_ALLOCATION ");
219 case AttributeBitmap
:
220 DbgPrint(" $BITMAP ");
223 case AttributeReparsePoint
:
224 DbgPrint(" $REPARSE_POINT ");
227 case AttributeEAInformation
:
228 DbgPrint(" $EA_INFORMATION ");
235 case AttributePropertySet
:
236 DbgPrint(" $PROPERTY_SET ");
239 case AttributeLoggedUtilityStream
:
240 DbgPrint(" $LOGGED_UTILITY_STREAM ");
244 DbgPrint(" Attribute %lx ",
245 Attribute
->AttributeType
);
249 if (Attribute
->NameLength
!= 0)
251 Name
.Length
= Attribute
->NameLength
* sizeof(WCHAR
);
252 Name
.MaximumLength
= Name
.Length
;
253 Name
.Buffer
= (PWCHAR
)((ULONG
)Attribute
+ Attribute
->NameOffset
);
255 DbgPrint("'%wZ' ", &Name
);
259 Attribute
->Nonresident
? "non-resident" : "resident");
261 if (Attribute
->Nonresident
)
263 NresAttr
= (PNONRESIDENT_ATTRIBUTE
)Attribute
;
265 FindRun (NresAttr
,0,&lcn
, &runcount
);
267 DbgPrint (" AllocatedSize %I64u DataSize %I64u\n",
268 NresAttr
->AllocatedSize
, NresAttr
->DataSize
);
269 DbgPrint (" logical clusters: %I64u - %I64u\n",
270 lcn
, lcn
+ runcount
- 1);
276 NtfsDumpFileAttributes (PFILE_RECORD_HEADER FileRecord
)
278 PATTRIBUTE Attribute
;
280 Attribute
= (PATTRIBUTE
)((ULONG_PTR
)FileRecord
+ FileRecord
->AttributeOffset
);
281 while (Attribute
< (PATTRIBUTE
)((ULONG_PTR
)FileRecord
+ FileRecord
->BytesInUse
) &&
282 Attribute
->AttributeType
!= (ATTRIBUTE_TYPE
)-1)
284 NtfsDumpAttribute (Attribute
);
286 Attribute
= (PATTRIBUTE
)((ULONG_PTR
)Attribute
+ Attribute
->Length
);