Changeset eb522e8 in mainline for uspace/srv/vfs/vfs_register.c
- Timestamp:
- 2011-06-01T08:43:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6c1f1
- Parents:
- 9e2e715 (diff), e51a514 (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_register.c
r9e2e715 reb522e8 36 36 */ 37 37 38 #include <ipc/ipc.h>39 38 #include <ipc/services.h> 40 39 #include <async.h> 41 #include <async_rel.h>42 40 #include <fibril.h> 43 41 #include <fibril_synch.h> … … 111 109 void vfs_register(ipc_callid_t rid, ipc_call_t *request) 112 110 { 111 int phone; 112 113 113 dprintf("Processing VFS_REGISTER request received from %p.\n", 114 114 request->in_phone_hash); … … 121 121 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", 122 122 rc); 123 ipc_answer_0(rid, rc);123 async_answer_0(rid, rc); 124 124 return; 125 125 } … … 131 131 if (!fs_info) { 132 132 dprintf("Could not allocate memory for FS info.\n"); 133 ipc_answer_0(rid, ENOMEM);133 async_answer_0(rid, ENOMEM); 134 134 return; 135 135 } 136 136 137 137 link_initialize(&fs_info->fs_link); 138 fibril_mutex_initialize(&fs_info->phone_lock);139 138 fs_info->vfs_info = *vfs_info; 140 139 free(vfs_info); … … 144 143 if (!vfs_info_sane(&fs_info->vfs_info)) { 145 144 free(fs_info); 146 ipc_answer_0(rid, EINVAL);145 async_answer_0(rid, EINVAL); 147 146 return; 148 147 } … … 160 159 fibril_mutex_unlock(&fs_head_lock); 161 160 free(fs_info); 162 ipc_answer_0(rid, EEXISTS);161 async_answer_0(rid, EEXISTS); 163 162 return; 164 163 } … … 177 176 ipc_call_t call; 178 177 ipc_callid_t callid = async_get_call(&call); 179 if (IPC_GET_ METHOD(call) != IPC_M_CONNECT_TO_ME) {180 dprintf("Unexpected call, method = %d\n", IPC_GET_ METHOD(call));178 if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) { 179 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 181 180 list_remove(&fs_info->fs_link); 182 181 fibril_mutex_unlock(&fs_head_lock); 183 182 free(fs_info); 184 ipc_answer_0(callid, EINVAL); 185 ipc_answer_0(rid, EINVAL); 186 return; 187 } 188 fs_info->phone = IPC_GET_ARG5(call); 189 ipc_answer_0(callid, EOK); 183 async_answer_0(callid, EINVAL); 184 async_answer_0(rid, EINVAL); 185 return; 186 } 187 188 phone = IPC_GET_ARG5(call); 189 async_session_create(&fs_info->session, phone, 0); 190 async_answer_0(callid, EOK); 190 191 191 192 dprintf("Callback connection to FS created.\n"); … … 197 198 size_t size; 198 199 if (!async_share_in_receive(&callid, &size)) { 199 dprintf("Unexpected call, method = %d\n", IPC_GET_ METHOD(call));200 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 200 201 list_remove(&fs_info->fs_link); 201 202 fibril_mutex_unlock(&fs_head_lock); 202 ipc_hangup(fs_info->phone); 203 free(fs_info); 204 ipc_answer_0(callid, EINVAL); 205 ipc_answer_0(rid, EINVAL); 203 async_session_destroy(&fs_info->session); 204 async_hangup(phone); 205 free(fs_info); 206 async_answer_0(callid, EINVAL); 207 async_answer_0(rid, EINVAL); 206 208 return; 207 209 } … … 214 216 list_remove(&fs_info->fs_link); 215 217 fibril_mutex_unlock(&fs_head_lock); 216 ipc_hangup(fs_info->phone); 217 free(fs_info); 218 ipc_answer_0(callid, EINVAL); 219 ipc_answer_0(rid, EINVAL); 218 async_session_destroy(&fs_info->session); 219 async_hangup(phone); 220 free(fs_info); 221 async_answer_0(callid, EINVAL); 222 async_answer_0(rid, EINVAL); 220 223 return; 221 224 } … … 235 238 */ 236 239 fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next); 237 ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);240 async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle); 238 241 239 242 fibril_condvar_broadcast(&fs_head_cv); … … 269 272 if (fs->fs_handle == handle) { 270 273 fibril_mutex_unlock(&fs_head_lock); 271 fibril_mutex_lock(&fs->phone_lock); 272 phone = async_relation_create(fs->phone); 273 fibril_mutex_unlock(&fs->phone_lock); 274 phone = async_exchange_begin(&fs->session); 274 275 275 276 assert(phone > 0); … … 295 296 if (fs->fs_handle == handle) { 296 297 fibril_mutex_unlock(&fs_head_lock); 297 fibril_mutex_lock(&fs->phone_lock); 298 async_relation_destroy(fs->phone, phone); 299 fibril_mutex_unlock(&fs->phone_lock); 298 async_exchange_end(&fs->session, phone); 300 299 return; 301 300 } … … 333 332 } 334 333 334 /** Find the VFS info structure. 335 * 336 * @param handle FS handle for which the VFS info structure is sought. 337 * @return VFS info structure on success or NULL otherwise. 338 */ 339 vfs_info_t *fs_handle_to_info(fs_handle_t handle) 340 { 341 vfs_info_t *info = NULL; 342 link_t *cur; 343 344 fibril_mutex_lock(&fs_head_lock); 345 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 346 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 347 if (fs->fs_handle == handle) { 348 info = &fs->vfs_info; 349 break; 350 } 351 } 352 fibril_mutex_unlock(&fs_head_lock); 353 354 return info; 355 } 356 335 357 /** 336 358 * @}
Note:
See TracChangeset
for help on using the changeset viewer.