Changeset 368ee04 in mainline for uspace/srv/vfs/vfs_node.c


Ignore:
Timestamp:
2017-04-05T18:10:39Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
93ad8166
Parents:
39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/vfs-2.5-cherrypick

This merge cherry-picks some of the changesets from Jiri Zarevucky's:

lp:~zarevucky-jiri/helenos/vfs-2.5

and then continues independently, yet sometime in a similar vein.

Roughly speaking, Jiri's branch is merged entirely up to its revision
1926 and then cherry-picked on and off until its revision 1965. Among
these changes are:

  • relativization of the API,
  • client-side roots,
  • server-side mounts,
  • inbox for passing arbitrary files from parent to child,
  • some streamlining and cleanup.

Additional changes include:

  • addressing issues introduced by the above changes,
  • client-side I/O cursors (file positions),
  • all HelenOS file system APIs begin with the vfs_ prefix and can be used after including vfs/vfs.h,
  • removal of some POSIX-ish headers and definitions,
  • additional cleanup.
File:
1 edited

Legend:

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

    r39f892a9 r368ee04  
    4545#include <async.h>
    4646#include <errno.h>
     47#include <macros.h>
    4748
    4849/** Mutex protecting the VFS node hash table. */
     
    106107void vfs_node_delref(vfs_node_t *node)
    107108{
    108         bool free_vfs_node = false;
    109         bool free_fs_node = false;
    110        
    111         fibril_mutex_lock(&nodes_mutex);
    112        
    113         if (node->refcnt-- == 1) {
    114                
     109        bool free_node = false;
     110       
     111        fibril_mutex_lock(&nodes_mutex);
     112       
     113        node->refcnt--;
     114        if (node->refcnt == 0) {
    115115                /*
    116116                 * We are dropping the last reference to this node.
     
    119119               
    120120                hash_table_remove_item(&nodes, &node->nh_link);
    121                 free_vfs_node = true;
    122                
    123                 if (!node->lnkcnt)
    124                         free_fs_node = true;
     121                free_node = true;
    125122        }
    126123       
    127124        fibril_mutex_unlock(&nodes_mutex);
    128125       
    129         if (free_fs_node) {
    130                
     126        if (free_node) {
    131127                /*
    132                  * The node is not visible in the file system namespace.
    133                  * Free up its resources.
     128                 * VFS_OUT_DESTROY will free up the file's resources if there
     129                 * are no more hard links.
    134130                 */
    135131               
    136132                async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    137                 sysarg_t rc = async_req_2_0(exch, VFS_OUT_DESTROY,
    138                     (sysarg_t) node->service_id, (sysarg_t)node->index);
    139                
    140                 assert(rc == EOK);
     133                async_msg_2(exch, VFS_OUT_DESTROY, (sysarg_t) node->service_id,
     134                    (sysarg_t)node->index);
    141135                vfs_exchange_release(exch);
     136
     137                free(node);
    142138        }
    143        
    144         if (free_vfs_node)
    145                 free(node);
    146139}
    147140
     
    190183                node->index = result->triplet.index;
    191184                node->size = result->size;
    192                 node->lnkcnt = result->lnkcnt;
    193185                node->type = result->type;
    194186                fibril_rwlock_initialize(&node->contents_rwlock);
     
    196188        } else {
    197189                node = hash_table_get_inst(tmp, vfs_node_t, nh_link);
    198                 if (node->type == VFS_NODE_UNKNOWN &&
    199                     result->type != VFS_NODE_UNKNOWN) {
    200                         /* Upgrade the node type. */
    201                         node->type = result->type;
    202                 }
    203190        }
    204191
    205         assert(node->size == result->size || node->type != VFS_NODE_FILE);
    206         assert(node->lnkcnt == result->lnkcnt);
    207         assert(node->type == result->type || result->type == VFS_NODE_UNKNOWN);
    208 
    209192        _vfs_node_addref(node);
     193        fibril_mutex_unlock(&nodes_mutex);
     194
     195        return node;
     196}
     197
     198vfs_node_t *vfs_node_peek(vfs_lookup_res_t *result)
     199{
     200        vfs_node_t *node = NULL;
     201
     202        fibril_mutex_lock(&nodes_mutex);
     203        ht_link_t *tmp = hash_table_find(&nodes, &result->triplet);
     204        if (tmp) {
     205                node = hash_table_get_inst(tmp, vfs_node_t, nh_link);
     206                _vfs_node_addref(node);
     207        }
    210208        fibril_mutex_unlock(&nodes_mutex);
    211209
     
    302300        vfs_triplet_t *tri = key;
    303301        vfs_node_t *node = hash_table_get_inst(item, vfs_node_t, nh_link);
    304         return node->fs_handle == tri->fs_handle
    305                 && node->service_id == tri->service_id
    306                 && node->index == tri->index;
     302        return node->fs_handle == tri->fs_handle &&
     303            node->service_id == tri->service_id && node->index == tri->index;
    307304}
    308305
     
    318315}
    319316
     317bool vfs_node_has_children(vfs_node_t *node)
     318{
     319        async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
     320        int rc = async_req_2_0(exch, VFS_OUT_IS_EMPTY, node->service_id,
     321            node->index);
     322        vfs_exchange_release(exch);
     323        return rc == ENOTEMPTY;
     324}
     325
    320326/**
    321327 * @}
Note: See TracChangeset for help on using the changeset viewer.