Changeset 2dfd9fa in mainline
- Timestamp:
- 2009-06-22T13:39:46Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2dccb0
- Parents:
- 12956e57
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/devfs/devfs_ops.c
r12956e57 r2dfd9fa 42 42 #include <string.h> 43 43 #include <libfs.h> 44 #include <fibril_sync.h> 44 45 #include <adt/hash_table.h> 45 46 #include "devfs.h" … … 59 60 static hash_table_t devices; 60 61 62 /** Hash table mutex */ 63 static FIBRIL_MUTEX_INITIALIZE(devices_mutex); 64 61 65 #define DEVICES_KEYS 1 62 66 #define DEVICES_KEY_HANDLE 0 … … 196 200 }; 197 201 202 fibril_mutex_lock(&devices_mutex); 198 203 link_t *lnk = hash_table_find(&devices, key); 199 204 if (lnk == NULL) { 200 205 int phone = devmap_device_connect(handle, 0); 201 206 if (phone < 0) { 207 fibril_mutex_unlock(&devices_mutex); 202 208 free(name); 203 209 ipc_answer_0(rid, ENOENT); … … 207 213 device_t *dev = (device_t *) malloc(sizeof(device_t)); 208 214 if (dev == NULL) { 215 fibril_mutex_unlock(&devices_mutex); 209 216 free(name); 210 217 ipc_answer_0(rid, ENOMEM); … … 221 228 dev->refcount++; 222 229 } 230 fibril_mutex_unlock(&devices_mutex); 223 231 } 224 232 … … 239 247 }; 240 248 249 fibril_mutex_lock(&devices_mutex); 241 250 link_t *lnk = hash_table_find(&devices, key); 242 251 if (lnk == NULL) { 243 252 int phone = devmap_device_connect(handle, 0); 244 253 if (phone < 0) { 254 fibril_mutex_unlock(&devices_mutex); 245 255 ipc_answer_0(rid, ENOENT); 246 256 return; … … 249 259 device_t *dev = (device_t *) malloc(sizeof(device_t)); 250 260 if (dev == NULL) { 261 fibril_mutex_unlock(&devices_mutex); 251 262 ipc_answer_0(rid, ENOMEM); 252 263 return; … … 262 273 dev->refcount++; 263 274 } 275 fibril_mutex_unlock(&devices_mutex); 264 276 265 277 ipc_answer_3(rid, EOK, 0, 1, L_FILE); … … 275 287 }; 276 288 289 fibril_mutex_lock(&devices_mutex); 277 290 link_t *lnk = hash_table_find(&devices, key); 278 291 if (lnk == NULL) { 279 ipc_answer_0(rid, ENOENT); 280 return; 281 } 292 fibril_mutex_unlock(&devices_mutex); 293 ipc_answer_0(rid, ENOENT); 294 return; 295 } 296 fibril_mutex_unlock(&devices_mutex); 282 297 283 298 ipc_answer_1(rid, EOK, (ipcarg_t) index); … … 296 311 }; 297 312 313 fibril_mutex_lock(&devices_mutex); 298 314 link_t *lnk = hash_table_find(&devices, key); 299 315 if (lnk == NULL) { 316 fibril_mutex_unlock(&devices_mutex); 300 317 ipc_answer_0(rid, ENOENT); 301 318 return; … … 306 323 ipc_callid_t callid; 307 324 if (!ipc_data_read_receive(&callid, NULL)) { 325 fibril_mutex_unlock(&devices_mutex); 308 326 ipc_answer_0(callid, EINVAL); 309 327 ipc_answer_0(rid, EINVAL); … … 319 337 /* Forward the IPC_M_DATA_READ request to the driver */ 320 338 ipc_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 339 fibril_mutex_unlock(&devices_mutex); 321 340 322 341 /* Wait for reply from the driver. */ … … 370 389 }; 371 390 391 fibril_mutex_lock(&devices_mutex); 372 392 link_t *lnk = hash_table_find(&devices, key); 373 393 if (lnk == NULL) { 394 fibril_mutex_unlock(&devices_mutex); 374 395 ipc_answer_0(rid, ENOENT); 375 396 return; … … 380 401 ipc_callid_t callid; 381 402 if (!ipc_data_write_receive(&callid, NULL)) { 403 fibril_mutex_unlock(&devices_mutex); 382 404 ipc_answer_0(callid, EINVAL); 383 405 ipc_answer_0(rid, EINVAL); … … 394 416 ipc_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 395 417 418 fibril_mutex_unlock(&devices_mutex); 419 396 420 /* Wait for reply from the driver. */ 397 421 ipcarg_t rc; … … 421 445 }; 422 446 447 fibril_mutex_lock(&devices_mutex); 423 448 link_t *lnk = hash_table_find(&devices, key); 424 449 if (lnk == NULL) { 450 fibril_mutex_unlock(&devices_mutex); 425 451 ipc_answer_0(rid, ENOENT); 426 452 return; … … 434 460 hash_table_remove(&devices, key, DEVICES_KEYS); 435 461 } 462 463 fibril_mutex_unlock(&devices_mutex); 436 464 437 465 ipc_answer_0(rid, EOK); … … 449 477 }; 450 478 479 fibril_mutex_lock(&devices_mutex); 451 480 link_t *lnk = hash_table_find(&devices, key); 452 481 if (lnk == NULL) { 482 fibril_mutex_unlock(&devices_mutex); 453 483 ipc_answer_0(rid, ENOENT); 454 484 return; … … 462 492 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer); 463 493 494 fibril_mutex_unlock(&devices_mutex); 495 464 496 /* Wait for reply from the driver */ 465 497 ipcarg_t rc;
Note:
See TracChangeset
for help on using the changeset viewer.