Show
Ignore:
Timestamp:
09/23/08 14:18:34 (4 months ago)
Author:
mwhitworth
Message:

Add NameToVNode parameter, a dir parameter for relative lookups.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/fs/vfs/bcache.c

    r778 r881  
    5858 * 
    5959 * DESCRIPTION: Lock a buffer for unique access. Waits for the buffer to 
    60  *              be unlocked, and then locks it again. 
     60 *                              be unlocked, and then locks it again. 
    6161 * 
    6262 * PARAMETERS:  buffer - buffer in question. 
    6363 * 
    64  * RETURNS:     Nothing. 
     64 * RETURNS:             Nothing. 
    6565 * 
    6666 ***********************************************************************/ 
     
    7272} 
    7373 
     74SYMBOL_EXPORT(BufferLock); 
     75 
    7476/*********************************************************************** 
    7577 * 
     
    9092} 
    9193 
     94SYMBOL_EXPORT(BufferUnlock); 
     95 
    9296static void BufferWait(struct Buffer* buffer) 
    9397{ 
    9498        BufferGet(buffer); 
    9599        INIT_WAITQUEUE_ENTRY(bufferWait); 
    96  
     100         
    97101        do 
    98102        { 
     
    123127} 
    124128 
     129SYMBOL_EXPORT(WaitForBuffer); 
     130 
    125131/*********************************************************************** 
    126132 * 
     
    144150                return NULL; 
    145151 
     152        ZeroMemory(buff, sizeof(struct Buffer)); 
     153 
    146154        buff->device=device; 
    147155        buff->blockNum=blockNum; 
    148156        buff->refs=1; 
    149         buff->data=(BYTE*)malloc(device->softBlockSize); 
     157        buff->data=(BYTE*)MemAlloc(device->softBlockSize); 
    150158        if (!buff->data) 
     159        { 
     160                MemCacheFree(blockCache, buff); 
    151161                return NULL; 
     162        } 
    152163 
    153164        INIT_WAITQUEUE_HEAD(&buff->waitQueue); 
    154         BufferLock(buff); 
     165         
     166        BufferLock(buff); /* Buffer is unlocked in StorageEndRequest. */ 
    155167        BlockAddToHashTable(buff); 
    156168 
     
    158170} 
    159171 
     172SYMBOL_EXPORT(BlockBufferAlloc); 
     173 
    160174/*********************************************************************** 
    161175 * 
     
    173187{ 
    174188        WaitForBuffer(buff); 
    175         free(buff->data); 
     189        MemFree(buff->data); 
    176190        ListRemove(&buff->list); 
    177         MemCacheFree(blockCache,buff); 
     191        MemCacheFree(blockCache, buff); 
    178192} 
    179193 
     
    211225 ***********************************************************************/ 
    212226 
    213 int BlockSendRequestRaw(struct StorageDevice* device,struct Request* request) 
     227int BlockSendRequestRaw(struct StorageDevice* device, struct Request* request) 
    214228{ 
    215229        int err; 
     
    307321} 
    308322 
     323/* TODO: device is redundant here. */ 
     324 
    309325int BlockWrite(struct StorageDevice* device,struct Buffer* buffer) 
    310326{ 
     
    378394                /* Write all the blocks belonging to device to disk */ 
    379395                ListForEachEntry(buff, head, list) 
     396                { 
    380397                        if (BufferDirty(buff)) 
    381398                        { 
     399                                WaitForBuffer(buff); 
     400                                 
    382401                                /* For each block, call the respective StorageDevice write function */ 
    383402                                DoBlockWrite(buff->device,buff); 
    384403                                buff->flags &= ~(1 << BUFFER_DIRTY); 
    385404                        } 
     405                } 
    386406        } 
    387407 
     
    431451static void BufferFlusher() 
    432452{ 
    433         struct StorageDevice* sDevice; 
     453//      struct StorageDevice* sDevice; 
    434454        ThrSetPriority(currThread,1); 
    435455 
     
    439459                ThrSchedule(); 
    440460 
    441                 ListForEachEntry(sDevice,&sDeviceList,list) 
    442                         BlockSyncDevice(sDevice); 
     461                /* FIXME: TEMP */ 
     462//              ListForEachEntry(sDevice,&sDeviceList,list) 
     463//                      BlockSyncDevice(sDevice); 
    443464        } 
    444465} 
     
    461482        DWORD i; 
    462483 
    463         dev->hashLists=(struct ListHead*)malloc(1 << HASH_TABLE_ORDER); 
     484        dev->hashLists=(struct ListHead*)MemAlloc(1 << HASH_TABLE_ORDER); 
    464485 
    465486        for (i=0; i<HASH_NUM_ENTRIES; i++) 
     
    480501                { 
    481502                        BufferGet(curr); 
    482                         PreemptEnable(); /* As WaitForBuffer may sleep. */ 
     503                        PreemptEnable(); 
    483504                        WaitForBuffer(curr); 
    484505                        return curr;