Changeset 677745a in mainline


Ignore:
Timestamp:
2013-07-29T12:54:39Z (11 years ago)
Author:
Jiri Zarevucky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5bcd5b7
Parents:
b7c62a9
Message:

Have lookup return the last found directory, and the portion of path traversed. In exchange, only size < 2GB is returned from lookup.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/ipc/vfs.h

    rb7c62a9 r677745a  
    9494        VFS_OUT_UNMOUNT,
    9595        VFS_OUT_UNMOUNTED,
     96        VFS_OUT_GET_SIZE,
    9697        VFS_OUT_SYNC,
    9798        VFS_OUT_STAT,
  • uspace/lib/fs/libfs.c

    rb7c62a9 r677745a  
    238238}
    239239
     240static void vfs_out_get_size(ipc_callid_t rid, ipc_call_t *req)
     241{
     242        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     243        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     244        int rc;
     245
     246        fs_node_t *node = NULL;
     247        rc = libfs_ops->node_get(&node, service_id, index);
     248        if (rc != EOK) {
     249                async_answer_0(rid, rc);
     250        }
     251        if (node == NULL) {
     252                async_answer_0(rid, EINVAL);
     253        }
     254       
     255        uint64_t size = libfs_ops->size_get(node);
     256        libfs_ops->node_put(node);
     257       
     258        async_answer_2(rid, EOK, LOWER32(size), UPPER32(size));
     259}
     260
    240261static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    241262{
     
    299320                        vfs_out_sync(callid, &call);
    300321                        break;
     322                case VFS_OUT_GET_SIZE:
     323                        vfs_out_get_size(callid, &call);
     324                        break;
    301325                default:
    302326                        async_answer_0(callid, ENOTSUP);
     
    657681        /* Find the file and its parent. */
    658682       
     683        unsigned last_next = 0;
     684       
    659685        while (next != last) {
    660686                if (cur == NULL) {
    661                         async_answer_0(rid, ENOENT);
    662                         LOG_EXIT(ENOENT);
    663                         goto out;
    664                 }
     687                        assert(par != NULL);
     688                        goto out1;
     689                }
     690
    665691                if (!ops->is_directory(cur)) {
    666692                        async_answer_0(rid, ENOTDIR);
     
    669695                }
    670696               
     697                last_next = next;
    671698                /* Collect the component */
    672699                rc = plb_get_component(component, &clen, &next, last);
     
    773800                rc = ops->unlink(par, cur, component);
    774801                if (rc == EOK) {
    775                         aoff64_t size = ops->size_get(cur);
     802                        int64_t size = ops->size_get(cur);
     803                        int32_t lsize = LOWER32(size);
     804                        if (lsize != size) {
     805                                lsize = -1;
     806                        }
     807                       
    776808                        async_answer_5(rid, fs_handle, service_id,
    777                             ops->index_get(cur), LOWER32(size), UPPER32(size),
     809                            ops->index_get(cur), last, lsize,
    778810                            ops->is_directory(cur) ? VFS_NODE_DIRECTORY : VFS_NODE_FILE);
    779811                        LOG_EXIT(EOK);
     
    819851       
    820852        /* Return. */
    821        
     853out1:
    822854        if (!cur) {
     855                async_answer_5(rid, fs_handle, service_id,
     856                        ops->index_get(par), last_next, -1, VFS_NODE_DIRECTORY);
     857                LOG_EXIT(EOK);
     858                /*
    823859                async_answer_0(rid, ENOENT);
    824860                LOG_EXIT(ENOENT);
     861                */
    825862                goto out;
    826863        }
     
    835872        }
    836873       
    837         aoff64_t size = ops->size_get(cur);
     874        int64_t size = ops->size_get(cur);
     875        int32_t lsize = LOWER32(size);
     876        if (lsize != size) {
     877                lsize = -1;
     878        }
     879       
    838880        async_answer_5(rid, fs_handle, service_id,
    839                 ops->index_get(cur), LOWER32(size), UPPER32(size),
     881                ops->index_get(cur), last, lsize,
    840882                ops->is_directory(cur) ? VFS_NODE_DIRECTORY : VFS_NODE_FILE);
    841883       
  • uspace/srv/vfs/vfs.h

    rb7c62a9 r677745a  
    113113        vfs_node_type_t type;   /**< Partial info about the node type. */
    114114
    115         aoff64_t size;          /**< Cached size if the node is a file. */
     115        int64_t size;           /**< Cached size if the node is a file. */
    116116
    117117        /**
     
    185185extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, service_id_t);
    186186
     187int64_t vfs_node_get_size(vfs_node_t *node);
    187188
    188189#define MAX_OPEN_FILES  128
  • uspace/srv/vfs/vfs_lookup.c

    rb7c62a9 r677745a  
    270270        }
    271271       
     272        unsigned last = IPC_GET_ARG3(answer);
     273        if (last != first + len) {
     274                /* The path wasn't processed entirely. */
     275                rc = ENOENT;
     276                goto out;
     277        }
     278       
    272279        if (!result) {
    273280                rc = EOK;
     
    278285        result->triplet.service_id = (service_id_t) IPC_GET_ARG1(answer);
    279286        result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer);
    280         result->size =
    281             (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(answer), IPC_GET_ARG4(answer));
     287        result->size = (int64_t)(int32_t) IPC_GET_ARG4(answer);
    282288        result->type = IPC_GET_ARG5(answer);
    283289        rc = EOK;
  • uspace/srv/vfs/vfs_node.c

    rb7c62a9 r677745a  
    4545#include <async.h>
    4646#include <errno.h>
     47#include <macros.h>
    4748
    4849/** Mutex protecting the VFS node hash table. */
     
    300301}
    301302
     303int64_t vfs_node_get_size(vfs_node_t *node)
     304{
     305        if (node->size == -1) {
     306                sysarg_t sz1 = 0;
     307                sysarg_t sz2 = 0;
     308               
     309                async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
     310                (void) async_req_2_2(exch, VFS_OUT_GET_SIZE,
     311                        node->service_id, node->index, &sz1, &sz2);
     312                vfs_exchange_release(exch);
     313               
     314                node->size = MERGE_LOUP32(sz1, sz2);
     315        }
     316        return node->size;
     317}
     318
    302319/**
    303320 * @}
  • uspace/srv/vfs/vfs_ops.c

    rb7c62a9 r677745a  
    840840        } else {
    841841                if (file->append)
    842                         file->pos = file->node->size;
     842                        file->pos = vfs_node_get_size(file->node);
    843843               
    844844                rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE,
     
    942942        case SEEK_END:
    943943                fibril_rwlock_read_lock(&file->node->contents_rwlock);
    944                 aoff64_t size = file->node->size;
     944                aoff64_t size = vfs_node_get_size(file->node);
    945945               
    946946                if ((off >= 0) && (size + off < size)) {
Note: See TracChangeset for help on using the changeset viewer.