Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b4cbef1 in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2010-02-03T16:52:37Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
3b3e776, eda925a
Parents:
472c09d
Message:

add minimal data size check into async_data_receive
introduce more convenience wrappers for common IPC patterns:

async_data_read_forward_fast
async_data_void
async_data_forward_fast

File:
1 edited

Legend:

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

    r472c09d rb4cbef1  
    794794       
    795795        /*
    796          * Now we need to receive a call with client's
    797          * IPC_M_DATA_READ/IPC_M_DATA_WRITE request.
    798          */
    799         ipc_callid_t callid;
    800         int res;
    801         if (read)
    802                 res = async_data_read_receive(&callid, NULL);
    803         else
    804                 res = async_data_write_receive(&callid, NULL);
    805         if (!res) {
    806                 ipc_answer_0(callid, EINVAL);
    807                 ipc_answer_0(rid, EINVAL);
    808                 return;
    809         }
    810        
    811         /*
    812796         * Lock the open file structure so that no other thread can manipulate
    813797         * the same open file at a time.
     
    833817        }
    834818       
    835         int fs_phone = vfs_grab_phone(file->node->fs_handle);   
    836        
    837         /* Make a VFS_READ/VFS_WRITE request at the destination FS server. */
    838         aid_t msg;
    839         ipc_call_t answer;
    840         if (!read && file->append)
    841                 file->pos = file->node->size;
    842         msg = async_send_3(fs_phone, read ? VFS_OUT_READ : VFS_OUT_WRITE,
    843             file->node->dev_handle, file->node->index, file->pos, &answer);
    844        
    845         /*
    846          * Forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
     819        int fs_phone = vfs_grab_phone(file->node->fs_handle);
     820       
     821        /*
     822         * Make a VFS_READ/VFS_WRITE request at the destination FS server
     823         * and forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
    847824         * destination FS server. The call will be routed as if sent by
    848825         * ourselves. Note that call arguments are immutable in this case so we
    849826         * don't have to bother.
    850827         */
    851         ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    852 
    853         /* Wait for reply from the FS server. */
    854828        ipcarg_t rc;
    855         async_wait_for(msg, &rc);
     829        ipc_call_t answer;
     830        if (read) {
     831                if (file->append)
     832                        file->pos = file->node->size;
     833               
     834                rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ,
     835                    file->node->dev_handle, file->node->index, file->pos,
     836                    &answer);
     837        } else {
     838                rc = async_data_forward_3_1(fs_phone, VFS_OUT_WRITE,
     839                    file->node->dev_handle, file->node->index, file->pos,
     840                    &answer);
     841        }
    856842       
    857843        vfs_release_phone(fs_phone);
    858844       
    859845        size_t bytes = IPC_GET_ARG1(answer);
    860 
     846       
    861847        if (file->node->type == VFS_NODE_DIRECTORY)
    862848                fibril_rwlock_read_unlock(&namespace_rwlock);
Note: See TracChangeset for help on using the changeset viewer.