Changeset b72efe8 in mainline for uspace/srv/vfs
- Timestamp:
- 2011-06-19T14:38:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 74464e8
- Parents:
- 1d1bb0f
- Location:
- uspace/srv/vfs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.h
r1d1bb0f rb72efe8 145 145 extern fibril_mutex_t nodes_mutex; 146 146 147 extern fibril_condvar_t fs_ head_cv;148 extern fibril_mutex_t fs_ head_lock;149 extern li nk_t fs_head; /**< List of registered file systems. */147 extern fibril_condvar_t fs_list_cv; 148 extern fibril_mutex_t fs_list_lock; 149 extern list_t fs_list; /**< List of registered file systems. */ 150 150 151 151 extern vfs_pair_t rootfs; /**< Root file system. */ … … 158 158 } plb_entry_t; 159 159 160 extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_ head. */160 extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_entries. */ 161 161 extern uint8_t *plb; /**< Path Lookup Buffer */ 162 extern li nk_t plb_head;/**< List of active PLB entries. */162 extern list_t plb_entries; /**< List of active PLB entries. */ 163 163 164 164 #define MAX_MNTOPTS_LEN 256 -
uspace/srv/vfs/vfs_lookup.c
r1d1bb0f rb72efe8 50 50 51 51 FIBRIL_MUTEX_INITIALIZE(plb_mutex); 52 LIST_INITIALIZE(plb_ head); /**< PLB entry ring buffer. */52 LIST_INITIALIZE(plb_entries); /**< PLB entry ring buffer. */ 53 53 uint8_t *plb = NULL; 54 54 … … 102 102 size_t last; /* the last free index */ 103 103 104 if (list_empty(&plb_ head)) {104 if (list_empty(&plb_entries)) { 105 105 first = 0; 106 106 last = PLB_SIZE - 1; 107 107 } else { 108 plb_entry_t *oldest = list_get_instance( plb_head.next,109 plb_entry_t, plb_link);110 plb_entry_t *newest = list_get_instance( plb_head.prev,111 plb_entry_t, plb_link);108 plb_entry_t *oldest = list_get_instance( 109 list_first(&plb_entries), plb_entry_t, plb_link); 110 plb_entry_t *newest = list_get_instance( 111 list_last(&plb_entries), plb_entry_t, plb_link); 112 112 113 113 first = (newest->index + newest->len) % PLB_SIZE; … … 145 145 * buffer. 146 146 */ 147 list_append(&entry.plb_link, &plb_ head);147 list_append(&entry.plb_link, &plb_entries); 148 148 149 149 fibril_mutex_unlock(&plb_mutex); -
uspace/srv/vfs/vfs_ops.c
r1d1bb0f rb72efe8 325 325 * This will also give us its file system handle. 326 326 */ 327 fibril_mutex_lock(&fs_ head_lock);327 fibril_mutex_lock(&fs_list_lock); 328 328 fs_handle_t fs_handle; 329 329 recheck: … … 331 331 if (!fs_handle) { 332 332 if (flags & IPC_FLAG_BLOCKING) { 333 fibril_condvar_wait(&fs_ head_cv, &fs_head_lock);333 fibril_condvar_wait(&fs_list_cv, &fs_list_lock); 334 334 goto recheck; 335 335 } 336 336 337 fibril_mutex_unlock(&fs_ head_lock);337 fibril_mutex_unlock(&fs_list_lock); 338 338 async_answer_0(callid, ENOENT); 339 339 async_answer_0(rid, ENOENT); … … 343 343 return; 344 344 } 345 fibril_mutex_unlock(&fs_ head_lock);345 fibril_mutex_unlock(&fs_list_lock); 346 346 347 347 /* Acknowledge that we know fs_name. */ -
uspace/srv/vfs/vfs_register.c
r1d1bb0f rb72efe8 52 52 #include "vfs.h" 53 53 54 FIBRIL_CONDVAR_INITIALIZE(fs_ head_cv);55 FIBRIL_MUTEX_INITIALIZE(fs_ head_lock);56 LIST_INITIALIZE(fs_ head);54 FIBRIL_CONDVAR_INITIALIZE(fs_list_cv); 55 FIBRIL_MUTEX_INITIALIZE(fs_list_lock); 56 LIST_INITIALIZE(fs_list); 57 57 58 58 atomic_t fs_handle_next = { … … 149 149 } 150 150 151 fibril_mutex_lock(&fs_ head_lock);151 fibril_mutex_lock(&fs_list_lock); 152 152 153 153 /* … … 159 159 */ 160 160 dprintf("FS is already registered.\n"); 161 fibril_mutex_unlock(&fs_ head_lock);161 fibril_mutex_unlock(&fs_list_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_ head);171 list_append(&fs_info->fs_link, &fs_list); 172 172 173 173 /* … … 180 180 dprintf("Callback connection expected\n"); 181 181 list_remove(&fs_info->fs_link); 182 fibril_mutex_unlock(&fs_ head_lock);182 fibril_mutex_unlock(&fs_list_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_ head_lock);199 fibril_mutex_unlock(&fs_list_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_ head_lock);213 fibril_mutex_unlock(&fs_list_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_ head_cv);238 fibril_mutex_unlock(&fs_ head_lock);237 fibril_condvar_broadcast(&fs_list_cv); 238 fibril_mutex_unlock(&fs_list_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 the fs_headlist and256 * We simply lookup the session in fs_list and 257 257 * begin an exchange. 258 258 */ 259 fibril_mutex_lock(&fs_head_lock); 260 261 link_t *cur; 262 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 259 fibril_mutex_lock(&fs_list_lock); 260 261 list_foreach(fs_list, cur) { 263 262 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 264 263 265 264 if (fs->fs_handle == handle) { 266 fibril_mutex_unlock(&fs_ head_lock);265 fibril_mutex_unlock(&fs_list_lock); 267 266 268 267 assert(fs->sess); … … 274 273 } 275 274 276 fibril_mutex_unlock(&fs_ head_lock);275 fibril_mutex_unlock(&fs_list_lock); 277 276 278 277 return NULL; … … 293 292 * @param name File system name. 294 293 * @param lock If true, the function will lock and unlock the 295 * fs_ head_lock.294 * fs_list_lock. 296 295 * 297 296 * @return File system handle or zero if file system not found. … … 303 302 304 303 if (lock) 305 fibril_mutex_lock(&fs_head_lock); 306 307 link_t *cur; 308 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 304 fibril_mutex_lock(&fs_list_lock); 305 306 list_foreach(fs_list, cur) { 309 307 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 310 308 if (str_cmp(fs->vfs_info.name, name) == 0) { … … 315 313 316 314 if (lock) 317 fibril_mutex_unlock(&fs_ head_lock);315 fibril_mutex_unlock(&fs_list_lock); 318 316 319 317 return handle; … … 330 328 { 331 329 vfs_info_t *info = NULL; 332 link_t *cur; 333 334 fibril_mutex_lock(&fs_head_lock); 335 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { 330 331 fibril_mutex_lock(&fs_list_lock); 332 list_foreach(fs_list, cur) { 336 333 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); 337 334 if (fs->fs_handle == handle) { … … 340 337 } 341 338 } 342 fibril_mutex_unlock(&fs_ head_lock);339 fibril_mutex_unlock(&fs_list_lock); 343 340 344 341 return info;
Note:
See TracChangeset
for help on using the changeset viewer.