3 * Copyright (C) 2002, 2014 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/create.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMERS: Eric Kohl
24 * Pierre Schweitzer (pierre@reactos.org)
27 /* INCLUDES *****************************************************************/
34 static PCWSTR MftIdToName
[] = {
49 /* FUNCTIONS ****************************************************************/
53 NtfsMakeAbsoluteFilename(PFILE_OBJECT pFileObject
,
54 PWSTR pRelativeFileName
,
55 PWSTR
*pAbsoluteFilename
)
60 DPRINT("try related for %S\n", pRelativeFileName
);
61 Fcb
= pFileObject
->FsContext
;
64 if (Fcb
->Flags
& FCB_IS_VOLUME
)
66 /* This is likely to be an opening by ID, return ourselves */
67 if (pRelativeFileName
[0] == L
'\\')
69 *pAbsoluteFilename
= NULL
;
70 return STATUS_SUCCESS
;
73 return STATUS_INVALID_PARAMETER
;
76 /* verify related object is a directory and target name
77 don't start with \. */
78 if (NtfsFCBIsDirectory(Fcb
) == FALSE
||
79 pRelativeFileName
[0] == L
'\\')
81 return STATUS_INVALID_PARAMETER
;
84 /* construct absolute path name */
85 ASSERT(wcslen (Fcb
->PathName
) + 1 + wcslen (pRelativeFileName
) + 1 <= MAX_PATH
);
86 rcName
= ExAllocatePoolWithTag(NonPagedPool
, MAX_PATH
* sizeof(WCHAR
), TAG_NTFS
);
89 return STATUS_INSUFFICIENT_RESOURCES
;
92 wcscpy(rcName
, Fcb
->PathName
);
93 if (!NtfsFCBIsRoot(Fcb
))
94 wcscat (rcName
, L
"\\");
95 wcscat (rcName
, pRelativeFileName
);
96 *pAbsoluteFilename
= rcName
;
98 return STATUS_SUCCESS
;
104 NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt
,
106 PUNICODE_STRING OutPath
)
109 PFILE_RECORD_HEADER MftRecord
;
110 PFILENAME_ATTRIBUTE FileName
;
111 WCHAR FullPath
[MAX_PATH
];
112 ULONG WritePosition
= MAX_PATH
- 1;
114 DPRINT1("NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt
, Id
, OutPath
);
116 RtlZeroMemory(FullPath
, sizeof(FullPath
));
117 MftRecord
= ExAllocatePoolWithTag(NonPagedPool
,
118 DeviceExt
->NtfsInfo
.BytesPerFileRecord
,
120 if (MftRecord
== NULL
)
122 return STATUS_INSUFFICIENT_RESOURCES
;
127 Status
= ReadFileRecord(DeviceExt
, Id
, MftRecord
);
128 if (!NT_SUCCESS(Status
))
131 ASSERT(MftRecord
->Ntfs
.Type
== NRH_FILE_TYPE
);
132 if (!(MftRecord
->Flags
& FRH_IN_USE
))
134 Status
= STATUS_OBJECT_PATH_NOT_FOUND
;
138 FileName
= GetBestFileNameFromRecord(DeviceExt
, MftRecord
);
139 if (FileName
== NULL
)
141 DPRINT1("$FILE_NAME attribute not found for %I64x\n", Id
);
142 Status
= STATUS_OBJECT_PATH_NOT_FOUND
;
146 WritePosition
-= FileName
->NameLength
;
147 ASSERT(WritePosition
< MAX_PATH
);
148 RtlCopyMemory(FullPath
+ WritePosition
, FileName
->Name
, FileName
->NameLength
* sizeof(WCHAR
));
150 ASSERT(WritePosition
< MAX_PATH
);
151 FullPath
[WritePosition
] = L
'\\';
153 Id
= FileName
->DirectoryFileReferenceNumber
& NTFS_MFT_MASK
;
154 if (Id
== NTFS_FILE_ROOT
)
158 ExFreePoolWithTag(MftRecord
, TAG_NTFS
);
160 if (!NT_SUCCESS(Status
))
163 OutPath
->Length
= (MAX_PATH
- WritePosition
- 1) * sizeof(WCHAR
);
164 OutPath
->MaximumLength
= (MAX_PATH
- WritePosition
) * sizeof(WCHAR
);
165 OutPath
->Buffer
= ExAllocatePoolWithTag(NonPagedPool
, OutPath
->MaximumLength
, TAG_NTFS
);
166 if (OutPath
->Buffer
== NULL
)
168 return STATUS_INSUFFICIENT_RESOURCES
;
170 RtlCopyMemory(OutPath
->Buffer
, FullPath
+ WritePosition
, OutPath
->MaximumLength
);
177 NtfsOpenFileById(PDEVICE_EXTENSION DeviceExt
,
178 PFILE_OBJECT FileObject
,
180 PNTFS_FCB
* FoundFCB
)
184 PFILE_RECORD_HEADER MftRecord
;
186 DPRINT1("NtfsOpenFileById(%p, %p, %I64x, %p)\n", DeviceExt
, FileObject
, MftId
, FoundFCB
);
188 ASSERT(MftId
< 0x10);
189 if (MftId
> 0xb) /* No entries are used yet beyond this */
191 return STATUS_OBJECT_NAME_NOT_FOUND
;
194 MftRecord
= ExAllocatePoolWithTag(NonPagedPool
,
195 DeviceExt
->NtfsInfo
.BytesPerFileRecord
,
197 if (MftRecord
== NULL
)
199 return STATUS_INSUFFICIENT_RESOURCES
;
202 Status
= ReadFileRecord(DeviceExt
, MftId
, MftRecord
);
203 if (!NT_SUCCESS(Status
))
205 ExFreePoolWithTag(MftRecord
, TAG_NTFS
);
209 if (!(MftRecord
->Flags
& FRH_IN_USE
))
211 ExFreePoolWithTag(MftRecord
, TAG_NTFS
);
212 return STATUS_OBJECT_PATH_NOT_FOUND
;
215 FCB
= NtfsGrabFCBFromTable(DeviceExt
, MftIdToName
[MftId
]);
220 RtlInitUnicodeString(&Name
, MftIdToName
[MftId
]);
221 Status
= NtfsMakeFCBFromDirEntry(DeviceExt
, NULL
, &Name
, NULL
, MftRecord
, MftId
, &FCB
);
222 if (!NT_SUCCESS(Status
))
224 ExFreePoolWithTag(MftRecord
, TAG_NTFS
);
231 ExFreePoolWithTag(MftRecord
, TAG_NTFS
);
233 Status
= NtfsAttachFCBToFileObject(DeviceExt
,
242 * FUNCTION: Opens a file
246 NtfsOpenFile(PDEVICE_EXTENSION DeviceExt
,
247 PFILE_OBJECT FileObject
,
249 BOOLEAN CaseSensitive
,
250 PNTFS_FCB
* FoundFCB
)
255 PWSTR AbsFileName
= NULL
;
257 DPRINT1("NtfsOpenFile(%p, %p, %S, %s, %p)\n",
261 CaseSensitive
? "TRUE" : "FALSE",
266 if (FileObject
->RelatedFileObject
)
268 DPRINT("Converting relative filename to absolute filename\n");
270 Status
= NtfsMakeAbsoluteFilename(FileObject
->RelatedFileObject
,
273 if (AbsFileName
) FileName
= AbsFileName
;
274 if (!NT_SUCCESS(Status
))
280 //FIXME: Get canonical path name (remove .'s, ..'s and extra separators)
282 DPRINT("PathName to open: %S\n", FileName
);
284 /* try first to find an existing FCB in memory */
285 DPRINT("Checking for existing FCB in memory\n");
286 Fcb
= NtfsGrabFCBFromTable(DeviceExt
,
290 DPRINT("No existing FCB found, making a new one if file exists.\n");
291 Status
= NtfsGetFCBForFile(DeviceExt
,
296 if (ParentFcb
!= NULL
)
298 NtfsReleaseFCB(DeviceExt
,
302 if (!NT_SUCCESS (Status
))
304 DPRINT("Could not make a new FCB, status: %x\n", Status
);
307 ExFreePool(AbsFileName
);
313 DPRINT("Attaching FCB to fileObject\n");
314 Status
= NtfsAttachFCBToFileObject(DeviceExt
,
319 ExFreePool(AbsFileName
);
328 * FUNCTION: Opens a file
332 NtfsCreateFile(PDEVICE_OBJECT DeviceObject
,
333 PNTFS_IRP_CONTEXT IrpContext
)
335 PDEVICE_EXTENSION DeviceExt
;
336 PIO_STACK_LOCATION Stack
;
337 PFILE_OBJECT FileObject
;
338 ULONG RequestedDisposition
;
339 ULONG RequestedOptions
;
340 PNTFS_FCB Fcb
= NULL
;
343 UNICODE_STRING FullPath
;
344 PIRP Irp
= IrpContext
->Irp
;
346 DPRINT1("NtfsCreateFile(%p, %p) called\n", DeviceObject
, IrpContext
);
348 DeviceExt
= DeviceObject
->DeviceExtension
;
350 Stack
= IoGetCurrentIrpStackLocation (Irp
);
353 RequestedDisposition
= ((Stack
->Parameters
.Create
.Options
>> 24) & 0xff);
354 RequestedOptions
= Stack
->Parameters
.Create
.Options
& FILE_VALID_OPTION_FLAGS
;
355 // PagingFileCreate = (Stack->Flags & SL_OPEN_PAGING_FILE) ? TRUE : FALSE;
356 if (RequestedOptions
& FILE_DIRECTORY_FILE
&&
357 RequestedDisposition
== FILE_SUPERSEDE
)
359 return STATUS_INVALID_PARAMETER
;
362 /* Deny create if the volume is locked */
363 if (DeviceExt
->Flags
& VCB_VOLUME_LOCKED
)
365 return STATUS_ACCESS_DENIED
;
368 FileObject
= Stack
->FileObject
;
370 if ((RequestedOptions
& FILE_OPEN_BY_FILE_ID
) == FILE_OPEN_BY_FILE_ID
)
374 if (FileObject
->FileName
.Length
!= sizeof(ULONGLONG
))
375 return STATUS_INVALID_PARAMETER
;
377 MFTId
= (*(PULONGLONG
)FileObject
->FileName
.Buffer
) & NTFS_MFT_MASK
;
380 Status
= NtfsOpenFileById(DeviceExt
, FileObject
, MFTId
, &Fcb
);
384 Status
= NtfsMoonWalkID(DeviceExt
, MFTId
, &FullPath
);
387 if (!NT_SUCCESS(Status
))
392 DPRINT1("Open by ID: %I64x -> %wZ\n", (*(PULONGLONG
)FileObject
->FileName
.Buffer
) & NTFS_MFT_MASK
, &FullPath
);
395 /* This a open operation for the volume itself */
396 if (FileObject
->FileName
.Length
== 0 &&
397 (FileObject
->RelatedFileObject
== NULL
|| FileObject
->RelatedFileObject
->FsContext2
!= NULL
))
399 if (RequestedDisposition
!= FILE_OPEN
&&
400 RequestedDisposition
!= FILE_OPEN_IF
)
402 return STATUS_ACCESS_DENIED
;
405 if (RequestedOptions
& FILE_DIRECTORY_FILE
)
407 return STATUS_NOT_A_DIRECTORY
;
410 NtfsAttachFCBToFileObject(DeviceExt
, DeviceExt
->VolumeFcb
, FileObject
);
411 DeviceExt
->VolumeFcb
->RefCount
++;
413 Irp
->IoStatus
.Information
= FILE_OPENED
;
414 return STATUS_SUCCESS
;
419 Status
= NtfsOpenFile(DeviceExt
,
421 ((RequestedOptions
& FILE_OPEN_BY_FILE_ID
) ? FullPath
.Buffer
: FileObject
->FileName
.Buffer
),
422 BooleanFlagOn(Stack
->Flags
, SL_CASE_SENSITIVE
),
425 if (RequestedOptions
& FILE_OPEN_BY_FILE_ID
)
427 ExFreePoolWithTag(FullPath
.Buffer
, TAG_NTFS
);
431 if (NT_SUCCESS(Status
))
433 if (RequestedDisposition
== FILE_CREATE
)
435 Irp
->IoStatus
.Information
= FILE_EXISTS
;
436 NtfsCloseFile(DeviceExt
, FileObject
);
437 return STATUS_OBJECT_NAME_COLLISION
;
440 if (RequestedOptions
& FILE_NON_DIRECTORY_FILE
&&
441 NtfsFCBIsDirectory(Fcb
))
443 NtfsCloseFile(DeviceExt
, FileObject
);
444 return STATUS_FILE_IS_A_DIRECTORY
;
447 if (RequestedOptions
& FILE_DIRECTORY_FILE
&&
448 !NtfsFCBIsDirectory(Fcb
))
450 NtfsCloseFile(DeviceExt
, FileObject
);
451 return STATUS_NOT_A_DIRECTORY
;
455 * If it is a reparse point & FILE_OPEN_REPARSE_POINT, then allow opening it
457 * Otherwise, attempt to read reparse data and hand them to the Io manager
458 * with status reparse to force a reparse.
460 if (NtfsFCBIsReparsePoint(Fcb
) &&
461 ((RequestedOptions
& FILE_OPEN_REPARSE_POINT
) != FILE_OPEN_REPARSE_POINT
))
463 PREPARSE_DATA_BUFFER ReparseData
= NULL
;
465 Status
= NtfsReadFCBAttribute(DeviceExt
, Fcb
,
466 AttributeReparsePoint
, L
"", 0,
467 (PVOID
*)&Irp
->Tail
.Overlay
.AuxiliaryBuffer
);
468 if (NT_SUCCESS(Status
))
470 ReparseData
= (PREPARSE_DATA_BUFFER
)Irp
->Tail
.Overlay
.AuxiliaryBuffer
;
471 if (ReparseData
->ReparseTag
== IO_REPARSE_TAG_MOUNT_POINT
)
473 Status
= STATUS_REPARSE
;
477 Status
= STATUS_NOT_IMPLEMENTED
;
478 ExFreePoolWithTag(ReparseData
, TAG_NTFS
);
482 Irp
->IoStatus
.Information
= ((Status
== STATUS_REPARSE
) ? ReparseData
->ReparseTag
: 0);
484 NtfsCloseFile(DeviceExt
, FileObject
);
488 if (RequestedDisposition
== FILE_OVERWRITE
||
489 RequestedDisposition
== FILE_OVERWRITE_IF
||
490 RequestedDisposition
== FILE_SUPERSEDE
)
492 PFILE_RECORD_HEADER fileRecord
= NULL
;
493 PNTFS_ATTR_CONTEXT dataContext
= NULL
;
494 ULONG DataAttributeOffset
;
498 if (!NtfsGlobalData
->EnableWriteSupport
)
500 DPRINT1("NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
501 NtfsCloseFile(DeviceExt
, FileObject
);
502 return STATUS_ACCESS_DENIED
;
505 // TODO: check for appropriate access
507 ExAcquireResourceExclusiveLite(&(Fcb
->MainResource
), TRUE
);
509 fileRecord
= ExAllocatePoolWithTag(NonPagedPool
,
510 Fcb
->Vcb
->NtfsInfo
.BytesPerFileRecord
,
515 Status
= ReadFileRecord(Fcb
->Vcb
,
518 if (!NT_SUCCESS(Status
))
519 goto DoneOverwriting
;
521 // find the data attribute and set it's length to 0 (TODO: Handle Alternate Data Streams)
522 Status
= FindAttribute(Fcb
->Vcb
, fileRecord
, AttributeData
, L
"", 0, &dataContext
, &DataAttributeOffset
);
523 if (!NT_SUCCESS(Status
))
524 goto DoneOverwriting
;
526 Status
= SetAttributeDataLength(FileObject
, Fcb
, dataContext
, DataAttributeOffset
, fileRecord
, &Zero
);
530 Status
= STATUS_NO_MEMORY
;
535 ExFreePoolWithTag(fileRecord
, TAG_NTFS
);
537 ReleaseAttributeContext(dataContext
);
539 ExReleaseResourceLite(&(Fcb
->MainResource
));
541 if (!NT_SUCCESS(Status
))
543 NtfsCloseFile(DeviceExt
, FileObject
);
547 if (RequestedDisposition
== FILE_SUPERSEDE
)
549 Irp
->IoStatus
.Information
= FILE_SUPERSEDED
;
553 Irp
->IoStatus
.Information
= FILE_OVERWRITTEN
;
559 /* HUGLY HACK: Can't create new files yet... */
560 if (RequestedDisposition
== FILE_CREATE
||
561 RequestedDisposition
== FILE_OPEN_IF
||
562 RequestedDisposition
== FILE_OVERWRITE_IF
||
563 RequestedDisposition
== FILE_SUPERSEDE
)
565 if (!NtfsGlobalData
->EnableWriteSupport
)
567 DPRINT1("NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
568 NtfsCloseFile(DeviceExt
, FileObject
);
569 return STATUS_ACCESS_DENIED
;
572 // Create the file record on disk
573 Status
= NtfsCreateFileRecord(DeviceExt
,
575 (Stack
->Flags
& SL_CASE_SENSITIVE
),
576 BooleanFlagOn(IrpContext
->Flags
,IRPCONTEXT_CANWAIT
));
577 if (!NT_SUCCESS(Status
))
579 DPRINT1("ERROR: Couldn't create file record!\n");
583 // Now we should be able to open the file
584 return NtfsCreateFile(DeviceObject
, IrpContext
);
588 if (NT_SUCCESS(Status
))
590 Fcb
->OpenHandleCount
++;
591 DeviceExt
->OpenHandleCount
++;
595 * If the directory containing the file to open doesn't exist then
598 Irp
->IoStatus
.Information
= (NT_SUCCESS(Status
)) ? FILE_OPENED
: 0;
605 NtfsCreate(PNTFS_IRP_CONTEXT IrpContext
)
607 PDEVICE_EXTENSION DeviceExt
;
609 PDEVICE_OBJECT DeviceObject
;
611 DeviceObject
= IrpContext
->DeviceObject
;
612 if (DeviceObject
== NtfsGlobalData
->DeviceObject
)
614 /* DeviceObject represents FileSystem instead of logical volume */
615 DPRINT("Opening file system\n");
616 IrpContext
->Irp
->IoStatus
.Information
= FILE_OPENED
;
617 return STATUS_SUCCESS
;
620 DeviceExt
= DeviceObject
->DeviceExtension
;
622 if (!(IrpContext
->Flags
& IRPCONTEXT_CANWAIT
))
624 return NtfsMarkIrpContextForQueue(IrpContext
);
627 ExAcquireResourceExclusiveLite(&DeviceExt
->DirResource
,
629 Status
= NtfsCreateFile(DeviceObject
,
631 ExReleaseResourceLite(&DeviceExt
->DirResource
);
637 * @name NtfsCreateFileRecord()
640 * Creates a file record and saves it to the MFT. Adds the filename attribute of the
641 * created file to the parent directory's index.
644 * Points to the target disk's DEVICE_EXTENSION
647 * Pointer to a FILE_OBJECT describing the file to be created
650 * Boolean indicating if the function is allowed to wait for exclusive access to the master file table.
651 * This will only be relevant if the MFT doesn't have any free file records and needs to be enlarged.
654 * STATUS_SUCCESS on success.
655 * STATUS_INSUFFICIENT_RESOURCES if unable to allocate memory for the file record.
656 * STATUS_CANT_WAIT if CanWait was FALSE and the function needed to resize the MFT but
657 * couldn't get immediate, exclusive access to it.
660 NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt
,
661 PFILE_OBJECT FileObject
,
662 BOOLEAN CaseSensitive
,
665 NTSTATUS Status
= STATUS_SUCCESS
;
666 PFILE_RECORD_HEADER FileRecord
;
667 PNTFS_ATTR_RECORD NextAttribute
;
668 PFILENAME_ATTRIBUTE FilenameAttribute
;
669 ULONGLONG ParentMftIndex
;
670 ULONGLONG FileMftIndex
;
672 DPRINT1("NtfsCreateFileRecord(%p, %p, %s, %s)\n",
675 CaseSensitive
? "TRUE" : "FALSE",
676 CanWait
? "TRUE" : "FALSE");
678 // allocate memory for file record
679 FileRecord
= ExAllocatePoolWithTag(NonPagedPool
,
680 DeviceExt
->NtfsInfo
.BytesPerFileRecord
,
684 DPRINT1("ERROR: Unable to allocate memory for file record!\n");
685 return STATUS_INSUFFICIENT_RESOURCES
;
688 RtlZeroMemory(FileRecord
, DeviceExt
->NtfsInfo
.BytesPerFileRecord
);
690 FileRecord
->Ntfs
.Type
= NRH_FILE_TYPE
;
692 // calculate USA offset and count
693 FileRecord
->Ntfs
.UsaOffset
= FIELD_OFFSET(FILE_RECORD_HEADER
, MFTRecordNumber
) + sizeof(ULONG
);
695 // size of USA (in ULONG's) will be 1 (for USA number) + 1 for every sector the file record uses
696 FileRecord
->BytesAllocated
= DeviceExt
->NtfsInfo
.BytesPerFileRecord
;
697 FileRecord
->Ntfs
.UsaCount
= (FileRecord
->BytesAllocated
/ DeviceExt
->NtfsInfo
.BytesPerSector
) + 1;
699 // setup other file record fields
700 FileRecord
->SequenceNumber
= 1;
701 FileRecord
->AttributeOffset
= FileRecord
->Ntfs
.UsaOffset
+ (2 * FileRecord
->Ntfs
.UsaCount
);
702 FileRecord
->AttributeOffset
= ALIGN_UP_BY(FileRecord
->AttributeOffset
, 8);
703 FileRecord
->Flags
= FRH_IN_USE
;
704 FileRecord
->BytesInUse
= FileRecord
->AttributeOffset
+ sizeof(ULONG
) * 2;
706 // find where the first attribute will be added
707 NextAttribute
= (PNTFS_ATTR_RECORD
)((ULONG_PTR
)FileRecord
+ FileRecord
->AttributeOffset
);
709 // mark the (temporary) end of the file-record
710 NextAttribute
->Type
= AttributeEnd
;
711 NextAttribute
->Length
= FILE_RECORD_END
;
713 // add first attribute, $STANDARD_INFORMATION
714 AddStandardInformation(FileRecord
, NextAttribute
);
716 // advance NextAttribute pointer to the next attribute
717 NextAttribute
= (PNTFS_ATTR_RECORD
)((ULONG_PTR
)NextAttribute
+ (ULONG_PTR
)NextAttribute
->Length
);
719 // Add the $FILE_NAME attribute
720 AddFileName(FileRecord
, NextAttribute
, DeviceExt
, FileObject
, CaseSensitive
, &ParentMftIndex
);
722 // save a pointer to the filename attribute
723 FilenameAttribute
= (PFILENAME_ATTRIBUTE
)((ULONG_PTR
)NextAttribute
+ NextAttribute
->Resident
.ValueOffset
);
725 // advance NextAttribute pointer to the next attribute
726 NextAttribute
= (PNTFS_ATTR_RECORD
)((ULONG_PTR
)NextAttribute
+ (ULONG_PTR
)NextAttribute
->Length
);
728 // add the $DATA attribute
729 AddData(FileRecord
, NextAttribute
);
731 // dump file record in memory (for debugging)
732 NtfsDumpFileRecord(DeviceExt
, FileRecord
);
734 // Now that we've built the file record in memory, we need to store it in the MFT.
735 Status
= AddNewMftEntry(FileRecord
, DeviceExt
, &FileMftIndex
, CanWait
);
736 if (NT_SUCCESS(Status
))
738 // The highest 2 bytes should be the sequence number, unless the parent happens to be root
739 if (FileMftIndex
== NTFS_FILE_ROOT
)
740 FileMftIndex
= FileMftIndex
+ ((ULONGLONG
)NTFS_FILE_ROOT
<< 48);
742 FileMftIndex
= FileMftIndex
+ ((ULONGLONG
)FileRecord
->SequenceNumber
<< 48);
744 DPRINT1("New File Reference: 0x%016I64x\n", FileMftIndex
);
746 // Add the filename attribute to the filename-index of the parent directory
747 Status
= NtfsAddFilenameToDirectory(DeviceExt
,
754 ExFreePoolWithTag(FileRecord
, TAG_NTFS
);