Changeset eb27ce5a in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2008-01-09T19:50:40Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4fb6bf36
Parents:
cad9c72
Message:

Improve the API for converting (VFS triplets, size) to VFS nodes by introducing
a new type for results of vfs_lookup_internal().

File:
1 edited

Legend:

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

    rcad9c72 reb27ce5a  
    7171 * @param path          Path to be resolved; it needn't be an ASCIIZ string.
    7272 * @param len           Number of path characters pointed by path.
    73  * @param result        Empty node structure where the result will be stored.
    74  * @param size          Storage where the size of the node will be stored. Can
    75  *                      be NULL.
     73 * @param result        Empty structure where the lookup result will be stored.
    7674 * @param altroot       If non-empty, will be used instead of rootfs as the root
    7775 *                      of the whole VFS tree.
     
    7977 * @return              EOK on success or an error code from errno.h.
    8078 */
    81 int vfs_lookup_internal(char *path, size_t len, vfs_triplet_t *result,
    82     size_t *size, vfs_pair_t *altroot)
     79int vfs_lookup_internal(char *path, size_t len, vfs_lookup_res_t *result,
     80    vfs_pair_t *altroot)
    8381{
    8482        vfs_pair_t *root;
     
    180178
    181179        if (rc == EOK) {
    182                 result->fs_handle = (int) IPC_GET_ARG1(answer);
    183                 result->dev_handle = (int) IPC_GET_ARG2(answer);
    184                 result->index = (int) IPC_GET_ARG3(answer);
    185                 if (size)
    186                         *size = (size_t) IPC_GET_ARG4(answer);
     180                result->triplet.fs_handle = (int) IPC_GET_ARG1(answer);
     181                result->triplet.dev_handle = (int) IPC_GET_ARG2(answer);
     182                result->triplet.index = (int) IPC_GET_ARG3(answer);
     183                result->size = (size_t) IPC_GET_ARG4(answer);
    187184        }
    188185
     
    197194};
    198195
    199 static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root,
    200     size_t *size)
     196static int lookup_root(int fs_handle, int dev_handle, vfs_lookup_res_t *result)
    201197{
    202198        vfs_pair_t altroot = {
     
    205201        };
    206202
    207         return vfs_lookup_internal("/", strlen("/"), root, size, &altroot);
     203        return vfs_lookup_internal("/", strlen("/"), result, &altroot);
    208204}
    209205
     
    305301         */
    306302        int rc;
    307         vfs_triplet_t mounted_root;
    308         size_t mrsz;
    309         rc = lookup_root(fs_handle, dev_handle, &mounted_root, &mrsz);
     303        vfs_lookup_res_t mr_res;
     304        rc = lookup_root(fs_handle, dev_handle, &mr_res);
    310305        if (rc != EOK) {
    311306                free(buf);
     
    313308                return;
    314309        }
    315         vfs_node_t *mr_node = vfs_node_get(&mounted_root, mrsz);
     310        vfs_node_t *mr_node = vfs_node_get(&mr_res);
    316311        if (!mr_node) {
    317312                free(buf);
     
    323318         * Finally, we need to resolve the path to the mountpoint.
    324319         */
    325         vfs_triplet_t mp;
    326         size_t mpsz;
     320        vfs_lookup_res_t mp_res;
    327321        futex_down(&rootfs_futex);
    328322        if (rootfs.fs_handle) {
     
    331325                 */
    332326                rwlock_write_lock(&namespace_rwlock);
    333                 rc = vfs_lookup_internal(buf, size, &mp, &mpsz, NULL);
     327                rc = vfs_lookup_internal(buf, size, &mp_res, NULL);
    334328                if (rc != EOK) {
    335329                        /*
     
    343337                        return;
    344338                }
    345                 mp_node = vfs_node_get(&mp, mpsz);
     339                mp_node = vfs_node_get(&mp_res);
    346340                if (!mp_node) {
    347341                        rwlock_write_unlock(&namespace_rwlock);
     
    366360                         * For this simple, but important case, we are done.
    367361                         */
    368                         rootfs = mounted_root;
     362                        rootfs = mr_res.triplet;
    369363                        futex_up(&rootfs_futex);
    370364                        free(buf);
     
    393387         */
    394388
    395         int phone = vfs_grab_phone(mp.fs_handle);
     389        int phone = vfs_grab_phone(mp_res.triplet.fs_handle);
    396390        /* Later we can use ARG3 to pass mode/flags. */
    397         aid_t req1 = async_send_3(phone, VFS_MOUNT, (ipcarg_t) mp.dev_handle,
    398             (ipcarg_t) mp.index, 0, NULL);
     391        aid_t req1 = async_send_3(phone, VFS_MOUNT,
     392            (ipcarg_t) mp_res.triplet.dev_handle,
     393            (ipcarg_t) mp_res.triplet.index, 0, NULL);
    399394        /* The second call uses the same method. */
    400395        aid_t req2 = async_send_3(phone, VFS_MOUNT,
    401             (ipcarg_t) mounted_root.fs_handle,
    402             (ipcarg_t) mounted_root.dev_handle, (ipcarg_t) mounted_root.index,
    403             NULL);
     396            (ipcarg_t) mr_res.triplet.fs_handle,
     397            (ipcarg_t) mr_res.triplet.dev_handle,
     398            (ipcarg_t) mr_res.triplet.index, NULL);
    404399        vfs_release_phone(phone);
    405400
     
    479474         * The path is now populated and we can call vfs_lookup_internal().
    480475         */
    481         vfs_triplet_t triplet;
    482         size_t size;
    483         rc = vfs_lookup_internal(path, len, &triplet, &size, NULL);
     476        vfs_lookup_res_t lr;
     477        rc = vfs_lookup_internal(path, len, &lr, NULL);
    484478        if (rc) {
    485479                rwlock_read_unlock(&namespace_rwlock);
     
    494488        free(path);
    495489
    496         vfs_node_t *node = vfs_node_get(&triplet, size);
     490        vfs_node_t *node = vfs_node_get(&lr);
    497491        rwlock_read_unlock(&namespace_rwlock);
    498492
Note: See TracChangeset for help on using the changeset viewer.