Changeset 3b08178 in mainline for uspace/srv/fs/minixfs/mfs_ops.c


Ignore:
Timestamp:
2011-03-17T15:22:22Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e54ba607
Parents:
953a823
Message:

Initialize block cache and add a function to get a filesystem instance given the device handle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs_ops.c

    r953a823 r3b08178  
    3131 */
    3232
    33 #include <libfs.h>
    3433#include <stdio.h>
    3534#include <stdlib.h>
    36 #include <libblock.h>
    3735#include <fibril_synch.h>
    3836#include <errno.h>
    39 #include <adt/list.h>
    4037#include "mfs.h"
    4138#include "mfs_utils.h"
     
    4744static LIST_INITIALIZE(inst_list);
    4845static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex);
     46
     47libfs_ops_t mfs_libfs_ops;
    4948
    5049void mfs_mounted(ipc_callid_t rid, ipc_call_t *request)
     
    161160                sbi->max_file_size = conv32(native, sb->s_max_file_size);
    162161                sbi->nzones = conv16(native, sb->s_nzones);
     162                sbi->block_size = MFS_BLOCKSIZE;
    163163                if (version == MFS_VERSION_V2)
    164164                        sbi->nzones = conv32(native, sb->s_nzones2);
     
    166166 
    167167        free(sb);
     168
     169        rc = block_cache_init(devmap_handle, sbi->block_size, 0, CACHE_MODE_WT);
     170
     171        if (rc != EOK) {
     172                block_fini(devmap_handle);
     173                async_answer_0(rid, EINVAL);
     174                mfsdebug("block cache initialization failed\n");
     175                return;
     176        }
    168177
    169178        /*Initialize the instance structure and add it to the list*/
     
    181190}
    182191
     192void mfs_mount(ipc_callid_t rid, ipc_call_t *request)
     193{
     194        libfs_mount(&mfs_libfs_ops, mfs_reg.fs_handle, rid, request);
     195}
     196
     197/*
     198 * Find a filesystem instance given the devmap handle
     199 */
     200int mfs_get_instance(devmap_handle_t handle, struct mfs_instance **instance)
     201{
     202        link_t *link;
     203        struct mfs_instance *instance_ptr;
     204
     205        fibril_mutex_lock(&inst_list_mutex);
     206
     207        for (link = inst_list.next; link != &inst_list; link = link->next) {
     208                instance_ptr = list_get_instance(link, struct mfs_instance, link);
     209               
     210                if (instance_ptr->handle == handle) {
     211                        *instance = instance_ptr;
     212                        fibril_mutex_unlock(&inst_list_mutex);
     213                        return EOK;
     214                }
     215        }
     216
     217        mfsdebug("Instance not found\n");
     218
     219        fibril_mutex_unlock(&inst_list_mutex);
     220        return EINVAL;
     221}
     222
    183223static bool check_magic_number(uint16_t magic, bool *native,
    184224                                mfs_version_t *version, bool *longfilenames)
     
    213253}
    214254
    215 
    216255/**
    217256 * @}
Note: See TracChangeset for help on using the changeset viewer.