2002-07-15 15:37:33 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
2003-01-17 18:51:13 +00:00
|
|
|
* Copyright (C) 2002,2003 ReactOS Team
|
2002-07-15 15:37:33 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2003-08-07 11:47:33 +00:00
|
|
|
/* $Id: attrib.c,v 1.5 2003/08/07 11:47:32 silverblade Exp $
|
2002-07-15 15:37:33 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2003-01-17 18:51:13 +00:00
|
|
|
* FILE: drivers/fs/ntfs/attrib.c
|
2002-07-15 15:37:33 +00:00
|
|
|
* PURPOSE: NTFS filesystem driver
|
|
|
|
* PROGRAMMER: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
|
2003-08-07 11:47:33 +00:00
|
|
|
#include <ntos.h>
|
|
|
|
|
2003-07-17 13:31:39 +00:00
|
|
|
//#define NDEBUG
|
2002-07-15 15:37:33 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include "ntfs.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2003-01-17 18:51:13 +00:00
|
|
|
VOID
|
|
|
|
NtfsDumpFileNameAttribute(PATTRIBUTE Attribute)
|
|
|
|
{
|
|
|
|
PRESIDENT_ATTRIBUTE ResAttr;
|
|
|
|
PFILENAME_ATTRIBUTE FileNameAttr;
|
|
|
|
|
|
|
|
DbgPrint(" $FILE_NAME ");
|
|
|
|
|
|
|
|
ResAttr = (PRESIDENT_ATTRIBUTE)Attribute;
|
|
|
|
// DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
|
|
|
|
|
|
|
|
FileNameAttr = (PFILENAME_ATTRIBUTE)((PVOID)ResAttr + ResAttr->ValueOffset);
|
|
|
|
DbgPrint(" '%.*S' ", FileNameAttr->NameLength, FileNameAttr->Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NtfsDumpVolumeNameAttribute(PATTRIBUTE Attribute)
|
|
|
|
{
|
|
|
|
PRESIDENT_ATTRIBUTE ResAttr;
|
|
|
|
PWCHAR VolumeName;
|
|
|
|
|
|
|
|
DbgPrint(" $VOLUME_NAME ");
|
|
|
|
|
|
|
|
ResAttr = (PRESIDENT_ATTRIBUTE)Attribute;
|
|
|
|
// DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
|
|
|
|
|
|
|
|
VolumeName = (PWCHAR)((PVOID)ResAttr + ResAttr->ValueOffset);
|
|
|
|
DbgPrint(" '%.*S' ", ResAttr->ValueLength/2, VolumeName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NtfsDumpVolumeInformationAttribute(PATTRIBUTE Attribute)
|
|
|
|
{
|
|
|
|
PRESIDENT_ATTRIBUTE ResAttr;
|
|
|
|
PVOLINFO_ATTRIBUTE VolInfoAttr;
|
|
|
|
|
|
|
|
DbgPrint(" $VOLUME_INFORMATION ");
|
|
|
|
|
|
|
|
ResAttr = (PRESIDENT_ATTRIBUTE)Attribute;
|
|
|
|
// DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
|
|
|
|
|
|
|
|
VolInfoAttr = (PVOLINFO_ATTRIBUTE)((PVOID)ResAttr + ResAttr->ValueOffset);
|
|
|
|
DbgPrint(" NTFS Version %u.%u Flags 0x%04hx ",
|
|
|
|
VolInfoAttr->MajorVersion,
|
|
|
|
VolInfoAttr->MinorVersion,
|
|
|
|
VolInfoAttr->Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
VOID
|
|
|
|
NtfsDumpAttribute(PATTRIBUTE Attribute)
|
|
|
|
{
|
|
|
|
PNONRESIDENT_ATTRIBUTE NresAttr;
|
|
|
|
PRESIDENT_ATTRIBUTE ResAttr;
|
|
|
|
UNICODE_STRING Name;
|
|
|
|
PUCHAR Ptr;
|
|
|
|
UCHAR RunHeader;
|
|
|
|
ULONG RunLength;
|
|
|
|
ULONG RunStart;
|
|
|
|
|
|
|
|
switch (Attribute->AttributeType)
|
|
|
|
{
|
|
|
|
case AttributeStandardInformation:
|
|
|
|
DbgPrint(" $STANDARD_INFORMATION ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeAttributeList:
|
|
|
|
DbgPrint(" $ATTRIBUTE_LIST ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeFileName:
|
2003-01-17 18:51:13 +00:00
|
|
|
NtfsDumpFileNameAttribute(Attribute);
|
2002-07-15 15:37:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeObjectId:
|
|
|
|
DbgPrint(" $OBJECT_ID ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeSecurityDescriptor:
|
|
|
|
DbgPrint(" $SECURITY_DESCRIPTOR ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeVolumeName:
|
2003-01-17 18:51:13 +00:00
|
|
|
NtfsDumpVolumeNameAttribute(Attribute);
|
2002-07-15 15:37:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeVolumeInformation:
|
2003-01-17 18:51:13 +00:00
|
|
|
NtfsDumpVolumeInformationAttribute(Attribute);
|
2002-07-15 15:37:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeData:
|
|
|
|
DbgPrint(" $DATA ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeIndexRoot:
|
|
|
|
DbgPrint(" $INDEX_ROOT ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeIndexAllocation:
|
|
|
|
DbgPrint(" $INDEX_ALLOCATION ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeBitmap:
|
|
|
|
DbgPrint(" $BITMAP ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeReparsePoint:
|
|
|
|
DbgPrint(" $REPARSE_POINT ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeEAInformation:
|
|
|
|
DbgPrint(" $EA_INFORMATION ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeEA:
|
|
|
|
DbgPrint(" $EA ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributePropertySet:
|
|
|
|
DbgPrint(" $PROPERTY_SET ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AttributeLoggedUtilityStream:
|
|
|
|
DbgPrint(" $LOGGED_UTILITY_STREAM ");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DbgPrint(" Attribute %lx ",
|
|
|
|
Attribute->AttributeType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Attribute->NameLength != 0)
|
|
|
|
{
|
|
|
|
Name.Length = Attribute->NameLength * sizeof(WCHAR);
|
|
|
|
Name.MaximumLength = Name.Length;
|
|
|
|
Name.Buffer = (PWCHAR)((ULONG)Attribute + Attribute->NameOffset);
|
|
|
|
|
|
|
|
DbgPrint("'%wZ' ", &Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
DbgPrint("(%s)\n",
|
2003-01-17 18:51:13 +00:00
|
|
|
Attribute->Nonresident ? "non-resident" : "resident");
|
2002-07-15 15:37:33 +00:00
|
|
|
|
|
|
|
if (Attribute->Nonresident != 0)
|
|
|
|
{
|
|
|
|
NresAttr = (PNONRESIDENT_ATTRIBUTE)Attribute;
|
|
|
|
Ptr = (PUCHAR)((ULONG)NresAttr + NresAttr->RunArrayOffset);
|
|
|
|
while (*Ptr != 0)
|
|
|
|
{
|
|
|
|
RunHeader = *Ptr++;
|
|
|
|
|
|
|
|
switch (RunHeader & 0x0F)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
RunLength = (ULONG)*Ptr++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
RunLength = *((PUSHORT)Ptr);
|
|
|
|
Ptr += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
RunLength = *Ptr++;
|
|
|
|
RunLength += *Ptr++ << 8;
|
|
|
|
RunLength += *Ptr++ << 16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
RunLength = *((PULONG)Ptr);
|
|
|
|
Ptr += 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DbgPrint("RunLength size of %hu not implemented!\n", RunHeader & 0x0F);
|
2003-07-21 21:53:53 +00:00
|
|
|
KEBUGCHECK(0);
|
2002-07-15 15:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (RunHeader >> 4)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
RunStart = (ULONG)*Ptr;
|
|
|
|
Ptr++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
RunStart = *((PUSHORT)Ptr);
|
|
|
|
Ptr += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
RunStart = *Ptr++;
|
|
|
|
RunStart += *Ptr++ << 8;
|
|
|
|
RunStart += *Ptr++ << 16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
RunStart = *((PULONG)Ptr);
|
|
|
|
Ptr += 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DbgPrint("RunStart size of %hu not implemented!\n", RunHeader >> 4);
|
2003-07-21 21:53:53 +00:00
|
|
|
KEBUGCHECK(0);
|
2002-07-15 15:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DbgPrint(" AllocatedSize %I64d DataSize %I64d\n", NresAttr->AllocatedSize, NresAttr->DataSize);
|
|
|
|
// DbgPrint(" Run: Header %hx Start %lu Length %lu\n", RunHeader, RunStart, RunLength);
|
|
|
|
if (RunLength == 1)
|
|
|
|
{
|
|
|
|
DbgPrint(" logical sector %lu (0x%lx)\n", RunStart, RunStart);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DbgPrint(" logical sectors %lu-%lu (0x%lx-0x%lx)\n",
|
|
|
|
RunStart, RunStart + RunLength - 1,
|
|
|
|
RunStart, RunStart + RunLength - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* EOF */
|