Changeset f17667a in mainline for uspace/srv/vfs/vfs_node.c


Ignore:
Timestamp:
2008-02-17T13:32:53Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2616965d
Parents:
b5553a2
Message:

Add the VFS_FREE operation. This operation frees up whatever resources used by
a file system node for which there is no name (i.e. an unlinked node).

Cleanup VFS operations enums and remove unneeded VFS operations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_node.c

    rb5553a2 rf17667a  
    4444#include <libadt/hash_table.h>
    4545#include <assert.h>
     46#include <async.h>
     47#include <errno.h>
    4648
    4749/** Futex protecting the VFS node hash table. */
     
    102104void vfs_node_delref(vfs_node_t *node)
    103105{
     106        bool free_vfs_node = false;
     107        bool free_fs_node = false;
     108
    104109        futex_down(&nodes_futex);
    105110        if (node->refcnt-- == 1) {
     111                /*
     112                 * We are dropping the last reference to this node.
     113                 * Remove it from the VFS node hash table.
     114                 */
    106115                unsigned long key[] = {
    107116                        [KEY_FS_HANDLE] = node->fs_handle,
     
    110119                };
    111120                hash_table_remove(&nodes, key, 3);
     121                free_vfs_node = true;
     122                if (!node->lnkcnt)
     123                        free_fs_node = true;
    112124        }
    113125        futex_up(&nodes_futex);
     126
     127        if (free_fs_node) {
     128                /*
     129                 * The node is not visible in the file system namespace.
     130                 * Free up its resources.
     131                 */
     132                int phone = vfs_grab_phone(node->fs_handle);
     133                ipcarg_t rc;
     134                rc = async_req_2_0(phone, VFS_FREE, (ipcarg_t)node->dev_handle,
     135                    (ipcarg_t)node->index);
     136                assert(rc == EOK);
     137                vfs_release_phone(phone);
     138        }
     139        if (free_vfs_node)
     140                free(node);
    114141}
    115142
     
    197224void nodes_remove_callback(link_t *item)
    198225{
    199         vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
    200         free(node);
    201226}
    202227
Note: See TracChangeset for help on using the changeset viewer.