+NTSTATUS
+SetAttributeDataLength(PFILE_OBJECT FileObject,
+ PNTFS_FCB Fcb,
+ PNTFS_ATTR_CONTEXT AttrContext,
+ ULONG AttrOffset,
+ PFILE_RECORD_HEADER FileRecord,
+ PDEVICE_EXTENSION DeviceExt,
+ PLARGE_INTEGER DataSize)
+{
+ if (AttrContext->Record.IsNonResident)
+ {
+ // do we need to increase the allocation size?
+ if (AttrContext->Record.NonResident.AllocatedSize < DataSize->QuadPart)
+ {
+ DPRINT1("FixMe: Increasing allocation size is unimplemented!\n");
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+ // TODO: is the file compressed, encrypted, or sparse?
+
+ // NOTE: we need to have acquired the main resource exclusively, as well as(?) the PagingIoResource
+
+ // TODO: update the allocated size on-disk
+ DPRINT("Allocated Size: %I64u\n", AttrContext->Record.NonResident.AllocatedSize);
+
+ AttrContext->Record.NonResident.DataSize = DataSize->QuadPart;
+ AttrContext->Record.NonResident.InitializedSize = DataSize->QuadPart;
+
+ Fcb->RFCB.FileSize = *DataSize;
+ Fcb->RFCB.ValidDataLength = *DataSize;
+
+ DPRINT("Data Size: %I64u\n", Fcb->RFCB.FileSize.QuadPart);
+
+ //NtfsDumpFileAttributes(Fcb->Vcb, FileRecord);
+
+ // copy the attribute back into the FileRecord
+ RtlCopyMemory((PCHAR)FileRecord + AttrOffset, &AttrContext->Record, AttrContext->Record.Length);
+
+ //NtfsDumpFileAttributes(Fcb->Vcb, FileRecord);
+
+ // write the updated file record back to disk
+ UpdateFileRecord(Fcb->Vcb, Fcb->MFTIndex, FileRecord);
+
+ CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->RFCB.AllocationSize);
+ }
+ else
+ {
+ // we can't yet handle resident attributes
+ DPRINT1("FixMe: Can't handle increasing length of resident attribute\n");
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+ return STATUS_SUCCESS;
+}
+