ReactOS Fundraising Campaign 2012
 
€ 4,060 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

static NTSTATUS Fat32WriteRootDirectory ( IN HANDLE  FileHandle,
IN PFAT32_BOOT_SECTOR  BootSector,
IN OUT PFORMAT_CONTEXT  Context 
) [static]

Definition at line 286 of file fat32.c.

Referenced by Fat32Format().

{
    IO_STATUS_BLOCK IoStatusBlock;
    NTSTATUS Status;
    PUCHAR Buffer;
    LARGE_INTEGER FileOffset;
    ULONGLONG FirstDataSector;
    ULONGLONG FirstRootDirSector;

    /* Allocate buffer for the cluster */
    Buffer = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
                                     0,
                                     BootSector->SectorsPerCluster * BootSector->BytesPerSector);
    if (Buffer == NULL)
        return STATUS_INSUFFICIENT_RESOURCES;

    /* Zero the buffer */
    memset(Buffer, 0, BootSector->SectorsPerCluster * BootSector->BytesPerSector);

    DPRINT("BootSector->ReservedSectors = %lu\n", BootSector->ReservedSectors);
    DPRINT("BootSector->FATSectors32 = %lu\n", BootSector->FATSectors32);
    DPRINT("BootSector->RootCluster = %lu\n", BootSector->RootCluster);
    DPRINT("BootSector->SectorsPerCluster = %lu\n", BootSector->SectorsPerCluster);

    /* Write cluster */
    FirstDataSector = BootSector->ReservedSectors +
        (BootSector->FATCount * BootSector->FATSectors32) + 0 /* RootDirSectors */;

    DPRINT("FirstDataSector = %lu\n", FirstDataSector);

    FirstRootDirSector = ((BootSector->RootCluster - 2) * BootSector->SectorsPerCluster) + FirstDataSector;
    FileOffset.QuadPart = FirstRootDirSector * BootSector->BytesPerSector;

    DPRINT("FirstRootDirSector = %lu\n", FirstRootDirSector);
    DPRINT("FileOffset = %lu\n", FileOffset.QuadPart);

    Status = NtWriteFile(FileHandle,
                         NULL,
                         NULL,
                         NULL,
                         &IoStatusBlock,
                         Buffer,
                         BootSector->SectorsPerCluster * BootSector->BytesPerSector,
                         &FileOffset,
                         NULL);
    if (!NT_SUCCESS(Status))
    {
        DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
        RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
        return Status;
    }

    UpdateProgress(Context, (ULONG)BootSector->SectorsPerCluster);

    /* Free the buffer */
    RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);

    return Status;
}

Generated on Tue May 22 2012 06:07:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.