Changeset b72efe8 in mainline for uspace/srv/vfs/vfs_register.c


Ignore:
Timestamp:
2011-06-19T14:38:59Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74464e8
Parents:
1d1bb0f
Message:

Separate list_t typedef from link_t (user-space part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • assert_link_not_used()
  • usb_hid_report_path_free() shall not unlink the path, caller must do it
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_register.c

    r1d1bb0f rb72efe8  
    5252#include "vfs.h"
    5353
    54 FIBRIL_CONDVAR_INITIALIZE(fs_head_cv);
    55 FIBRIL_MUTEX_INITIALIZE(fs_head_lock);
    56 LIST_INITIALIZE(fs_head);
     54FIBRIL_CONDVAR_INITIALIZE(fs_list_cv);
     55FIBRIL_MUTEX_INITIALIZE(fs_list_lock);
     56LIST_INITIALIZE(fs_list);
    5757
    5858atomic_t fs_handle_next = {
     
    149149        }
    150150       
    151         fibril_mutex_lock(&fs_head_lock);
     151        fibril_mutex_lock(&fs_list_lock);
    152152       
    153153        /*
     
    159159                 */
    160160                dprintf("FS is already registered.\n");
    161                 fibril_mutex_unlock(&fs_head_lock);
     161                fibril_mutex_unlock(&fs_list_lock);
    162162                free(fs_info);
    163163                async_answer_0(rid, EEXISTS);
     
    169169         */
    170170        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);
    172172       
    173173        /*
     
    180180                dprintf("Callback connection expected\n");
    181181                list_remove(&fs_info->fs_link);
    182                 fibril_mutex_unlock(&fs_head_lock);
     182                fibril_mutex_unlock(&fs_list_lock);
    183183                free(fs_info);
    184184                async_answer_0(rid, EINVAL);
     
    197197                dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
    198198                list_remove(&fs_info->fs_link);
    199                 fibril_mutex_unlock(&fs_head_lock);
     199                fibril_mutex_unlock(&fs_list_lock);
    200200                async_hangup(fs_info->sess);
    201201                free(fs_info);
     
    211211                dprintf("Client suggests wrong size of PFB, size = %d\n", size);
    212212                list_remove(&fs_info->fs_link);
    213                 fibril_mutex_unlock(&fs_head_lock);
     213                fibril_mutex_unlock(&fs_list_lock);
    214214                async_hangup(fs_info->sess);
    215215                free(fs_info);
     
    235235        async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
    236236       
    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);
    239239       
    240240        dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n",
     
    254254        /*
    255255         * For now, we don't try to be very clever and very fast.
    256          * We simply lookup the session in the fs_head list and
     256         * We simply lookup the session in fs_list and
    257257         * begin an exchange.
    258258         */
    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) {
    263262                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    264263               
    265264                if (fs->fs_handle == handle) {
    266                         fibril_mutex_unlock(&fs_head_lock);
     265                        fibril_mutex_unlock(&fs_list_lock);
    267266                       
    268267                        assert(fs->sess);
     
    274273        }
    275274       
    276         fibril_mutex_unlock(&fs_head_lock);
     275        fibril_mutex_unlock(&fs_list_lock);
    277276       
    278277        return NULL;
     
    293292 * @param name File system name.
    294293 * @param lock If true, the function will lock and unlock the
    295  *             fs_head_lock.
     294 *             fs_list_lock.
    296295 *
    297296 * @return File system handle or zero if file system not found.
     
    303302       
    304303        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) {
    309307                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    310308                if (str_cmp(fs->vfs_info.name, name) == 0) {
     
    315313       
    316314        if (lock)
    317                 fibril_mutex_unlock(&fs_head_lock);
     315                fibril_mutex_unlock(&fs_list_lock);
    318316       
    319317        return handle;
     
    330328{
    331329        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) {
    336333                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    337334                if (fs->fs_handle == handle) {
     
    340337                }
    341338        }
    342         fibril_mutex_unlock(&fs_head_lock);
     339        fibril_mutex_unlock(&fs_list_lock);
    343340       
    344341        return info;
Note: See TracChangeset for help on using the changeset viewer.