ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 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

PtrExt2FileLockInfo NTAPI Ext2AllocateByteLocks ( void  )

Definition at line 929 of file misc.c.

{
    PtrExt2FileLockInfo     PtrByteLocks = NULL;
    BOOLEAN                     AllocatedFromZone = TRUE;
   KIRQL                            CurrentIrql;

    // first, try to allocate out of the zone
    KeAcquireSpinLock(&(Ext2GlobalData.ZoneAllocationSpinLock), &CurrentIrql);
    if (!ExIsFullZone(&(Ext2GlobalData.ByteLockZoneHeader))) 
    {
        // we have enough memory
        PtrByteLocks = (PtrExt2FileLockInfo)ExAllocateFromZone(&(Ext2GlobalData.ByteLockZoneHeader));

        // release the spinlock
        KeReleaseSpinLock(&(Ext2GlobalData.ZoneAllocationSpinLock), CurrentIrql);
    } 
    else 
    {
        // release the spinlock
        KeReleaseSpinLock(&(Ext2GlobalData.ZoneAllocationSpinLock), CurrentIrql);

        // if we failed to obtain from the zone, get it directly from the VMM
        PtrByteLocks = (PtrExt2FileLockInfo)Ext2AllocatePool(NonPagedPool, Ext2QuadAlign(sizeof(Ext2FileLockInfo)) );
        AllocatedFromZone = FALSE;
    }

    // if we could not obtain the required memory, bug-check.
    //  Do NOT do this in your commercial driver, instead handle the error gracefully ...
    if (!PtrByteLocks) 
    {
        Ext2Panic(STATUS_INSUFFICIENT_RESOURCES, Ext2QuadAlign(sizeof(Ext2FileLockInfo)), 0);
    }

    // zero out the allocated memory block
    RtlZeroMemory(PtrByteLocks, Ext2QuadAlign(sizeof(PtrExt2FileLockInfo)));

    if (!AllocatedFromZone) 
    {
        Ext2SetFlag(PtrByteLocks->FileLockFlags, EXT2_BYTE_LOCK_NOT_FROM_ZONE);
    }

    return(PtrByteLocks);
}

Generated on Sat May 26 2012 04:39:45 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.