Changeset 8b5690f in mainline for uspace/lib/fs/libfs.c


Ignore:
Timestamp:
2011-02-03T05:11:01Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ba38f72c
Parents:
22027b6e (diff), 86d7bfa (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/lib/fs/libfs.c

    r22027b6e r8b5690f  
    4040#include <errno.h>
    4141#include <async.h>
    42 #include <ipc/ipc.h>
    4342#include <as.h>
    4443#include <assert.h>
     
    5857#define answer_and_return(rid, rc) \
    5958        do { \
    60                 ipc_answer_0((rid), (rc)); \
     59                async_answer_0((rid), (rc)); \
    6160                return; \
    6261        } while (0)
     
    102101         * Ask VFS for callback connection.
    103102         */
    104         ipc_connect_to_me(vfs_phone, 0, 0, 0, &reg->vfs_phonehash);
     103        async_connect_to_me(vfs_phone, 0, 0, 0, conn);
    105104       
    106105        /*
     
    127126        async_wait_for(req, NULL);
    128127        reg->fs_handle = (int) IPC_GET_ARG1(answer);
    129        
    130         /*
    131          * Create a connection fibril to handle the callback connection.
    132          */
    133         async_new_connection(reg->vfs_phonehash, 0, NULL, conn);
    134128       
    135129        /*
     
    165159        if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||
    166160            (mountee_phone < 0)) {
    167                 ipc_answer_0(callid, EINVAL);
    168                 ipc_answer_0(rid, EINVAL);
     161                async_answer_0(callid, EINVAL);
     162                async_answer_0(rid, EINVAL);
    169163                return;
    170164        }
    171165       
    172166        /* Acknowledge the mountee_phone */
    173         ipc_answer_0(callid, EOK);
     167        async_answer_0(callid, EOK);
    174168       
    175169        fs_node_t *fn;
    176170        res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
    177171        if ((res != EOK) || (!fn)) {
    178                 ipc_hangup(mountee_phone);
     172                async_hangup(mountee_phone);
    179173                async_data_write_void(combine_rc(res, ENOENT));
    180                 ipc_answer_0(rid, combine_rc(res, ENOENT));
     174                async_answer_0(rid, combine_rc(res, ENOENT));
    181175                return;
    182176        }
    183177       
    184178        if (fn->mp_data.mp_active) {
    185                 ipc_hangup(mountee_phone);
     179                async_hangup(mountee_phone);
    186180                (void) ops->node_put(fn);
    187181                async_data_write_void(EBUSY);
    188                 ipc_answer_0(rid, EBUSY);
     182                async_answer_0(rid, EBUSY);
    189183                return;
    190184        }
     
    192186        rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME);
    193187        if (rc != EOK) {
    194                 ipc_hangup(mountee_phone);
     188                async_hangup(mountee_phone);
    195189                (void) ops->node_put(fn);
    196190                async_data_write_void(rc);
    197                 ipc_answer_0(rid, rc);
     191                async_answer_0(rid, rc);
    198192                return;
    199193        }
     
    213207         * Do not release the FS node so that it stays in memory.
    214208         */
    215         ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
     209        async_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
    216210            IPC_GET_ARG3(answer));
    217211}
     
    226220        res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
    227221        if ((res != EOK) || (!fn)) {
    228                 ipc_answer_0(rid, combine_rc(res, ENOENT));
     222                async_answer_0(rid, combine_rc(res, ENOENT));
    229223                return;
    230224        }
     
    235229        if (!fn->mp_data.mp_active) {
    236230                (void) ops->node_put(fn);
    237                 ipc_answer_0(rid, EINVAL);
     231                async_answer_0(rid, EINVAL);
    238232                return;
    239233        }
     
    249243         */
    250244        if (res == EOK) {
    251                 ipc_hangup(fn->mp_data.phone);
     245                async_hangup(fn->mp_data.phone);
    252246                fn->mp_data.mp_active = false;
    253247                fn->mp_data.fs_handle = 0;
     
    259253
    260254        (void) ops->node_put(fn);
    261         ipc_answer_0(rid, res);
     255        async_answer_0(rid, res);
    262256}
    263257
     
    299293       
    300294        if (cur->mp_data.mp_active) {
    301                 ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
     295                async_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
    302296                    next, last, cur->mp_data.devmap_handle, lflag, index,
    303297                    IPC_FF_ROUTE_FROM_ME);
     
    323317                        if (len + 1 == NAME_MAX) {
    324318                                /* Component length overflow */
    325                                 ipc_answer_0(rid, ENAMETOOLONG);
     319                                async_answer_0(rid, ENAMETOOLONG);
    326320                                goto out;
    327321                        }
     
    357351                                next--;
    358352                       
    359                         ipc_forward_slow(rid, tmp->mp_data.phone,
     353                        async_forward_slow(rid, tmp->mp_data.phone,
    360354                            VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle,
    361355                            lflag, index, IPC_FF_ROUTE_FROM_ME);
     
    371365                        if (next <= last) {
    372366                                /* There are unprocessed components */
    373                                 ipc_answer_0(rid, ENOENT);
     367                                async_answer_0(rid, ENOENT);
    374368                                goto out;
    375369                        }
     
    379373                                /* Request to create a new link */
    380374                                if (!ops->is_directory(cur)) {
    381                                         ipc_answer_0(rid, ENOTDIR);
     375                                        async_answer_0(rid, ENOTDIR);
    382376                                        goto out;
    383377                                }
     
    397391                                                if (lflag & L_CREATE)
    398392                                                        (void) ops->destroy(fn);
    399                                                 ipc_answer_0(rid, rc);
     393                                                async_answer_0(rid, rc);
    400394                                        } else {
    401395                                                aoff64_t size = ops->size_get(fn);
    402                                                 ipc_answer_5(rid, fs_handle,
     396                                                async_answer_5(rid, fs_handle,
    403397                                                    devmap_handle,
    404398                                                    ops->index_get(fn),
     
    409403                                        }
    410404                                } else
    411                                         ipc_answer_0(rid, ENOSPC);
     405                                        async_answer_0(rid, ENOSPC);
    412406                               
    413407                                goto out;
    414408                        }
    415409                       
    416                         ipc_answer_0(rid, ENOENT);
     410                        async_answer_0(rid, ENOENT);
    417411                        goto out;
    418412                }
     
    440434                if (lflag & (L_CREATE | L_LINK)) {
    441435                        if (!ops->is_directory(cur)) {
    442                                 ipc_answer_0(rid, ENOTDIR);
     436                                async_answer_0(rid, ENOTDIR);
    443437                                goto out;
    444438                        }
     
    449443                                if (ops->plb_get_char(next) == '/') {
    450444                                        /* More than one component */
    451                                         ipc_answer_0(rid, ENOENT);
     445                                        async_answer_0(rid, ENOENT);
    452446                                        goto out;
    453447                                }
     
    455449                                if (len + 1 == NAME_MAX) {
    456450                                        /* Component length overflow */
    457                                         ipc_answer_0(rid, ENAMETOOLONG);
     451                                        async_answer_0(rid, ENAMETOOLONG);
    458452                                        goto out;
    459453                                }
     
    479473                                        if (lflag & L_CREATE)
    480474                                                (void) ops->destroy(fn);
    481                                         ipc_answer_0(rid, rc);
     475                                        async_answer_0(rid, rc);
    482476                                } else {
    483477                                        aoff64_t size = ops->size_get(fn);
    484                                         ipc_answer_5(rid, fs_handle,
     478                                        async_answer_5(rid, fs_handle,
    485479                                            devmap_handle,
    486480                                            ops->index_get(fn),
     
    491485                                }
    492486                        } else
    493                                 ipc_answer_0(rid, ENOSPC);
     487                                async_answer_0(rid, ENOSPC);
    494488                       
    495489                        goto out;
    496490                }
    497491               
    498                 ipc_answer_0(rid, ENOENT);
     492                async_answer_0(rid, ENOENT);
    499493                goto out;
    500494        }
     
    509503                if (rc == EOK) {
    510504                        aoff64_t size = ops->size_get(cur);
    511                         ipc_answer_5(rid, fs_handle, devmap_handle,
     505                        async_answer_5(rid, fs_handle, devmap_handle,
    512506                            ops->index_get(cur), LOWER32(size), UPPER32(size),
    513507                            old_lnkcnt);
    514508                } else
    515                         ipc_answer_0(rid, rc);
     509                        async_answer_0(rid, rc);
    516510               
    517511                goto out;
     
    520514        if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) ||
    521515            (lflag & L_LINK)) {
    522                 ipc_answer_0(rid, EEXIST);
     516                async_answer_0(rid, EEXIST);
    523517                goto out;
    524518        }
    525519       
    526520        if ((lflag & L_FILE) && (ops->is_directory(cur))) {
    527                 ipc_answer_0(rid, EISDIR);
     521                async_answer_0(rid, EISDIR);
    528522                goto out;
    529523        }
    530524       
    531525        if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) {
    532                 ipc_answer_0(rid, ENOTDIR);
     526                async_answer_0(rid, ENOTDIR);
    533527                goto out;
    534528        }
    535529
    536530        if ((lflag & L_ROOT) && par) {
    537                 ipc_answer_0(rid, EINVAL);
     531                async_answer_0(rid, EINVAL);
    538532                goto out;
    539533        }
     
    547541                if (rc == EOK) {
    548542                        aoff64_t size = ops->size_get(cur);
    549                         ipc_answer_5(rid, fs_handle, devmap_handle,
     543                        async_answer_5(rid, fs_handle, devmap_handle,
    550544                            ops->index_get(cur), LOWER32(size), UPPER32(size),
    551545                            ops->lnkcnt_get(cur));
    552546                } else
    553                         ipc_answer_0(rid, rc);
     547                        async_answer_0(rid, rc);
    554548               
    555549        } else
    556                 ipc_answer_0(rid, rc);
     550                async_answer_0(rid, rc);
    557551       
    558552out:
     
    583577            (size != sizeof(struct stat))) {
    584578                ops->node_put(fn);
    585                 ipc_answer_0(callid, EINVAL);
    586                 ipc_answer_0(rid, EINVAL);
     579                async_answer_0(callid, EINVAL);
     580                async_answer_0(rid, EINVAL);
    587581                return;
    588582        }
     
    603597       
    604598        async_data_read_finalize(callid, &stat, sizeof(struct stat));
    605         ipc_answer_0(rid, EOK);
     599        async_answer_0(rid, EOK);
    606600}
    607601
     
    625619       
    626620        if (fn == NULL) {
    627                 ipc_answer_0(rid, ENOENT);
     621                async_answer_0(rid, ENOENT);
    628622                return;
    629623        }
     
    631625        rc = ops->node_open(fn);
    632626        aoff64_t size = ops->size_get(fn);
    633         ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
     627        async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
    634628            (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    635629       
Note: See TracChangeset for help on using the changeset viewer.