Changeset b7c62a9 in mainline
- Timestamp:
- 2013-07-29T11:44:35Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 677745a
- Parents:
- 9e9b168
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/fs/libfs.c
r9e9b168 rb7c62a9 203 203 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 204 204 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 205 205 206 int rc; 206 207 rc = vfs_out_ops->destroy(service_id, index); 208 207 fs_node_t *node = NULL; 208 rc = libfs_ops->node_get(&node, service_id, index); 209 if (rc == EOK && node != NULL) { 210 bool destroy = (libfs_ops->lnkcnt_get(node) == 0); 211 libfs_ops->node_put(node); 212 if (destroy) { 213 rc = vfs_out_ops->destroy(service_id, index); 214 } 215 } 209 216 async_answer_0(rid, rc); 210 217 } … … 769 776 async_answer_5(rid, fs_handle, service_id, 770 777 ops->index_get(cur), LOWER32(size), UPPER32(size), 771 ops-> lnkcnt_get(cur));778 ops->is_directory(cur) ? VFS_NODE_DIRECTORY : VFS_NODE_FILE); 772 779 LOG_EXIT(EOK); 773 780 } else { … … 831 838 async_answer_5(rid, fs_handle, service_id, 832 839 ops->index_get(cur), LOWER32(size), UPPER32(size), 833 ops-> lnkcnt_get(cur));840 ops->is_directory(cur) ? VFS_NODE_DIRECTORY : VFS_NODE_FILE); 834 841 835 842 LOG_EXIT(EOK); -
uspace/srv/vfs/vfs.h
r9e9b168 rb7c62a9 94 94 vfs_node_type_t type; 95 95 aoff64_t size; 96 unsigned int lnkcnt;97 96 } vfs_lookup_res_t; 98 97 … … 110 109 unsigned refcnt; 111 110 112 /** Number of names this node has in the file system namespace. */113 unsigned lnkcnt;114 115 111 ht_link_t nh_link; /**< Node hash-table link. */ 116 112 -
uspace/srv/vfs/vfs_lookup.c
r9e9b168 rb7c62a9 280 280 result->size = 281 281 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(answer), IPC_GET_ARG4(answer)); 282 result->lnkcnt = (unsigned int) IPC_GET_ARG5(answer); 283 284 if (lflag & L_FILE) 285 result->type = VFS_NODE_FILE; 286 else if (lflag & L_DIRECTORY) 287 result->type = VFS_NODE_DIRECTORY; 288 else 289 result->type = VFS_NODE_UNKNOWN; 290 282 result->type = IPC_GET_ARG5(answer); 291 283 rc = EOK; 292 284 -
uspace/srv/vfs/vfs_node.c
r9e9b168 rb7c62a9 106 106 void vfs_node_delref(vfs_node_t *node) 107 107 { 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) {108 bool free_node = false; 109 110 fibril_mutex_lock(&nodes_mutex); 111 112 node->refcnt--; 113 if (node->refcnt == 0) { 114 114 115 115 /* … … 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 * DESTROY will free up the file's resources if there are no more hard links. 134 129 */ 135 130 136 131 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); 132 async_msg_2(exch, VFS_OUT_DESTROY, 133 (sysarg_t) node->service_id, (sysarg_t)node->index); 141 134 vfs_exchange_release(exch); 135 136 free(node); 142 137 } 143 144 if (free_vfs_node)145 free(node);146 138 } 147 139 … … 190 182 node->index = result->triplet.index; 191 183 node->size = result->size; 192 node->lnkcnt = result->lnkcnt;193 184 node->type = result->type; 194 185 fibril_rwlock_initialize(&node->contents_rwlock); … … 196 187 } else { 197 188 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 189 } 204 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 190 209 191 _vfs_node_addref(node); -
uspace/srv/vfs/vfs_ops.c
r9e9b168 rb7c62a9 79 79 fs_index_t rindex; 80 80 aoff64_t rsize; 81 unsigned rlnkcnt;82 81 async_exch_t *exch; 83 82 sysarg_t rc; … … 130 129 rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), 131 130 IPC_GET_ARG3(answer)); 132 rlnkcnt = (unsigned) IPC_GET_ARG4(answer);133 131 134 132 mr_res.triplet.fs_handle = fs_handle; … … 136 134 mr_res.triplet.index = rindex; 137 135 mr_res.size = rsize; 138 mr_res.lnkcnt = rlnkcnt;139 136 mr_res.type = VFS_NODE_DIRECTORY; 140 137 … … 237 234 rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), 238 235 IPC_GET_ARG3(answer)); 239 rlnkcnt = (unsigned) IPC_GET_ARG4(answer);240 236 241 237 mr_res.triplet.fs_handle = fs_handle; … … 243 239 mr_res.triplet.index = rindex; 244 240 mr_res.size = rsize; 245 mr_res.lnkcnt = rlnkcnt;246 241 mr_res.type = VFS_NODE_DIRECTORY; 247 242 … … 668 663 file->open_write = false; 669 664 670 vfs_node_addref(node);671 vfs_node_put(node);672 665 vfs_file_put(file); 673 666 if (parent) { … … 858 851 size_t bytes = IPC_GET_ARG1(answer); 859 852 860 if (file->node->type == VFS_NODE_DIRECTORY) 853 if (file->node->type == VFS_NODE_DIRECTORY) { 861 854 fibril_rwlock_read_unlock(&namespace_rwlock); 855 } 862 856 863 857 /* Unlock the VFS node. */ … … 1120 1114 * VFS_OUT_DESTROY'ed after the last reference to it is dropped. 1121 1115 */ 1122 vfs_node_t *node = vfs_node_get(&lr); 1123 vfs_node_delref(node); 1124 vfs_node_put(node); 1116 vfs_node_put(vfs_node_get(&lr)); 1125 1117 1126 1118 exit: … … 1225 1217 1226 1218 if (orig_unlinked) { 1227 vfs_node_t *node = vfs_node_get(&new_lr_orig); 1228 vfs_node_delref(node); 1229 vfs_node_put(node); 1219 vfs_node_put(vfs_node_get(&new_lr_orig)); 1230 1220 } 1231 1221
Note:
See TracChangeset
for help on using the changeset viewer.