Changeset 802

Show
Ignore:
Timestamp:
07/14/08 20:34:56 (2 months ago)
Author:
mwhitworth
Message:

Add comments.

Files:
1 modified

Legend:

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

    r780 r802  
     1/*  This file is part of Whitix. 
     2 * 
     3 *  Whitix is free software; you can redistribute it and/or modify 
     4 *  it under the terms of the GNU General Public License as published by 
     5 *  the Free Software Foundation; either version 2 of the License, or 
     6 *  (at your option) any later version. 
     7 * 
     8 *  Whitix is distributed in the hope that it will be useful, 
     9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11 *  GNU General Public License for more details. 
     12 * 
     13 *  You should have received a copy of the GNU General Public License 
     14 *  along with Whitix; if not, write to the Free Software 
     15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
     16 * 
     17 */ 
     18 
    119#include <bitmap.h> 
    220 
    321#include "ext3.h" 
     22 
     23/******************************************************************************* 
     24 * 
     25 * FUNCTION:    Ext3GetGroupDesc 
     26 * 
     27 * DESCRIPTION: Get the on-disk group descriptor with index 'groupNo'. 
     28 * 
     29 * PARAMETERS:  superBlock      - superblock of the filesystem that contains the 
     30 *                                                        descriptors. 
     31 *                              groupNo         - index of the group. 
     32 *                              buffer          - return the buffer containing the group on-disk, 
     33 *                                                        in case the calling function wants to update the 
     34 *                                                        buffer and call JournalDirtyMetadata. (OPTIONAL) 
     35 * 
     36 * RETURNS:     A pointer to the group descriptor in the buffer. 
     37 * 
     38 ******************************************************************************/ 
    439 
    540struct Ext3GroupDesc* Ext3GetGroupDesc(struct VfsSuperBlock* superBlock, DWORD groupNo, 
     
    843        struct Ext3GroupDesc* descP; 
    944        DWORD groupDesc, desc; 
    10          
     45        struct Ext3SbInfo* sbInfo=EXT3_SUPERINFO(superBlock); 
     46         
     47        /*  
     48         * The group descriptors are located after the superblock on disk, and are 
     49         * read in when the superblock is mounted. 
     50         */ 
     51          
     52        if (groupNo >= sbInfo->groupCount) 
     53                return NULL; 
     54         
     55        /* Sector index of the group */ 
    1156        groupDesc=groupNo/DESCS_PER_BLOCK(superBlock); 
     57         
     58        /* Offset within the group */ 
    1259        desc = groupNo % DESCS_PER_BLOCK(superBlock); 
    1360         
    14         descP=(struct Ext3GroupDesc*)EXT3_SUPERINFO(superBlock)->descs[groupDesc]->data; 
     61        descP=(struct Ext3GroupDesc*)(EXT3_SUPERINFO(superBlock)->descs[groupDesc]->data); 
    1562         
    1663        if (buffer) 
     
    1966        return descP+desc; 
    2067} 
     68 
     69/******************************************************************************* 
     70 * 
     71 * FUNCTION:    Ext3BlockLoadBitmap 
     72 * 
     73 * DESCRIPTION: Load the block bitmap pointed to by the group descriptor at index 
     74 *                              blockGroup. 
     75 * 
     76 * PARAMETERS:  superBlock      - superblock of the filesystem that contains the 
     77 *                                                        descriptor. 
     78 *                              groupNo         - index of the group. 
     79 * 
     80 * RETURNS:     A buffer pointer to the block bitmap. 
     81 * 
     82 ******************************************************************************/ 
    2183 
    2284struct Buffer* Ext3BlockLoadBitmap(struct VfsSuperBlock* superBlock, int blockGroup) 
     
    222284        offset=blockNo % sbInfo->blocksPerGrp; 
    223285         
    224         KePrint("group = %u\n", group); 
     286        if (group >= sbInfo->groupCount) 
     287        { 
     288                KePrint("Ext3BlockFree: blockNo = %d, %u %u", blockNo, group, sbInfo->groupCount); 
     289                return -EIO; 
     290        } 
    225291         
    226292        desc=Ext3GetGroupDesc(superBlock, group, &groupBuffer);