Changes in uspace/lib/fs/libfs.c [1b20da0:a35b458] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/fs/libfs.c

    r1b20da0 ra35b458  
    8686        errno_t rc;
    8787        vfs_fs_probe_info_t info;
    88        
     88
    8989        ipc_callid_t callid;
    9090        size_t size;
     
    9595                return;
    9696        }
    97        
     97
    9898        memset(&info, 0, sizeof(info));
    9999        rc = vfs_out_ops->fsprobe(service_id, &info);
     
    103103                return;
    104104        }
    105        
     105
    106106        async_data_read_finalize(callid, &info, sizeof(info));
    107107        async_answer_0(rid, EOK);
     
    113113        char *opts;
    114114        errno_t rc;
    115        
     115
    116116        /* Accept the mount options. */
    117117        rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
     
    268268        if (node == NULL)
    269269                async_answer_0(rid, EINVAL);
    270        
     270
    271271        bool children = false;
    272272        rc = libfs_ops->has_children(&children, node);
    273273        libfs_ops->node_put(node);
    274        
     274
    275275        if (rc != EOK)
    276276                async_answer_0(rid, rc);
     
    288288                async_answer_0(iid, EOK);
    289289        }
    290        
     290
    291291        while (true) {
    292292                ipc_call_t call;
    293293                ipc_callid_t callid = async_get_call(&call);
    294                
     294
    295295                if (!IPC_GET_IMETHOD(call))
    296296                        return;
    297                
     297
    298298                switch (IPC_GET_IMETHOD(call)) {
    299299                case VFS_OUT_FSPROBE:
     
    372372         * out-of-order, when it knows that the operation succeeded or failed.
    373373         */
    374        
     374
    375375        async_exch_t *exch = async_exchange_begin(sess);
    376        
     376
    377377        ipc_call_t answer;
    378378        aid_t req = async_send_0(exch, VFS_IN_REGISTER, &answer);
    379        
     379
    380380        /*
    381381         * Send our VFS info structure to VFS.
    382382         */
    383383        errno_t rc = async_data_write_start(exch, info, sizeof(*info));
    384        
     384
    385385        if (rc != EOK) {
    386386                async_exchange_end(exch);
     
    388388                return rc;
    389389        }
    390        
     390
    391391        /*
    392392         * Set VFS_OUT and libfs operations.
     
    403403        rc = async_create_callback_port(exch, INTERFACE_VFS_DRIVER_CB, 0, 0,
    404404            vfs_connection, NULL, &port);
    405        
     405
    406406        /*
    407407         * Request sharing the Path Lookup Buffer with VFS.
     
    413413                return ENOMEM;
    414414        }
    415        
     415
    416416        async_exchange_end(exch);
    417        
     417
    418418        if (rc) {
    419419                async_forget(req);
    420420                return rc;
    421421        }
    422          
     422
    423423        /*
    424424         * Pick up the answer for the request to the VFS_IN_REQUEST call.
     
    426426        async_wait_for(req, NULL);
    427427        reg.fs_handle = (int) IPC_GET_ARG1(answer);
    428        
     428
    429429        /*
    430430         * Tell the async framework that other connections are to be handled by
     
    432432         */
    433433        async_set_fallback_port_handler(vfs_connection, NULL);
    434        
     434
    435435        return IPC_GET_RETVAL(answer);
    436436}
     
    451451        unsigned pos = *ppos;
    452452        unsigned size = 0;
    453        
     453
    454454        if (pos == last) {
    455455                *sz = 0;
     
    460460        if (c == '/')
    461461                pos++;
    462        
     462
    463463        for (int i = 0; i <= NAME_MAX; i++) {
    464464                c = plb_get_char(pos);
     
    480480        size_t size;
    481481        ipc_callid_t wcall;
    482        
     482
    483483        if (!async_data_write_receive(&wcall, &size))
    484484                return ENOENT;
     
    498498        fs_index_t parent_index = IPC_GET_ARG2(*req);
    499499        fs_index_t child_index = IPC_GET_ARG3(*req);
    500        
     500
    501501        char component[NAME_MAX + 1];
    502502        errno_t rc = receive_fname(component);
     
    512512                return;
    513513        }
    514        
     514
    515515        fs_node_t *child = NULL;
    516516        rc = ops->node_get(&child, parent_sid, child_index);
     
    520520                return;
    521521        }
    522        
     522
    523523        rc = ops->link(parent, child, component);
    524524        ops->node_put(parent);
     
    548548        fs_index_t index = IPC_GET_ARG4(*req);
    549549        int lflag = IPC_GET_ARG5(*req);
    550        
     550
    551551        // TODO: Validate flags.
    552        
     552
    553553        unsigned next = first;
    554554        unsigned last = first + len;
    555        
     555
    556556        char component[NAME_MAX + 1];
    557557        errno_t rc;
    558        
     558
    559559        fs_node_t *par = NULL;
    560560        fs_node_t *cur = NULL;
    561561        fs_node_t *tmp = NULL;
    562562        unsigned clen = 0;
    563        
     563
    564564        rc = ops->node_get(&cur, service_id, index);
    565565        if (rc != EOK) {
     
    567567                goto out;
    568568        }
    569        
     569
    570570        assert(cur != NULL);
    571        
     571
    572572        /* Find the file and its parent. */
    573        
     573
    574574        unsigned last_next = 0;
    575        
     575
    576576        while (next != last) {
    577577                if (cur == NULL) {
     
    584584                        goto out;
    585585                }
    586                
     586
    587587                last_next = next;
    588588                /* Collect the component */
     
    593593                        goto out;
    594594                }
    595                
     595
    596596                if (clen == 0) {
    597597                        /* The path is just "/". */
    598598                        break;
    599599                }
    600                
     600
    601601                assert(component[clen] == 0);
    602                
     602
    603603                /* Match the component */
    604604                rc = ops->match(&tmp, cur, component);
     
    607607                        goto out;
    608608                }
    609                
     609
    610610                /* Descend one level */
    611611                if (par) {
     
    616616                        }
    617617                }
    618                
     618
    619619                par = cur;
    620620                cur = tmp;
    621621                tmp = NULL;
    622622        }
    623        
     623
    624624        /* At this point, par is either NULL or a directory.
    625625         * If cur is NULL, the looked up file does not exist yet.
    626626         */
    627          
     627
    628628        assert(par == NULL || ops->is_directory(par));
    629629        assert(par != NULL || cur != NULL);
    630        
     630
    631631        /* Check for some error conditions. */
    632        
     632
    633633        if (cur && (lflag & L_FILE) && (ops->is_directory(cur))) {
    634634                async_answer_0(rid, EISDIR);
    635635                goto out;
    636636        }
    637        
     637
    638638        if (cur && (lflag & L_DIRECTORY) && (ops->is_file(cur))) {
    639639                async_answer_0(rid, ENOTDIR);
    640640                goto out;
    641641        }
    642        
     642
    643643        /* Unlink. */
    644        
     644
    645645        if (lflag & L_UNLINK) {
    646646                if (!cur) {
     
    652652                        goto out;
    653653                }
    654                
     654
    655655                rc = ops->unlink(par, cur, component);
    656656                if (rc == EOK) {
     
    665665                goto out;
    666666        }
    667        
     667
    668668        /* Create. */
    669        
     669
    670670        if (lflag & L_CREATE) {
    671671                if (cur && (lflag & L_EXCLUSIVE)) {
     
    673673                        goto out;
    674674                }
    675        
     675
    676676                if (!cur) {
    677677                        rc = ops->create(&cur, service_id,
     
    685685                                goto out;
    686686                        }
    687                        
     687
    688688                        rc = ops->link(par, cur, component);
    689689                        if (rc != EOK) {
     
    695695                }
    696696        }
    697        
     697
    698698        /* Return. */
    699699out1:
     
    704704                goto out;
    705705        }
    706        
     706
    707707        async_answer_5(rid, EOK, fs_handle, ops->index_get(cur),
    708708            (ops->is_directory(cur) << 16) | last, LOWER32(ops->size_get(cur)),
    709709            UPPER32(ops->size_get(cur)));
    710        
     710
    711711out:
    712712        if (par)
    713713                (void) ops->node_put(par);
    714        
     714
    715715        if (cur)
    716716                (void) ops->node_put(cur);
    717        
     717
    718718        if (tmp)
    719719                (void) ops->node_put(tmp);
     
    824824        service_id_t service_id = IPC_GET_ARG1(*request);
    825825        fs_index_t index = IPC_GET_ARG2(*request);
    826        
     826
    827827        fs_node_t *fn;
    828828        errno_t rc = ops->node_get(&fn, service_id, index);
    829829        on_error(rc, answer_and_return(rid, rc));
    830        
     830
    831831        if (fn == NULL) {
    832832                async_answer_0(rid, ENOENT);
    833833                return;
    834834        }
    835        
     835
    836836        rc = ops->node_open(fn);
    837837        aoff64_t size = ops->size_get(fn);
     
    840840            (ops->is_file(fn) ? L_FILE : 0) |
    841841            (ops->is_directory(fn) ? L_DIRECTORY : 0));
    842        
     842
    843843        (void) ops->node_put(fn);
    844844}
Note: See TracChangeset for help on using the changeset viewer.