Changeset 9c0c0e1 in mainline for uspace/srv/fs/ext4fs/ext4fs_ops.c


Ignore:
Timestamp:
2011-10-04T12:18:44Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a23297c
Parents:
01ab41b
Message:

part of code needed for successful mount (porting from ext2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    r01ab41b r9c0c0e1  
    4141#include <libfs.h>
    4242#include <malloc.h>
     43#include <stdio.h>
    4344#include <ipc/loc.h>
    4445#include "ext4fs.h"
     
    4647
    4748#define EXT4FS_NODE(node)       ((node) ? (ext4fs_node_t *) (node)->data : NULL)
     49#define EXT4FS_DBG(format, ...) {if (true) printf("ext4fs: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__);}
    4850
    4951typedef struct ext4fs_instance {
     
    6769static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **);
    6870static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t);
    69 
     71static int ext4fs_node_put_core(ext4fs_node_t *);
    7072
    7173/*
     
    120122 */
    121123
     124/**
     125 * TODO doxy
     126 */
    122127int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst)
    123128{
     
    145150}
    146151
     152/**
     153 * TODO doxy
     154 */
    147155int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id)
    148156{
     
    150158}
    151159
     160/**
     161 * TODO doxy
     162 */
    152163int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
    153164{
     
    156167}
    157168
     169/**
     170 * TODO doxy
     171 */
    158172int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
    159173{
    160         // TODO
    161         return 0;
    162 }
    163 
     174        ext4fs_instance_t *inst = NULL;
     175        int rc;
     176
     177        rc = ext4fs_instance_get(service_id, &inst);
     178        if (rc != EOK) {
     179                return rc;
     180        }
     181
     182        return ext4fs_node_get_core(rfn, inst, index);
     183}
     184
     185/**
     186 * TODO doxy
     187 */
    164188int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst,
    165189                fs_index_t index)
     
    172196 * TODO doxy
    173197 */
     198int ext4fs_node_put_core(ext4fs_node_t *enode) {
     199        // TODO
     200        return EOK;
     201}
     202
     203/**
     204 * TODO doxy
     205 */
    174206int ext4fs_node_open(fs_node_t *fn)
    175207{
     
    180212int ext4fs_node_put(fs_node_t *fn)
    181213{
    182         // TODO
     214        EXT4FS_DBG("");
     215        int rc;
     216        ext4fs_node_t *enode = EXT4FS_NODE(fn);
     217
     218        fibril_mutex_lock(&open_nodes_lock);
     219
     220        assert(enode->references > 0);
     221        enode->references--;
     222        if (enode->references == 0) {
     223                rc = ext4fs_node_put_core(enode);
     224                if (rc != EOK) {
     225                        fibril_mutex_unlock(&open_nodes_lock);
     226                        return rc;
     227                }
     228        }
     229
     230        fibril_mutex_unlock(&open_nodes_lock);
     231
    183232        return EOK;
    184233}
     
    278327 */
    279328
     329/**
     330 * TODO doxy
     331 */
    280332static int ext4fs_mounted(service_id_t service_id, const char *opts,
    281333   fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
    282334{
     335
     336        EXT4FS_DBG("Mounting...");
    283337
    284338        int rc;
     
    300354        }
    301355
    302         /* Initialize the filesystem  */
     356        EXT4FS_DBG("Basic structures allocated");
     357
     358        /* Initialize the filesystem */
    303359        rc = ext4_filesystem_init(fs, service_id);
    304360        if (rc != EOK) {
     
    307363                return rc;
    308364        }
     365
     366        EXT4FS_DBG("initialized");
    309367
    310368        /* Do some sanity checking */
     
    317375        }
    318376
     377        EXT4FS_DBG("Checked and clean");
     378
    319379        /* Check flags */
    320         rc = ext4_filesystem_check_flags(fs, &read_only);
     380        rc = ext4_filesystem_check_features(fs, &read_only);
    321381        if (rc != EOK) {
    322382                ext4_filesystem_fini(fs);
     
    326386        }
    327387
     388        EXT4FS_DBG("Features checked");
     389
    328390        /* Initialize instance */
    329391        link_initialize(&inst->link);
     
    332394        inst->open_nodes_count = 0;
    333395
     396        EXT4FS_DBG("Instance initialized");
     397
    334398        /* Read root node */
    335399        fs_node_t *root_node;
    336         rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);
     400        rc = ext4fs_root_get(&root_node, inst->service_id);
    337401        if (rc != EOK) {
    338402                ext4_filesystem_fini(fs);
     
    343407        ext4fs_node_t *enode = EXT4FS_NODE(root_node);
    344408
     409        EXT4FS_DBG("Root node found");
     410
    345411        /* Add instance to the list */
    346412        fibril_mutex_lock(&instance_list_mutex);
     
    348414        fibril_mutex_unlock(&instance_list_mutex);
    349415
     416        EXT4FS_DBG("Instance added");
     417
    350418        *index = EXT4_INODE_ROOT_INDEX;
    351419        *size = 0;
    352420        *lnkcnt = ext4_inode_get_usage_count(enode->inode_ref->inode);
    353421
     422        EXT4FS_DBG("Return values set");
     423
    354424        ext4fs_node_put(root_node);
    355425
    356         return EOK;
    357 }
    358 
     426        EXT4FS_DBG("Mounting finished");
     427
     428        return EOK;
     429}
     430
     431/**
     432 * TODO doxy
     433 */
    359434static int ext4fs_unmounted(service_id_t service_id)
    360435{
     
    388463}
    389464
     465/**
     466 * TODO doxy
     467 */
    390468static int
    391469ext4fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
     
    396474}
    397475
     476/**
     477 * TODO doxy
     478 */
    398479static int
    399480ext4fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
     
    404485}
    405486
     487/**
     488 * TODO doxy
     489 */
    406490static int
    407491ext4fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size)
     
    411495}
    412496
     497/**
     498 * TODO doxy
     499 */
    413500static int ext4fs_close(service_id_t service_id, fs_index_t index)
    414501{
     
    417504}
    418505
     506/**
     507 * TODO doxy
     508 */
    419509static int ext4fs_destroy(service_id_t service_id, fs_index_t index)
    420510{
     
    423513}
    424514
     515/**
     516 * TODO doxy
     517 */
    425518static int ext4fs_sync(service_id_t service_id, fs_index_t index)
    426519{
Note: See TracChangeset for help on using the changeset viewer.