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

Changeset 319f4fb in mainline


Ignore:
Timestamp:
2010-01-24T16:05:59Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
c4aca2c
Parents:
203a090
Message:

Add vfs_nodes_refcount_sum_get().

Location:
uspace/srv/vfs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    r203a090 r319f4fb  
    181181extern vfs_node_t *vfs_node_get(vfs_lookup_res_t *);
    182182extern void vfs_node_put(vfs_node_t *);
     183extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, dev_handle_t);
     184
    183185
    184186#define MAX_OPEN_FILES  128
  • uspace/srv/vfs/vfs_node.c

    r203a090 r319f4fb  
    231231}
    232232
     233struct refcnt_data {
     234        /** Sum of all reference counts for this file system instance. */
     235        unsigned refcnt;
     236        fs_handle_t fs_handle;
     237        dev_handle_t dev_handle;
     238};
     239
     240static void refcnt_visitor(link_t *item, void *arg)
     241{
     242        vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
     243        struct refcnt_data *rd = (void *) arg;
     244
     245        if ((node->fs_handle == rd->fs_handle) &&
     246            (node->dev_handle == rd->dev_handle))
     247                rd->refcnt += node->refcnt;
     248}
     249
     250unsigned
     251vfs_nodes_refcount_sum_get(fs_handle_t fs_handle, dev_handle_t dev_handle)
     252{
     253        struct refcnt_data rd = {
     254                .refcnt = 0,
     255                .fs_handle = fs_handle,
     256                .dev_handle = dev_handle
     257        };
     258
     259        fibril_mutex_lock(&nodes_mutex);
     260        hash_table_apply(&nodes, refcnt_visitor, &rd);
     261        fibril_mutex_unlock(&nodes_mutex);
     262
     263        return rd.refcnt;
     264}
     265
    233266/**
    234267 * @}
Note: See TracChangeset for help on using the changeset viewer.