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


Ignore:
Timestamp:
2011-04-15T19:38:07Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9dd730d1
Parents:
6b9e85b (diff), b2fb47f (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

    r6b9e85b r8b655705  
    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                                                else
     394                                                        (void) ops->node_put(fn);
     395                                                async_answer_0(rid, rc);
    400396                                        } else {
    401397                                                aoff64_t size = ops->size_get(fn);
    402                                                 ipc_answer_5(rid, fs_handle,
     398                                                async_answer_5(rid, fs_handle,
    403399                                                    devmap_handle,
    404400                                                    ops->index_get(fn),
     
    409405                                        }
    410406                                } else
    411                                         ipc_answer_0(rid, ENOSPC);
     407                                        async_answer_0(rid, ENOSPC);
    412408                               
    413409                                goto out;
    414410                        }
    415411                       
    416                         ipc_answer_0(rid, ENOENT);
     412                        async_answer_0(rid, ENOENT);
    417413                        goto out;
    418414                }
     
    440436                if (lflag & (L_CREATE | L_LINK)) {
    441437                        if (!ops->is_directory(cur)) {
    442                                 ipc_answer_0(rid, ENOTDIR);
     438                                async_answer_0(rid, ENOTDIR);
    443439                                goto out;
    444440                        }
     
    449445                                if (ops->plb_get_char(next) == '/') {
    450446                                        /* More than one component */
    451                                         ipc_answer_0(rid, ENOENT);
     447                                        async_answer_0(rid, ENOENT);
    452448                                        goto out;
    453449                                }
     
    455451                                if (len + 1 == NAME_MAX) {
    456452                                        /* Component length overflow */
    457                                         ipc_answer_0(rid, ENAMETOOLONG);
     453                                        async_answer_0(rid, ENAMETOOLONG);
    458454                                        goto out;
    459455                                }
     
    479475                                        if (lflag & L_CREATE)
    480476                                                (void) ops->destroy(fn);
    481                                         ipc_answer_0(rid, rc);
     477                                        else
     478                                                (void) ops->node_put(fn);
     479                                        async_answer_0(rid, rc);
    482480                                } else {
    483481                                        aoff64_t size = ops->size_get(fn);
    484                                         ipc_answer_5(rid, fs_handle,
     482                                        async_answer_5(rid, fs_handle,
    485483                                            devmap_handle,
    486484                                            ops->index_get(fn),
     
    491489                                }
    492490                        } else
    493                                 ipc_answer_0(rid, ENOSPC);
     491                                async_answer_0(rid, ENOSPC);
    494492                       
    495493                        goto out;
    496494                }
    497495               
    498                 ipc_answer_0(rid, ENOENT);
     496                async_answer_0(rid, ENOENT);
    499497                goto out;
    500498        }
     
    509507                if (rc == EOK) {
    510508                        aoff64_t size = ops->size_get(cur);
    511                         ipc_answer_5(rid, fs_handle, devmap_handle,
     509                        async_answer_5(rid, fs_handle, devmap_handle,
    512510                            ops->index_get(cur), LOWER32(size), UPPER32(size),
    513511                            old_lnkcnt);
    514512                } else
    515                         ipc_answer_0(rid, rc);
     513                        async_answer_0(rid, rc);
    516514               
    517515                goto out;
     
    520518        if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) ||
    521519            (lflag & L_LINK)) {
    522                 ipc_answer_0(rid, EEXIST);
     520                async_answer_0(rid, EEXIST);
    523521                goto out;
    524522        }
    525523       
    526524        if ((lflag & L_FILE) && (ops->is_directory(cur))) {
    527                 ipc_answer_0(rid, EISDIR);
     525                async_answer_0(rid, EISDIR);
    528526                goto out;
    529527        }
    530528       
    531529        if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) {
    532                 ipc_answer_0(rid, ENOTDIR);
     530                async_answer_0(rid, ENOTDIR);
    533531                goto out;
    534532        }
    535533
    536534        if ((lflag & L_ROOT) && par) {
    537                 ipc_answer_0(rid, EINVAL);
     535                async_answer_0(rid, EINVAL);
    538536                goto out;
    539537        }
     
    547545                if (rc == EOK) {
    548546                        aoff64_t size = ops->size_get(cur);
    549                         ipc_answer_5(rid, fs_handle, devmap_handle,
     547                        async_answer_5(rid, fs_handle, devmap_handle,
    550548                            ops->index_get(cur), LOWER32(size), UPPER32(size),
    551549                            ops->lnkcnt_get(cur));
    552550                } else
    553                         ipc_answer_0(rid, rc);
     551                        async_answer_0(rid, rc);
    554552               
    555553        } else
    556                 ipc_answer_0(rid, rc);
     554                async_answer_0(rid, rc);
    557555       
    558556out:
     
    583581            (size != sizeof(struct stat))) {
    584582                ops->node_put(fn);
    585                 ipc_answer_0(callid, EINVAL);
    586                 ipc_answer_0(rid, EINVAL);
     583                async_answer_0(callid, EINVAL);
     584                async_answer_0(rid, EINVAL);
    587585                return;
    588586        }
     
    603601       
    604602        async_data_read_finalize(callid, &stat, sizeof(struct stat));
    605         ipc_answer_0(rid, EOK);
     603        async_answer_0(rid, EOK);
    606604}
    607605
     
    625623       
    626624        if (fn == NULL) {
    627                 ipc_answer_0(rid, ENOENT);
     625                async_answer_0(rid, ENOENT);
    628626                return;
    629627        }
     
    631629        rc = ops->node_open(fn);
    632630        aoff64_t size = ops->size_get(fn);
    633         ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
     631        async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
    634632            (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    635633       
Note: See TracChangeset for help on using the changeset viewer.