Changeset 89c57b6 in mainline for uspace/srv/vfs/vfs_register.c


Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88634420
Parents:
cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    rcefb126 r89c57b6  
    3636 */
    3737
    38 #include <ipc/ipc.h>
    3938#include <ipc/services.h>
    4039#include <async.h>
    4140#include <fibril.h>
     41#include <fibril_synch.h>
    4242#include <errno.h>
    4343#include <stdio.h>
     
    4646#include <ctype.h>
    4747#include <bool.h>
    48 #include <fibril_synch.h>
    4948#include <adt/list.h>
    5049#include <as.h>
     
    110109void vfs_register(ipc_callid_t rid, ipc_call_t *request)
    111110{
     111        int phone;
     112       
    112113        dprintf("Processing VFS_REGISTER request received from %p.\n",
    113114            request->in_phone_hash);
     
    120121                dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n",
    121122                    rc);
    122                 ipc_answer_0(rid, rc);
     123                async_answer_0(rid, rc);
    123124                return;
    124125        }
     
    130131        if (!fs_info) {
    131132                dprintf("Could not allocate memory for FS info.\n");
    132                 ipc_answer_0(rid, ENOMEM);
     133                async_answer_0(rid, ENOMEM);
    133134                return;
    134135        }
    135136       
    136137        link_initialize(&fs_info->fs_link);
    137         fibril_mutex_initialize(&fs_info->phone_lock);
    138138        fs_info->vfs_info = *vfs_info;
    139139        free(vfs_info);
     
    143143        if (!vfs_info_sane(&fs_info->vfs_info)) {
    144144                free(fs_info);
    145                 ipc_answer_0(rid, EINVAL);
     145                async_answer_0(rid, EINVAL);
    146146                return;
    147147        }
     
    159159                fibril_mutex_unlock(&fs_head_lock);
    160160                free(fs_info);
    161                 ipc_answer_0(rid, EEXISTS);
     161                async_answer_0(rid, EEXISTS);
    162162                return;
    163163        }
     
    176176        ipc_call_t call;
    177177        ipc_callid_t callid = async_get_call(&call);
    178         if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
    179                 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
     178        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
     179                dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
    180180                list_remove(&fs_info->fs_link);
    181181                fibril_mutex_unlock(&fs_head_lock);
    182182                free(fs_info);
    183                 ipc_answer_0(callid, EINVAL);
    184                 ipc_answer_0(rid, EINVAL);
    185                 return;
    186         }
    187         fs_info->phone = IPC_GET_ARG5(call);
    188         ipc_answer_0(callid, EOK);
     183                async_answer_0(callid, EINVAL);
     184                async_answer_0(rid, EINVAL);
     185                return;
     186        }
     187       
     188        phone = IPC_GET_ARG5(call);
     189        async_session_create(&fs_info->session, phone, 0);
     190        async_answer_0(callid, EOK);
    189191       
    190192        dprintf("Callback connection to FS created.\n");
     
    196198        size_t size;
    197199        if (!async_share_in_receive(&callid, &size)) {
    198                 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
     200                dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
    199201                list_remove(&fs_info->fs_link);
    200202                fibril_mutex_unlock(&fs_head_lock);
    201                 ipc_hangup(fs_info->phone);
    202                 free(fs_info);
    203                 ipc_answer_0(callid, EINVAL);
    204                 ipc_answer_0(rid, EINVAL);
     203                async_session_destroy(&fs_info->session);
     204                async_hangup(phone);
     205                free(fs_info);
     206                async_answer_0(callid, EINVAL);
     207                async_answer_0(rid, EINVAL);
    205208                return;
    206209        }
     
    213216                list_remove(&fs_info->fs_link);
    214217                fibril_mutex_unlock(&fs_head_lock);
    215                 ipc_hangup(fs_info->phone);
    216                 free(fs_info);
    217                 ipc_answer_0(callid, EINVAL);
    218                 ipc_answer_0(rid, EINVAL);
     218                async_session_destroy(&fs_info->session);
     219                async_hangup(phone);
     220                free(fs_info);
     221                async_answer_0(callid, EINVAL);
     222                async_answer_0(rid, EINVAL);
    219223                return;
    220224        }
     
    234238         */
    235239        fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next);
    236         ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);
     240        async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
    237241       
    238242        fibril_condvar_broadcast(&fs_head_cv);
     
    252256int vfs_grab_phone(fs_handle_t handle)
    253257{
     258        link_t *cur;
     259        fs_info_t *fs;
    254260        int phone;
    255261
     
    262268         */
    263269        fibril_mutex_lock(&fs_head_lock);
    264         link_t *cur;
    265         fs_info_t *fs;
    266270        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
    267271                fs = list_get_instance(cur, fs_info_t, fs_link);
    268272                if (fs->fs_handle == handle) {
    269273                        fibril_mutex_unlock(&fs_head_lock);
    270                         fibril_mutex_lock(&fs->phone_lock);
    271                         phone = ipc_connect_me_to(fs->phone, 0, 0, 0);
    272                         fibril_mutex_unlock(&fs->phone_lock);
     274                        phone = async_exchange_begin(&fs->session);
    273275
    274276                        assert(phone > 0);
     
    284286 * @param phone         Phone to FS task.
    285287 */
    286 void vfs_release_phone(int phone)
    287 {
    288         /* TODO: implement connection caching */
    289         ipc_hangup(phone);
     288void vfs_release_phone(fs_handle_t handle, int phone)
     289{
     290        link_t *cur;
     291        fs_info_t *fs;
     292
     293        fibril_mutex_lock(&fs_head_lock);
     294        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     295                fs = list_get_instance(cur, fs_info_t, fs_link);
     296                if (fs->fs_handle == handle) {
     297                        fibril_mutex_unlock(&fs_head_lock);
     298                        async_exchange_end(&fs->session, phone);
     299                        return;
     300                }
     301        }
     302        /* should not really get here */
     303        abort();
     304        fibril_mutex_unlock(&fs_head_lock);
    290305}
    291306
     
    317332}
    318333
     334/** Find the VFS info structure.
     335 *
     336 * @param handle        FS handle for which the VFS info structure is sought.
     337 * @return              VFS info structure on success or NULL otherwise.
     338 */
     339vfs_info_t *fs_handle_to_info(fs_handle_t handle)
     340{
     341        vfs_info_t *info = NULL;
     342        link_t *cur;
     343
     344        fibril_mutex_lock(&fs_head_lock);
     345        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     346                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
     347                if (fs->fs_handle == handle) {
     348                        info = &fs->vfs_info;
     349                        break;
     350                }
     351        }
     352        fibril_mutex_unlock(&fs_head_lock);
     353
     354        return info;
     355}
     356
    319357/**
    320358 * @}
Note: See TracChangeset for help on using the changeset viewer.