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


Ignore:
Timestamp:
2011-11-21T11:46:37Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f49638e
Parents:
343ccfd
Message:

Unlink operation skeleton

File:
1 edited

Legend:

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

    r343ccfd rebeaaa06  
    444444
    445445
    446 int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
    447 {
    448         EXT4FS_DBG("not supported");
    449 
     446int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)
     447{
     448
     449        return ENOTSUP;
     450
     451        int rc;
     452
     453        bool has_children;
     454        rc = ext4fs_has_children(&has_children, cfn);
     455        if (rc != EOK) {
     456                return rc;
     457        }
     458
     459        // Cannot unlink non-empty node
     460        if (has_children) {
     461                return ENOTEMPTY;
     462        }
     463
     464        // Remove entry from parent directory
    450465        // TODO
    451         return ENOTSUP;
     466//      rc = ext4_directory_remove_entry(EXT4FS_NODE(pfn), name);
     467//      if (rc != EOK) {
     468//              return rc;
     469//      }
     470
     471        // Decrement links count
     472        ext4_inode_ref_t * child_inode_ref = EXT4FS_NODE(cfn)->inode_ref;
     473
     474        uint32_t lnk_count = ext4_inode_get_links_count(child_inode_ref->inode);
     475        lnk_count--;
     476        ext4_inode_set_links_count(child_inode_ref->inode, lnk_count);
     477
     478        child_inode_ref->dirty = true;
     479
     480        // If directory - handle links from parent
     481        if (lnk_count <= 1 && ext4fs_is_directory(cfn)) {
     482
     483                ext4_inode_ref_t *parent_inode_ref = EXT4FS_NODE(pfn)->inode_ref;
     484                uint32_t parent_lnk_count = ext4_inode_get_links_count(
     485                                parent_inode_ref->inode);
     486                parent_lnk_count--;
     487                ext4_inode_set_links_count(parent_inode_ref->inode, parent_lnk_count);
     488
     489                parent_inode_ref->dirty = true;
     490        }
     491
     492
     493        return EOK;
    452494}
    453495
Note: See TracChangeset for help on using the changeset viewer.