Changeset 12b4a7f in mainline for uspace/srv/fs/ext4fs/ext4fs_ops.c


Ignore:
Timestamp:
2011-11-07T16:23:30Z (14 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
43a9968
Parents:
052e82d
Message:

functional truncate operation (only to lower size actually), except extent files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r052e82d r12b4a7f  
    954954        fs = enode->instance->filesystem;
    955955
     956
     957        if (! ext4_inode_can_truncate(inode_ref->inode)) {
     958                // Unable to truncate
     959                return EINVAL;
     960        }
     961
    956962        old_size = ext4_inode_get_size(fs->superblock, inode_ref->inode);
    957 
    958         printf("old size = \%llu, new size = \%llu\n", old_size, new_size);
    959963
    960964        if (old_size == new_size) {
     
    962966        } else {
    963967
    964                 //int rc;
    965968                uint32_t block_size;
    966969                uint32_t blocks_count, total_blocks;
     
    970973
    971974                if (old_size < new_size) {
    972                         // TODO don't return immediately
    973                         EXT4FS_DBG("expand the file");
     975                        // Currently not supported to expand the file
     976                        // TODO
     977                        EXT4FS_DBG("trying to expand the file");
    974978                        return EINVAL;
    975979                }
    976 
    977                 EXT4FS_DBG("cut the end of the file !");
    978980
    979981                size_diff = old_size - new_size;
     
    990992                inode_ref->dirty = true;
    991993
    992                 for (i = 0; i< blocks_count; ++i) {
     994                // starting from 1 because of logical blocks are numbered from 0
     995                for (i = 1; i <= blocks_count; ++i) {
    993996                        // TODO check retval
     997                        // TODO decrement inode->blocks_count
     998
    994999                        ext4_filesystem_release_inode_block(fs, inode_ref, total_blocks - i);
    9951000                }
Note: See TracChangeset for help on using the changeset viewer.