Changeset 757

Show
Ignore:
Timestamp:
07/08/08 18:17:04 (3 months ago)
Author:
mwhitworth
Message:

Add to DirtyVNode code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/fs/fs/ext3/inode.c

    r752 r757  
    66#include "ext3.h" 
    77 
     8int Ext3INodeGetLoc(struct VNode* vNode, struct Buffer** buffer, struct Ext3INode** iNode) 
     9{ 
     10        DWORD vNo=vNode->id-1; 
     11        struct Ext3SbInfo* sbInfo=EXT3_SUPERINFO(vNode->superBlock); 
     12        DWORD blockGroup,groupDesc,desc, block; 
     13        struct Ext3GroupDesc* groupDescs; 
     14 
     15        if (vNo > sbInfo->iNodesCount) 
     16                return -EINVAL; 
     17 
     18        blockGroup=vNo/sbInfo->iNodesPerGrp; 
     19 
     20        if (blockGroup >= sbInfo->groupCount) 
     21                return -EINVAL; 
     22 
     23        /* Get the group descriptor for the inode */ 
     24        groupDesc=blockGroup/DESCS_PER_BLOCK(vNode->superBlock); 
     25        desc=blockGroup & (DESCS_PER_BLOCK(vNode->superBlock)-1); 
     26 
     27        groupDescs=(struct Ext3GroupDesc*)(sbInfo->descs[groupDesc]->data); 
     28 
     29        if (!groupDescs) 
     30                return -EFAULT; 
     31 
     32        block=groupDescs[desc].iNodeTable+((vNo % sbInfo->iNodesPerGrp)/INODES_PER_BLOCK(vNode->superBlock)); 
     33 
     34        *buffer=BlockRead(vNode->superBlock->sDevice,block); 
     35 
     36        if (!*buffer) 
     37                return -EIO; 
     38 
     39        *iNode=((struct Ext3INode*)(*buffer)->data+(vNo % INODES_PER_BLOCK(vNode->superBlock))); 
     40 
     41        return 0; 
     42} 
     43 
    844int Ext3ReadVNode(struct VNode* vNode) 
    945{ 
    10         struct Ext3SbInfo* sbInfo=(struct Ext3SbInfo*)vNode->superBlock->privData; 
    11         int blockGroup,groupDesc,desc,block,i; 
    12         struct Ext3GroupDesc* groupDescs; 
    1346        struct Buffer* buffer; 
    1447        struct Ext3INode* iNode; 
    1548        struct Ext3INodeInfo* iNodeInfo; 
    16         DWORD vNo=vNode->id-1; 
    17  
    18         if (vNo > sbInfo->iNodesCount) 
    19                 return -EINVAL; 
    20  
    21         blockGroup=vNo/sbInfo->iNodesPerGrp; 
    22  
    23         if (blockGroup >= sbInfo->groupCount) 
    24                 return -EINVAL; 
    25  
    26         /* Get the group descriptor for the inode */ 
    27         groupDesc=blockGroup/DESCS_PER_BLOCK(vNode->superBlock); 
    28         desc=blockGroup & (DESCS_PER_BLOCK(vNode->superBlock)-1); 
    29  
    30         groupDescs=(struct Ext3GroupDesc*)(sbInfo->descs[groupDesc]->data); 
    31  
    32         if (!groupDescs) 
    33                 return -EFAULT; 
    34  
    35         block=groupDescs[desc].iNodeTable+((vNo % sbInfo->iNodesPerGrp)/INODES_PER_BLOCK(vNode->superBlock)); 
    36  
    37         buffer=BlockRead(vNode->superBlock->sDevice,block); 
    38  
    39         if (!buffer) 
    40                 return -EIO; 
    41  
    42         iNode=((struct Ext3INode*)buffer->data+(vNo % INODES_PER_BLOCK(vNode->superBlock))); 
     49        int i, err; 
     50 
     51        err=Ext3INodeGetLoc(vNode, &buffer, &iNode); 
     52 
     53        if (err) 
     54                return err; 
    4355 
    4456        iNodeInfo=(struct Ext3INodeInfo*)malloc(sizeof(struct Ext3INodeInfo)); 
     
    8193} 
    8294 
     95int Ext3INodeReserveWrite(struct JournalHandle* handle, struct VNode* vNode, 
     96        struct Buffer** buffer, struct Ext3INode** iNode) 
     97{ 
     98        int err; 
     99 
     100        /* Fill in buffer and iNode first, before signalling to the journal that we're 
     101         * going to write at that disk location. */ 
     102 
     103        err=Ext3INodeGetLoc(vNode, buffer, iNode); 
     104 
     105        if (!err) 
     106                err=JournalGetWriteAccess(handle, *buffer); 
     107 
     108        return err; 
     109} 
     110 
    83111int Ext3DirtyVNode(struct VNode* vNode) 
    84112{ 
    85113        struct JournalHandle* handle; 
     114        struct Buffer* buffer; 
     115        struct Ext3INode* iNode; 
    86116 
    87117        handle=JournalStart(EXT3_JOURNAL(vNode), 2); 
     118 
     119        if (handle) 
     120        { 
     121                Ext3INodeReserveWrite(handle, vNode, &buffer, &iNode); 
     122        } 
    88123 
    89124        return 0;