Changeset 44c0f5b in mainline


Ignore:
Timestamp:
2011-03-18T19:44:55Z (14 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fe4ac35
Parents:
8b86ed26
Message:

link function mfs_node_get() to the libfs_ops structure

Location:
uspace/srv/fs/minixfs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs.h

    r8b86ed26 r44c0f5b  
    104104extern bool mfs_is_file(fs_node_t *fsnode);
    105105extern devmap_handle_t mfs_device_get(fs_node_t *fsnode);
    106 extern int  mfs_get_instance(devmap_handle_t handle,
     106extern int mfs_instance_get(devmap_handle_t handle,
    107107                                struct mfs_instance **instance);
     108int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
     109                        fs_index_t index);
    108110
    109111/*mfs_inode.c*/
  • uspace/srv/fs/minixfs/mfs_ops.c

    r8b86ed26 r44c0f5b  
    4040static bool check_magic_number(uint16_t magic, bool *native,
    4141                                mfs_version_t *version, bool *longfilenames);
     42static int mfs_node_core_get(fs_node_t **rfn, struct mfs_instance *inst,
     43                        fs_index_t index);
    4244
    4345static LIST_INITIALIZE(inst_list);
     
    4749        .device_get = mfs_device_get,
    4850        .is_directory = mfs_is_directory,
    49         .is_file = mfs_is_file
     51        .is_file = mfs_is_file,
     52        .node_get = mfs_node_get
    5053};
    5154
     
    204207}
    205208
     209int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
     210                        fs_index_t index)
     211{
     212        int rc;
     213        struct mfs_instance *instance;
     214
     215        rc = mfs_instance_get(devmap_handle, &instance);
     216
     217        if (rc != EOK)
     218                return rc;
     219
     220        return mfs_node_core_get(rfn, instance, index);
     221}
     222
     223static int mfs_node_core_get(fs_node_t **rfn, struct mfs_instance *inst,
     224                        fs_index_t index)
     225{
     226        fs_node_t *node = NULL;
     227        struct mfs_node *mnode = NULL;
     228        int rc;
     229
     230        const struct mfs_sb_info *sbi = inst->sbi;
     231
     232        node = (fs_node_t *) malloc(sizeof(fs_node_t));
     233        if (!node) {
     234                rc = ENOMEM;
     235                goto out_err;
     236        }
     237
     238        fs_node_initialize(node);
     239
     240        mnode = (struct mfs_node *) malloc(sizeof(struct mfs_node));
     241        if (!mnode) {
     242                rc = ENOMEM;
     243                goto out_err;
     244        }
     245
     246        if (sbi->fs_version == MFS_VERSION_V1) {
     247                /*Read MFS V1 inode*/
     248                struct mfs_inode *ino;
     249
     250                ino = mfs_read_inode_raw(inst, index);
     251                mnode->ino = ino;
     252        } else {
     253                /*Read MFS V2/V3 inode*/
     254                struct mfs2_inode *ino2;
     255
     256                ino2 = mfs2_read_inode_raw(inst, index);
     257                mnode->ino2 = ino2;
     258        }
     259
     260        mnode->instance = inst;
     261        node->data = mnode;
     262        *rfn = node;
     263
     264        return EOK;
     265
     266out_err:
     267        if (node)
     268                free(node);
     269        if (mnode)
     270                free(mnode);
     271        return rc;
     272}
     273
    206274bool mfs_is_directory(fs_node_t *fsnode)
    207275{
    208         struct mfs_node *node = fsnode->data;
    209         struct mfs_sb_info *sbi = node->instance->sbi;
     276        const struct mfs_node *node = fsnode->data;
     277        const struct mfs_sb_info *sbi = node->instance->sbi;
    210278
    211279        if (sbi->fs_version == MFS_VERSION_V1)
     
    229297 * Find a filesystem instance given the devmap handle
    230298 */
    231 int mfs_get_instance(devmap_handle_t handle, struct mfs_instance **instance)
     299int mfs_instance_get(devmap_handle_t handle, struct mfs_instance **instance)
    232300{
    233301        link_t *link;
Note: See TracChangeset for help on using the changeset viewer.