Changes in uspace/srv/vfs/vfs_register.c [15f3c3f:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_register.c
r15f3c3f r79ae36dd 52 52 #include "vfs.h" 53 53 54 FIBRIL_CONDVAR_INITIALIZE(fs_ list_cv);55 FIBRIL_MUTEX_INITIALIZE(fs_ list_lock);56 LIST_INITIALIZE(fs_ list);54 FIBRIL_CONDVAR_INITIALIZE(fs_head_cv); 55 FIBRIL_MUTEX_INITIALIZE(fs_head_lock); 56 LIST_INITIALIZE(fs_head); 57 57 58 58 atomic_t fs_handle_next = { … … 149 149 } 150 150 151 fibril_mutex_lock(&fs_ list_lock);151 fibril_mutex_lock(&fs_head_lock); 152 152 153 153 /* … … 159 159 */ 160 160 dprintf("FS is already registered.\n"); 161 fibril_mutex_unlock(&fs_ list_lock);161 fibril_mutex_unlock(&fs_head_lock); 162 162 free(fs_info); 163 163 async_answer_0(rid, EEXISTS); … … 169 169 */ 170 170 dprintf("Inserting FS into the list of registered file systems.\n"); 171 list_append(&fs_info->fs_link, &fs_ list);171 list_append(&fs_info->fs_link, &fs_head); 172 172 173 173 /* … … 180 180 dprintf("Callback connection expected\n"); 181 181 list_remove(&fs_info->fs_link); 182 fibril_mutex_unlock(&fs_ list_lock);182 fibril_mutex_unlock(&fs_head_lock); 183 183 free(fs_info); 184 184 async_answer_0(rid, EINVAL); … … 197 197 dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call)); 198 198 list_remove(&fs_info->fs_link); 199 fibril_mutex_unlock(&fs_ list_lock);199 fibril_mutex_unlock(&fs_head_lock); 200 200 async_hangup(fs_info->sess); 201 201 free(fs_info); … … 211 211 dprintf("Client suggests wrong size of PFB, size = %d\n", size); 212 212 list_remove(&fs_info->fs_link); 213 fibril_mutex_unlock(&fs_ list_lock);213 fibril_mutex_unlock(&fs_head_lock); 214 214 async_hangup(fs_info->sess); 215 215 free(fs_info); … … 235 235 async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle); 236 236 237 fibril_condvar_broadcast(&fs_ list_cv);238 fibril_mutex_unlock(&fs_ list_lock);237 fibril_condvar_broadcast(&fs_head_cv); 238 fibril_mutex_unlock(&fs_head_lock); 239 239 240 240 dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n", … … 254 254 /* 255 255 * For now, we don't try to be very clever and very fast. 256 * We simply lookup the session in fs_list and256 * We simply lookup the session in the fs_head list and 257 257 * begin an exchange. 258 258 */ 259 fibril_mutex_lock(&fs_list_lock); 260 261 list_foreach(fs_list, cur) { 259 fibril_mutex_lock(&fs_head_lock); 260 261 link_t *cur; 262 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 262 263 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 263 264 264 265 if (fs->fs_handle == handle) { 265 fibril_mutex_unlock(&fs_ list_lock);266 fibril_mutex_unlock(&fs_head_lock); 266 267 267 268 assert(fs->sess); … … 273 274 } 274 275 275 fibril_mutex_unlock(&fs_ list_lock);276 fibril_mutex_unlock(&fs_head_lock); 276 277 277 278 return NULL; … … 292 293 * @param name File system name. 293 294 * @param lock If true, the function will lock and unlock the 294 * fs_ list_lock.295 * fs_head_lock. 295 296 * 296 297 * @return File system handle or zero if file system not found. … … 302 303 303 304 if (lock) 304 fibril_mutex_lock(&fs_list_lock); 305 306 list_foreach(fs_list, cur) { 305 fibril_mutex_lock(&fs_head_lock); 306 307 link_t *cur; 308 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 307 309 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 308 if (str_cmp(fs->vfs_info.name, name) == 0) { 310 if (str_cmp(fs->vfs_info.name, name) == 0) { 309 311 handle = fs->fs_handle; 310 312 break; … … 313 315 314 316 if (lock) 315 fibril_mutex_unlock(&fs_ list_lock);317 fibril_mutex_unlock(&fs_head_lock); 316 318 317 319 return handle; … … 328 330 { 329 331 vfs_info_t *info = NULL; 330 331 fibril_mutex_lock(&fs_list_lock); 332 list_foreach(fs_list, cur) { 332 link_t *cur; 333 334 fibril_mutex_lock(&fs_head_lock); 335 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 333 336 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 334 337 if (fs->fs_handle == handle) { … … 337 340 } 338 341 } 339 fibril_mutex_unlock(&fs_ list_lock);342 fibril_mutex_unlock(&fs_head_lock); 340 343 341 344 return info;
Note:
See TracChangeset
for help on using the changeset viewer.