Changeset 8f6bb76e in mainline for uspace/srv/fs/minixfs/mfs_rw.c


Ignore:
Timestamp:
2011-04-10T10:03:31Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
230229de
Parents:
ce45f19
Message:
  • Fix bug when allocating memory space for the indirect zone vector
  • relative block number calculation was not correct
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs_rw.c

    rce45f19 r8f6bb76e  
    6969        int rblock = pos / block_size;
    7070
    71         if (mnode->ino_i->i_size < (int32_t) pos) {
     71        if (mnode->ino_i->i_size < pos) {
    7272                /*Trying to read beyond the end of file*/
    7373                r = EOK;
     
    147147                return EOK;
    148148        }
    149         rblock -= nr_direct - 1;
     149
     150        rblock -= nr_direct;
    150151
    151152        if (rblock < ptrs_per_block) {
     
    160161                                ino_i->i_izone[0] = zone;
    161162                                ino_i->dirty = true;
    162                         } else
     163                        } else {
    163164                                return -1;
     165                        }
    164166                }
    165167
     
    177179        }
    178180
    179         rblock -= ptrs_per_block - 1;
     181        rblock -= ptrs_per_block;
    180182
    181183        /*The wanted block is in the double indirect zone chain*/
     
    277279        unsigned i;
    278280        block_t *b;
    279 
    280         *ind_zone = malloc(sbi->block_size);
     281        const int max_ind_zone_ptrs = (MFS_MAX_BLOCKSIZE / sizeof(uint16_t)) *
     282                                sizeof(uint32_t);
     283
     284        *ind_zone = malloc(max_ind_zone_ptrs);
    281285        if (*ind_zone == NULL)
    282286                return ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.