Changeset 368ee04 in mainline for uspace/srv/vfs/vfs_node.c
- Timestamp:
- 2017-04-05T18:10:39Z (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_node.c
r39f892a9 r368ee04 45 45 #include <async.h> 46 46 #include <errno.h> 47 #include <macros.h> 47 48 48 49 /** Mutex protecting the VFS node hash table. */ … … 106 107 void vfs_node_delref(vfs_node_t *node) 107 108 { 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) { 115 115 /* 116 116 * We are dropping the last reference to this node. … … 119 119 120 120 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; 125 122 } 126 123 127 124 fibril_mutex_unlock(&nodes_mutex); 128 125 129 if (free_fs_node) { 130 126 if (free_node) { 131 127 /* 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. 134 130 */ 135 131 136 132 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); 141 135 vfs_exchange_release(exch); 136 137 free(node); 142 138 } 143 144 if (free_vfs_node)145 free(node);146 139 } 147 140 … … 190 183 node->index = result->triplet.index; 191 184 node->size = result->size; 192 node->lnkcnt = result->lnkcnt;193 185 node->type = result->type; 194 186 fibril_rwlock_initialize(&node->contents_rwlock); … … 196 188 } else { 197 189 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 }203 190 } 204 191 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 209 192 _vfs_node_addref(node); 193 fibril_mutex_unlock(&nodes_mutex); 194 195 return node; 196 } 197 198 vfs_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 } 210 208 fibril_mutex_unlock(&nodes_mutex); 211 209 … … 302 300 vfs_triplet_t *tri = key; 303 301 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; 307 304 } 308 305 … … 318 315 } 319 316 317 bool 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 320 326 /** 321 327 * @}
Note:
See TracChangeset
for help on using the changeset viewer.