Changeset 42d08592 in mainline


Ignore:
Timestamp:
2016-09-02T12:28:18Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e503517a
Parents:
2a2fbc8
Message:

Factor out IPC communication from vfs_rdwr()

File:
1 edited

Legend:

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

    r2a2fbc8 r42d08592  
    734734}
    735735
    736 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
     736typedef sysarg_t (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, ipc_call_t *,
     737    bool, void *);
     738
     739static sysarg_t rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file,
     740    ipc_call_t *answer, bool read, void *data)
     741{
     742        /*
     743         * Make a VFS_READ/VFS_WRITE request at the destination FS server
     744         * and forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
     745         * destination FS server. The call will be routed as if sent by
     746         * ourselves. Note that call arguments are immutable in this case so we
     747         * don't have to bother.
     748         */
     749
     750        if (read) {
     751                return async_data_read_forward_4_1(exch, VFS_OUT_READ,
     752                    file->node->service_id, file->node->index,
     753                    LOWER32(file->pos), UPPER32(file->pos), answer);
     754        } else {
     755                return async_data_write_forward_4_1(exch, VFS_OUT_WRITE,
     756                    file->node->service_id, file->node->index,
     757                    LOWER32(file->pos), UPPER32(file->pos), answer);
     758        }       
     759}
     760       
     761static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read,
     762    rdwr_ipc_cb_t ipc_cb, void *ipc_cb_data)
    737763{
    738764        /*
     
    786812        async_exch_t *fs_exch = vfs_exchange_grab(file->node->fs_handle);
    787813       
    788         /*
    789          * Make a VFS_READ/VFS_WRITE request at the destination FS server
    790          * and forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
    791          * destination FS server. The call will be routed as if sent by
    792          * ourselves. Note that call arguments are immutable in this case so we
    793          * don't have to bother.
    794          */
    795         sysarg_t rc;
     814        if (!read && file->append)
     815                file->pos = file->node->size;
     816       
     817        /*
     818         * Handle communication with the endpoint FS.
     819         */
    796820        ipc_call_t answer;
    797         if (read) {
    798                 rc = async_data_read_forward_4_1(fs_exch, VFS_OUT_READ,
    799                     file->node->service_id, file->node->index,
    800                     LOWER32(file->pos), UPPER32(file->pos), &answer);
    801         } else {
    802                 if (file->append)
    803                         file->pos = file->node->size;
    804                
    805                 rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE,
    806                     file->node->service_id, file->node->index,
    807                     LOWER32(file->pos), UPPER32(file->pos), &answer);
    808         }
     821        sysarg_t rc = ipc_cb(fs_exch, file, &answer, read, ipc_cb_data);
    809822       
    810823        vfs_exchange_release(fs_exch);
     
    842855void vfs_read(ipc_callid_t rid, ipc_call_t *request)
    843856{
    844         vfs_rdwr(rid, request, true);
     857        vfs_rdwr(rid, request, true, rdwr_ipc_client, NULL);
    845858}
    846859
    847860void vfs_write(ipc_callid_t rid, ipc_call_t *request)
    848861{
    849         vfs_rdwr(rid, request, false);
     862        vfs_rdwr(rid, request, false, rdwr_ipc_client, NULL);
    850863}
    851864
Note: See TracChangeset for help on using the changeset viewer.