Changeset 89c57b6 in mainline for uspace/srv/vfs/vfs_register.c
- Timestamp:
- 2011-04-13T14:45:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88634420
- Parents:
- cefb126 (diff), 17279ead (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
rcefb126 r89c57b6 36 36 */ 37 37 38 #include <ipc/ipc.h>39 38 #include <ipc/services.h> 40 39 #include <async.h> 41 40 #include <fibril.h> 41 #include <fibril_synch.h> 42 42 #include <errno.h> 43 43 #include <stdio.h> … … 46 46 #include <ctype.h> 47 47 #include <bool.h> 48 #include <fibril_synch.h>49 48 #include <adt/list.h> 50 49 #include <as.h> … … 110 109 void vfs_register(ipc_callid_t rid, ipc_call_t *request) 111 110 { 111 int phone; 112 112 113 dprintf("Processing VFS_REGISTER request received from %p.\n", 113 114 request->in_phone_hash); … … 120 121 dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", 121 122 rc); 122 ipc_answer_0(rid, rc);123 async_answer_0(rid, rc); 123 124 return; 124 125 } … … 130 131 if (!fs_info) { 131 132 dprintf("Could not allocate memory for FS info.\n"); 132 ipc_answer_0(rid, ENOMEM);133 async_answer_0(rid, ENOMEM); 133 134 return; 134 135 } 135 136 136 137 link_initialize(&fs_info->fs_link); 137 fibril_mutex_initialize(&fs_info->phone_lock);138 138 fs_info->vfs_info = *vfs_info; 139 139 free(vfs_info); … … 143 143 if (!vfs_info_sane(&fs_info->vfs_info)) { 144 144 free(fs_info); 145 ipc_answer_0(rid, EINVAL);145 async_answer_0(rid, EINVAL); 146 146 return; 147 147 } … … 159 159 fibril_mutex_unlock(&fs_head_lock); 160 160 free(fs_info); 161 ipc_answer_0(rid, EEXISTS);161 async_answer_0(rid, EEXISTS); 162 162 return; 163 163 } … … 176 176 ipc_call_t call; 177 177 ipc_callid_t callid = async_get_call(&call); 178 if (IPC_GET_ METHOD(call) != IPC_M_CONNECT_TO_ME) {179 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)); 180 180 list_remove(&fs_info->fs_link); 181 181 fibril_mutex_unlock(&fs_head_lock); 182 182 free(fs_info); 183 ipc_answer_0(callid, EINVAL); 184 ipc_answer_0(rid, EINVAL); 185 return; 186 } 187 fs_info->phone = IPC_GET_ARG5(call); 188 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); 189 191 190 192 dprintf("Callback connection to FS created.\n"); … … 196 198 size_t size; 197 199 if (!async_share_in_receive(&callid, &size)) { 198 dprintf("Unexpected call, method = %d\n", IPC_GET_ METHOD(call));200 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 199 201 list_remove(&fs_info->fs_link); 200 202 fibril_mutex_unlock(&fs_head_lock); 201 ipc_hangup(fs_info->phone); 202 free(fs_info); 203 ipc_answer_0(callid, EINVAL); 204 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); 205 208 return; 206 209 } … … 213 216 list_remove(&fs_info->fs_link); 214 217 fibril_mutex_unlock(&fs_head_lock); 215 ipc_hangup(fs_info->phone); 216 free(fs_info); 217 ipc_answer_0(callid, EINVAL); 218 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); 219 223 return; 220 224 } … … 234 238 */ 235 239 fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next); 236 ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);240 async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle); 237 241 238 242 fibril_condvar_broadcast(&fs_head_cv); … … 252 256 int vfs_grab_phone(fs_handle_t handle) 253 257 { 258 link_t *cur; 259 fs_info_t *fs; 254 260 int phone; 255 261 … … 262 268 */ 263 269 fibril_mutex_lock(&fs_head_lock); 264 link_t *cur;265 fs_info_t *fs;266 270 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 267 271 fs = list_get_instance(cur, fs_info_t, fs_link); 268 272 if (fs->fs_handle == handle) { 269 273 fibril_mutex_unlock(&fs_head_lock); 270 fibril_mutex_lock(&fs->phone_lock); 271 phone = ipc_connect_me_to(fs->phone, 0, 0, 0); 272 fibril_mutex_unlock(&fs->phone_lock); 274 phone = async_exchange_begin(&fs->session); 273 275 274 276 assert(phone > 0); … … 284 286 * @param phone Phone to FS task. 285 287 */ 286 void vfs_release_phone(int phone) 287 { 288 /* TODO: implement connection caching */ 289 ipc_hangup(phone); 288 void vfs_release_phone(fs_handle_t handle, int phone) 289 { 290 link_t *cur; 291 fs_info_t *fs; 292 293 fibril_mutex_lock(&fs_head_lock); 294 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 295 fs = list_get_instance(cur, fs_info_t, fs_link); 296 if (fs->fs_handle == handle) { 297 fibril_mutex_unlock(&fs_head_lock); 298 async_exchange_end(&fs->session, phone); 299 return; 300 } 301 } 302 /* should not really get here */ 303 abort(); 304 fibril_mutex_unlock(&fs_head_lock); 290 305 } 291 306 … … 317 332 } 318 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 319 357 /** 320 358 * @}
Note:
See TracChangeset
for help on using the changeset viewer.