Ignore:
File:
1 edited

Legend:

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

    r991f645 r3a4b3ba  
    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/**
     
    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);
     
    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) {
     
    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. */
     
    834837        ipc_call_t answer;
    835838        if (read) {
    836                 if (file->append)
    837                         file->pos = file->node->size;
    838                
    839839                rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ,
    840840                    file->node->devmap_handle, file->node->index, file->pos,
    841841                    &answer);
    842842        } else {
     843                if (file->append)
     844                        file->pos = file->node->size;
     845               
    843846                rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE,
    844847                    file->node->devmap_handle, file->node->index, file->pos,
     
    888891{
    889892        int fd = (int) IPC_GET_ARG1(*request);
    890         off64_t off =
    891             (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
     893        off64_t off = (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
     894            IPC_GET_ARG3(*request));
    892895        int whence = (int) IPC_GET_ARG4(*request);
    893896       
     
    903906        off64_t newoff;
    904907        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                        
     908        case SEEK_SET:
     909                if (off >= 0) {
     910                        file->pos = (aoff64_t) off;
    929911                        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                        
     912                        ipc_answer_1(rid, EOK, off);
     913                        return;
     914                }
     915                break;
     916        case SEEK_CUR:
     917                if ((off >= 0) && (file->pos + off < file->pos)) {
     918                        fibril_mutex_unlock(&file->lock);
     919                        ipc_answer_0(rid, EOVERFLOW);
     920                        return;
     921                }
     922               
     923                if ((off < 0) && (file->pos < (aoff64_t) -off)) {
     924                        fibril_mutex_unlock(&file->lock);
     925                        ipc_answer_0(rid, EOVERFLOW);
     926                        return;
     927                }
     928               
     929                file->pos += off;
     930                newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
     931               
     932                fibril_mutex_unlock(&file->lock);
     933                ipc_answer_2(rid, EOK, LOWER32(newoff),
     934                    UPPER32(newoff));
     935                return;
     936        case SEEK_END:
     937                fibril_rwlock_read_lock(&file->node->contents_rwlock);
     938                aoff64_t size = file->node->size;
     939               
     940                if ((off >= 0) && (size + off < size)) {
    953941                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    954942                        fibril_mutex_unlock(&file->lock);
    955                         ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
    956                         return;
     943                        ipc_answer_0(rid, EOVERFLOW);
     944                        return;
     945                }
     946               
     947                if ((off < 0) && (size < (aoff64_t) -off)) {
     948                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
     949                        fibril_mutex_unlock(&file->lock);
     950                        ipc_answer_0(rid, EOVERFLOW);
     951                        return;
     952                }
     953               
     954                file->pos = size + off;
     955                newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
     956               
     957                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
     958                fibril_mutex_unlock(&file->lock);
     959                ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
     960                return;
    957961        }
    958962       
     
    977981{
    978982        int fd = IPC_GET_ARG1(*request);
    979         aoff64_t size =
    980             (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
     983        aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request),
     984            IPC_GET_ARG3(*request));
    981985        int rc;
    982986
Note: See TracChangeset for help on using the changeset viewer.