Changeset 10e4cd7 in mainline for uspace/lib/c/generic/vfs/vfs.c


Ignore:
Timestamp:
2011-11-03T21:45:35Z (14 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
76a67ce
Parents:
3ce78580
Message:

Initial implementation of vfs mtab_read support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/vfs.c

    r3ce78580 r10e4cd7  
    3535#include <vfs/canonify.h>
    3636#include <vfs/vfs.h>
     37#include <vfs/vfs_mtab.h>
    3738#include <vfs/vfs_sess.h>
    3839#include <macros.h>
     
    831832}
    832833
     834int get_mtab_list(list_t *mtab_list)
     835{
     836        sysarg_t rc;
     837        size_t i;
     838        size_t num_mounted_fs;
     839       
     840        async_exch_t *exch = vfs_exchange_begin();
     841
     842        rc = async_req_0_0(exch, VFS_IN_GET_MTAB);
     843        if (rc != EOK)
     844                goto exit;
     845
     846        /* Ask VFS how many filesystems are mounted */
     847        rc = async_req_0_1(exch, VFS_IN_PING, &num_mounted_fs);
     848        if (rc != EOK)
     849                goto exit;
     850
     851        for (i = 0; i < num_mounted_fs; ++i) {
     852                mtab_list_ent_t *mtab_list_ent;
     853                mtab_ent_t *mtab_ent;
     854
     855                mtab_list_ent = malloc(sizeof(mtab_list_ent_t));
     856                if (!mtab_list_ent) {
     857                        rc = ENOMEM;
     858                        goto exit;
     859                }
     860
     861                mtab_ent = &mtab_list_ent->mtab_ent;
     862
     863                rc = async_data_read_start(exch, (void *) &mtab_ent->mp,
     864                    MAX_PATH_LEN);
     865                if (rc != EOK)
     866                        goto exit;
     867
     868                rc = async_data_read_start(exch, (void *) &mtab_ent->opts,
     869                        MAX_MNTOPTS_LEN);
     870                if (rc != EOK)
     871                        goto exit;
     872
     873                rc = async_data_read_start(exch, (void *) &mtab_ent->fs_name,
     874                        FS_NAME_MAXLEN);
     875                if (rc != EOK)
     876                        goto exit;
     877
     878                sysarg_t p[3];
     879                int j;
     880
     881                for (j = 0; j < 3; ++j) {
     882                        rc = async_req_0_1(exch, VFS_IN_PING, &p[j]);
     883                        if (rc != EOK)
     884                                goto exit;
     885                }
     886
     887                mtab_ent->flags = p[0];
     888                mtab_ent->instance = p[1];
     889                mtab_ent->fs_handle = p[2];
     890
     891                link_initialize(&mtab_list_ent->link);
     892                list_append(&mtab_list_ent->link, mtab_list);
     893        }
     894
     895exit:
     896        vfs_exchange_end(exch);
     897        return rc;
     898}
     899
    833900/** @}
    834901 */
Note: See TracChangeset for help on using the changeset viewer.