Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 9a0be34 in mainline


Ignore:
Timestamp:
2011-09-06T19:47:51Z (10 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master
Children:
7a46bfe
Parents:
5e0427e8
Message:

mfs minor fixes:

  • remove old asserts
  • do not allow to write beyond the maximum file size
  • fix a little bug when deleting sparse files
File:
1 edited

Legend:

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

    r5e0427e8 r9a0be34  
    8383        const struct mfs_sb_info *sbi = mnode->instance->sbi;
    8484
     85        if (pos >= sbi->max_file_size) {
     86                /*Can't write beyond the maximum file size*/
     87                return EINVAL;
     88        }
     89
    8590        /*Compute the relative block number in file*/
    8691        int rblock = pos / sbi->block_size;
     
    97102        uint32_t *ind_zone, *ind2_zone;
    98103
    99         assert(mnode);
    100104        struct mfs_ino_info *ino_i = mnode->ino_i;
    101 
    102         assert(ino_i);
    103         assert(mnode->instance);
    104 
    105105        struct mfs_instance *inst = mnode->instance;
    106106        struct mfs_sb_info *sbi = inst->sbi;
    107         assert(sbi);
    108107
    109108        const mfs_version_t fs_version = sbi->fs_version;
     109        const bool deleting = write_mode && (w_block == 0);
    110110
    111111        if (fs_version == MFS_VERSION_V1) {
     
    132132                /*The wanted block is in the single indirect zone chain*/
    133133                if (ino_i->i_izone[0] == 0) {
    134                         if (write_mode) {
     134                        if (write_mode && !deleting) {
    135135                                uint32_t zone;
    136136                                r = alloc_zone_and_clear(inst, &zone);
     
    166166        /*read the first indirect zone of the chain*/
    167167        if (ino_i->i_izone[1] == 0) {
    168                 if (write_mode) {
     168                if (write_mode && !deleting) {
    169169                        uint32_t zone;
    170170                        r = alloc_zone_and_clear(inst, &zone);
     
    193193        /*read the second indirect zone of the chain*/
    194194        if (ind_zone[ind2_off] == 0) {
    195                 if (write_mode) {
     195                if (write_mode && !deleting) {
    196196                        uint32_t zone;
    197197                        r = alloc_zone_and_clear(inst, &zone);
Note: See TracChangeset for help on using the changeset viewer.