Changeset b72efe8 in mainline for uspace/srv/vfs


Ignore:
Timestamp:
2011-06-19T14:38:59Z (14 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
Location:
uspace/srv/vfs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    r1d1bb0f rb72efe8  
    145145extern fibril_mutex_t nodes_mutex;
    146146
    147 extern fibril_condvar_t fs_head_cv;
    148 extern fibril_mutex_t fs_head_lock;
    149 extern link_t fs_head;          /**< List of registered file systems. */
     147extern fibril_condvar_t fs_list_cv;
     148extern fibril_mutex_t fs_list_lock;
     149extern list_t fs_list;          /**< List of registered file systems. */
    150150
    151151extern vfs_pair_t rootfs;       /**< Root file system. */
     
    158158} plb_entry_t;
    159159
    160 extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_head. */
     160extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_entries. */
    161161extern uint8_t *plb;            /**< Path Lookup Buffer */
    162 extern link_t plb_head;         /**< List of active PLB entries. */
     162extern list_t plb_entries;      /**< List of active PLB entries. */
    163163
    164164#define MAX_MNTOPTS_LEN         256
  • uspace/srv/vfs/vfs_lookup.c

    r1d1bb0f rb72efe8  
    5050
    5151FIBRIL_MUTEX_INITIALIZE(plb_mutex);
    52 LIST_INITIALIZE(plb_head);      /**< PLB entry ring buffer. */
     52LIST_INITIALIZE(plb_entries);   /**< PLB entry ring buffer. */
    5353uint8_t *plb = NULL;
    5454
     
    102102        size_t last;    /* the last free index */
    103103
    104         if (list_empty(&plb_head)) {
     104        if (list_empty(&plb_entries)) {
    105105                first = 0;
    106106                last = PLB_SIZE - 1;
    107107        } 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);
    112112
    113113                first = (newest->index + newest->len) % PLB_SIZE;
     
    145145         * buffer.
    146146         */
    147         list_append(&entry.plb_link, &plb_head);
     147        list_append(&entry.plb_link, &plb_entries);
    148148       
    149149        fibril_mutex_unlock(&plb_mutex);
  • uspace/srv/vfs/vfs_ops.c

    r1d1bb0f rb72efe8  
    325325         * This will also give us its file system handle.
    326326         */
    327         fibril_mutex_lock(&fs_head_lock);
     327        fibril_mutex_lock(&fs_list_lock);
    328328        fs_handle_t fs_handle;
    329329recheck:
     
    331331        if (!fs_handle) {
    332332                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);
    334334                        goto recheck;
    335335                }
    336336               
    337                 fibril_mutex_unlock(&fs_head_lock);
     337                fibril_mutex_unlock(&fs_list_lock);
    338338                async_answer_0(callid, ENOENT);
    339339                async_answer_0(rid, ENOENT);
     
    343343                return;
    344344        }
    345         fibril_mutex_unlock(&fs_head_lock);
     345        fibril_mutex_unlock(&fs_list_lock);
    346346       
    347347        /* Acknowledge that we know fs_name. */
  • 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.