Changeset 973ef9fc in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2010-12-25T21:20:28Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
631ee0c
Parents:
1bfd3d3 (diff), 09178b7f (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_ops.c

    r1bfd3d3 r973ef9fc  
    5555
    5656/* Forward declarations of static functions. */
    57 static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t, aoff64_t);
     57static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t,
     58    aoff64_t);
    5859
    5960/**
     
    7879        size_t rsize;
    7980        unsigned rlnkcnt;
    80         ipcarg_t rc;
     81        sysarg_t rc;
    8182        int phone;
    8283        aid_t msg;
     
    125126                        phone = vfs_grab_phone(fs_handle);
    126127                        msg = async_send_1(phone, VFS_OUT_MOUNTED,
    127                             (ipcarg_t) devmap_handle, &answer);
     128                            (sysarg_t) devmap_handle, &answer);
    128129                        /* send the mount options */
    129130                        rc = async_data_write_start(phone, (void *)opts,
     
    187188        phone = vfs_grab_phone(mp_res.triplet.fs_handle);
    188189        msg = async_send_4(phone, VFS_OUT_MOUNT,
    189             (ipcarg_t) mp_res.triplet.devmap_handle,
    190             (ipcarg_t) mp_res.triplet.index,
    191             (ipcarg_t) fs_handle,
    192             (ipcarg_t) devmap_handle, &answer);
     190            (sysarg_t) mp_res.triplet.devmap_handle,
     191            (sysarg_t) mp_res.triplet.index,
     192            (sysarg_t) fs_handle,
     193            (sysarg_t) devmap_handle, &answer);
    193194       
    194195        /* send connection */
     
    250251void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
    251252{
     253        devmap_handle_t devmap_handle;
     254
    252255        /*
    253256         * We expect the library to do the device-name to device-handle
     
    255258         * in the request.
    256259         */
    257         devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
     260        devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    258261       
    259262        /*
     
    291294         */
    292295        char *fs_name;
    293         rc = async_data_write_accept((void **) &fs_name, true, 0, FS_NAME_MAXLEN,
    294             0, NULL);
     296        rc = async_data_write_accept((void **) &fs_name, true, 0,
     297            FS_NAME_MAXLEN, 0, NULL);
    295298        if (rc != EOK) {
    296299                free(mp);
     
    306309        ipc_call_t data;
    307310        ipc_callid_t callid = async_get_call(&data);
    308         if (IPC_GET_METHOD(data) != IPC_M_PING) {
     311        if (IPC_GET_IMETHOD(data) != IPC_M_PING) {
    309312                ipc_answer_0(callid, ENOTSUP);
    310313                ipc_answer_0(rid, ENOTSUP);
     
    458461
    459462                phone = vfs_grab_phone(mp_node->fs_handle);
    460                 rc = async_req_2_0(phone, VFS_OUT_UNMOUNT, mp_node->devmap_handle,
    461                     mp_node->index);
     463                rc = async_req_2_0(phone, VFS_OUT_UNMOUNT,
     464                    mp_node->devmap_handle, mp_node->index);
    462465                vfs_release_phone(mp_node->fs_handle, phone);
    463466                if (rc != EOK) {
     
    713716
    714717        /* Wait for reply from the FS server. */
    715         ipcarg_t rc;
     718        sysarg_t rc;
    716719        async_wait_for(msg, &rc);
    717720       
     
    740743                aid_t msg;
    741744                ipc_call_t answer;
    742                 msg = async_send_2(fs_phone, VFS_OUT_CLOSE, file->node->devmap_handle,
    743                     file->node->index, &answer);
     745                msg = async_send_2(fs_phone, VFS_OUT_CLOSE,
     746                    file->node->devmap_handle, file->node->index, &answer);
    744747               
    745748                /* Wait for reply from the FS server. */
    746                 ipcarg_t rc;
     749                sysarg_t rc;
    747750                async_wait_for(msg, &rc);
    748751               
     
    778781static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
    779782{
     783        vfs_info_t *vi;
    780784
    781785        /*
     
    804808        fibril_mutex_lock(&file->lock);
    805809
     810        vi = fs_handle_to_info(file->node->fs_handle);
     811        assert(vi);
     812
    806813        /*
    807814         * Lock the file's node so that no other client can read/write to it at
    808          * the same time.
    809          */
    810         if (read)
     815         * the same time unless the FS supports concurrent reads/writes and its
     816         * write implementation does not modify the file size.
     817         */
     818        if (read || (vi->concurrent_read_write && vi->write_retains_size))
    811819                fibril_rwlock_read_lock(&file->node->contents_rwlock);
    812820        else
     
    831839         * don't have to bother.
    832840         */
    833         ipcarg_t rc;
     841        sysarg_t rc;
    834842        ipc_call_t answer;
    835843        if (read) {
    836                 if (file->append)
    837                         file->pos = file->node->size;
    838                
    839844                rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ,
    840845                    file->node->devmap_handle, file->node->index, file->pos,
    841846                    &answer);
    842847        } else {
     848                if (file->append)
     849                        file->pos = file->node->size;
     850               
    843851                rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE,
    844852                    file->node->devmap_handle, file->node->index, file->pos,
     
    854862       
    855863        /* Unlock the VFS node. */
    856         if (read)
     864        if (read || (vi->concurrent_read_write && vi->write_retains_size))
    857865                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    858866        else {
     
    888896{
    889897        int fd = (int) IPC_GET_ARG1(*request);
    890         off64_t off =
    891             (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
     898        off64_t off = (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
     899            IPC_GET_ARG3(*request));
    892900        int whence = (int) IPC_GET_ARG4(*request);
    893901       
     
    903911        off64_t newoff;
    904912        switch (whence) {
    905                 case SEEK_SET:
    906                         if (off >= 0) {
    907                                 file->pos = (aoff64_t) off;
    908                                 fibril_mutex_unlock(&file->lock);
    909                                 ipc_answer_1(rid, EOK, off);
    910                                 return;
    911                         }
    912                         break;
    913                 case SEEK_CUR:
    914                         if ((off >= 0) && (file->pos + off < file->pos)) {
    915                                 fibril_mutex_unlock(&file->lock);
    916                                 ipc_answer_0(rid, EOVERFLOW);
    917                                 return;
    918                         }
    919                        
    920                         if ((off < 0) && (file->pos < (aoff64_t) -off)) {
    921                                 fibril_mutex_unlock(&file->lock);
    922                                 ipc_answer_0(rid, EOVERFLOW);
    923                                 return;
    924                         }
    925                        
    926                         file->pos += off;
    927                         newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
    928                        
     913        case SEEK_SET:
     914                if (off >= 0) {
     915                        file->pos = (aoff64_t) off;
    929916                        fibril_mutex_unlock(&file->lock);
    930                         ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
    931                         return;
    932                 case SEEK_END:
    933                         fibril_rwlock_read_lock(&file->node->contents_rwlock);
    934                         aoff64_t size = file->node->size;
    935                        
    936                         if ((off >= 0) && (size + off < size)) {
    937                                 fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    938                                 fibril_mutex_unlock(&file->lock);
    939                                 ipc_answer_0(rid, EOVERFLOW);
    940                                 return;
    941                         }
    942                        
    943                         if ((off < 0) && (size < (aoff64_t) -off)) {
    944                                 fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    945                                 fibril_mutex_unlock(&file->lock);
    946                                 ipc_answer_0(rid, EOVERFLOW);
    947                                 return;
    948                         }
    949                        
    950                         file->pos = size + off;
    951                         newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
    952                        
     917                        ipc_answer_1(rid, EOK, off);
     918                        return;
     919                }
     920                break;
     921        case SEEK_CUR:
     922                if ((off >= 0) && (file->pos + off < file->pos)) {
     923                        fibril_mutex_unlock(&file->lock);
     924                        ipc_answer_0(rid, EOVERFLOW);
     925                        return;
     926                }
     927               
     928                if ((off < 0) && (file->pos < (aoff64_t) -off)) {
     929                        fibril_mutex_unlock(&file->lock);
     930                        ipc_answer_0(rid, EOVERFLOW);
     931                        return;
     932                }
     933               
     934                file->pos += off;
     935                newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
     936               
     937                fibril_mutex_unlock(&file->lock);
     938                ipc_answer_2(rid, EOK, LOWER32(newoff),
     939                    UPPER32(newoff));
     940                return;
     941        case SEEK_END:
     942                fibril_rwlock_read_lock(&file->node->contents_rwlock);
     943                aoff64_t size = file->node->size;
     944               
     945                if ((off >= 0) && (size + off < size)) {
    953946                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    954947                        fibril_mutex_unlock(&file->lock);
    955                         ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
    956                         return;
     948                        ipc_answer_0(rid, EOVERFLOW);
     949                        return;
     950                }
     951               
     952                if ((off < 0) && (size < (aoff64_t) -off)) {
     953                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
     954                        fibril_mutex_unlock(&file->lock);
     955                        ipc_answer_0(rid, EOVERFLOW);
     956                        return;
     957                }
     958               
     959                file->pos = size + off;
     960                newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
     961               
     962                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
     963                fibril_mutex_unlock(&file->lock);
     964                ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
     965                return;
    957966        }
    958967       
     
    964973    fs_index_t index, aoff64_t size)
    965974{
    966         ipcarg_t rc;
     975        sysarg_t rc;
    967976        int fs_phone;
    968977       
    969978        fs_phone = vfs_grab_phone(fs_handle);
    970         rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) devmap_handle,
    971             (ipcarg_t) index, LOWER32(size), UPPER32(size));
     979        rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (sysarg_t) devmap_handle,
     980            (sysarg_t) index, LOWER32(size), UPPER32(size));
    972981        vfs_release_phone(fs_handle, fs_phone);
    973982        return (int)rc;
     
    977986{
    978987        int fd = IPC_GET_ARG1(*request);
    979         aoff64_t size =
    980             (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
     988        aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
     989            IPC_GET_ARG3(*request));
    981990        int rc;
    982991
     
    9961005
    9971006        fibril_mutex_unlock(&file->lock);
    998         ipc_answer_0(rid, (ipcarg_t)rc);
     1007        ipc_answer_0(rid, (sysarg_t)rc);
    9991008}
    10001009
     
    10021011{
    10031012        int fd = IPC_GET_ARG1(*request);
    1004         ipcarg_t rc;
     1013        sysarg_t rc;
    10051014
    10061015        vfs_file_t *file = vfs_file_get(fd);
     
    10751084        ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    10761085       
    1077         ipcarg_t rv;
     1086        sysarg_t rv;
    10781087        async_wait_for(msg, &rv);
    10791088        vfs_release_phone(node->fs_handle, fs_phone);
Note: See TracChangeset for help on using the changeset viewer.