Changes in uspace/srv/vfs/vfs_register.c [ffa2c8ef:df908b3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_register.c
rffa2c8ef rdf908b3 36 36 */ 37 37 38 #include <ipc/ipc.h> 38 39 #include <ipc/services.h> 39 40 #include <async.h> 41 #include <async_rel.h> 40 42 #include <fibril.h> 41 43 #include <fibril_synch.h> … … 109 111 void vfs_register(ipc_callid_t rid, ipc_call_t *request) 110 112 { 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 async_answer_0(rid, rc);123 ipc_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 async_answer_0(rid, ENOMEM);133 ipc_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); 138 139 fs_info->vfs_info = *vfs_info; 139 140 free(vfs_info); … … 143 144 if (!vfs_info_sane(&fs_info->vfs_info)) { 144 145 free(fs_info); 145 async_answer_0(rid, EINVAL);146 ipc_answer_0(rid, EINVAL); 146 147 return; 147 148 } … … 159 160 fibril_mutex_unlock(&fs_head_lock); 160 161 free(fs_info); 161 async_answer_0(rid, EEXISTS);162 ipc_answer_0(rid, EEXISTS); 162 163 return; 163 164 } … … 176 177 ipc_call_t call; 177 178 ipc_callid_t callid = async_get_call(&call); 178 if (IPC_GET_ IMETHOD(call) != IPC_M_CONNECT_TO_ME) {179 dprintf("Unexpected call, method = %d\n", IPC_GET_ IMETHOD(call));179 if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) { 180 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); 180 181 list_remove(&fs_info->fs_link); 181 182 fibril_mutex_unlock(&fs_head_lock); 182 183 free(fs_info); 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); 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); 191 190 192 191 dprintf("Callback connection to FS created.\n"); … … 198 197 size_t size; 199 198 if (!async_share_in_receive(&callid, &size)) { 200 dprintf("Unexpected call, method = %d\n", IPC_GET_ IMETHOD(call));199 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); 201 200 list_remove(&fs_info->fs_link); 202 201 fibril_mutex_unlock(&fs_head_lock); 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); 202 ipc_hangup(fs_info->phone); 203 free(fs_info); 204 ipc_answer_0(callid, EINVAL); 205 ipc_answer_0(rid, EINVAL); 208 206 return; 209 207 } … … 216 214 list_remove(&fs_info->fs_link); 217 215 fibril_mutex_unlock(&fs_head_lock); 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); 216 ipc_hangup(fs_info->phone); 217 free(fs_info); 218 ipc_answer_0(callid, EINVAL); 219 ipc_answer_0(rid, EINVAL); 223 220 return; 224 221 } … … 238 235 */ 239 236 fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next); 240 async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);237 ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle); 241 238 242 239 fibril_condvar_broadcast(&fs_head_cv); … … 272 269 if (fs->fs_handle == handle) { 273 270 fibril_mutex_unlock(&fs_head_lock); 274 phone = async_exchange_begin(&fs->session); 271 fibril_mutex_lock(&fs->phone_lock); 272 phone = async_relation_create(fs->phone); 273 fibril_mutex_unlock(&fs->phone_lock); 275 274 276 275 assert(phone > 0); … … 296 295 if (fs->fs_handle == handle) { 297 296 fibril_mutex_unlock(&fs_head_lock); 298 async_exchange_end(&fs->session, phone); 297 fibril_mutex_lock(&fs->phone_lock); 298 async_relation_destroy(fs->phone, phone); 299 fibril_mutex_unlock(&fs->phone_lock); 299 300 return; 300 301 } … … 332 333 } 333 334 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 357 335 /** 358 336 * @}
Note:
See TracChangeset
for help on using the changeset viewer.