Changeset e5f8762 in mainline


Ignore:
Timestamp:
2011-11-27T12:16:40Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d4d2954
Parents:
5f6cb14
Message:

Fixed bugs in directory removal process

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_directory.c

    r5f6cb14 re5f8762  
    317317        }
    318318
    319         if (rc != EOK) {
    320                 ext4_directory_iterator_fini(&it);
    321                 return rc;
    322         }
    323 
    324319        // TODO modify HTREE index if exists
    325320
  • uspace/lib/ext4/libext4_filesystem.c

    r5f6cb14 re5f8762  
    387387        }
    388388
     389        inode_ref->dirty = true;
     390
    389391        // Free inode
    390392        rc = ext4_ialloc_free_inode(fs, inode_ref);
     
    441443        for (i = 1; i <= blocks_count; ++i) {
    442444                // TODO check retval
    443                 // TODO decrement inode->blocks_count
    444 
    445445                ext4_filesystem_release_inode_block(fs, inode_ref, total_blocks - i);
    446446        }
  • uspace/lib/ext4/libext4_ialloc.c

    r5f6cb14 re5f8762  
    3737
    3838#include <errno.h>
     39#include <time.h>
    3940#include "libext4.h"
    4041
     
    9091        }
    9192
     93        time_t now = time(NULL);
     94        ext4_inode_set_deletion_time(inode_ref->inode, (uint32_t)now);
     95        inode_ref->dirty = true;
     96
     97        // if inode is directory, decrement directories count
     98        if (ext4_inode_is_type(fs->superblock, inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) {
     99                uint32_t bg_used_dirs = ext4_block_group_get_used_dirs_count(
     100                        bg_ref->block_group, fs->superblock);
     101                bg_used_dirs--;
     102                ext4_block_group_set_used_dirs_count(
     103                                bg_ref->block_group, fs->superblock, bg_used_dirs);
     104        }
     105
    92106        // Update superblock free inodes count
    93107        uint32_t sb_free_inodes = ext4_superblock_get_free_inodes_count(fs->superblock);
    94         sb_free_inodes--;
     108        sb_free_inodes++;
    95109        ext4_superblock_set_free_inodes_count(fs->superblock, sb_free_inodes);
    96110
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r5f6cb14 re5f8762  
    469469        // If directory - handle links from parent
    470470        if (lnk_count <= 1 && ext4fs_is_directory(cfn)) {
    471 
    472                 if (lnk_count) {
    473                         lnk_count--;
    474                 }
    475 
    476471                ext4_inode_ref_t *parent_inode_ref = EXT4FS_NODE(pfn)->inode_ref;
    477472
     
    567562unsigned ext4fs_lnkcnt_get(fs_node_t *fn)
    568563{
     564        if (ext4fs_is_directory(fn)) {
     565                if (lnkcnt > 1) {
     566                        EXT4FS_DBG("dir: returning \%u", 1);
     567                        return 1;
     568                } else {
     569                        EXT4FS_DBG("dir: returning \%u", 0);
     570                        return 0;
     571                }
     572        }
     573
     574        // For regular files return real links count
    569575        ext4fs_node_t *enode = EXT4FS_NODE(fn);
    570576        return ext4_inode_get_links_count(enode->inode_ref->inode);
     
    685691                return rc;
    686692        }
    687         ext4fs_node_t *enode = EXT4FS_NODE(root_node);
    688693
    689694        /* Add instance to the list */
     
    694699        *index = EXT4_INODE_ROOT_INDEX;
    695700        *size = 0;
    696         *lnkcnt = ext4_inode_get_links_count(enode->inode_ref->inode);
     701        *lnkcnt = 1;
    697702
    698703        ext4fs_node_put(root_node);
Note: See TracChangeset for help on using the changeset viewer.