Changeset 4bfad34 in mainline for uspace/lib/ext4/src/ops.c


Ignore:
Timestamp:
2017-05-11T22:07:09Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be39fc6
Parents:
71fe4723
Message:

Move parts of ext4 filesystem initialization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/ops.c

    r71fe4723 r4bfad34  
    3232 */
    3333/**
    34  * @file  ext4fs_ops.c
     34 * @file  ops.c
    3535 * @brief Operations for ext4 filesystem.
    3636 */
     
    4646#include <ipc/loc.h>
    4747#include "ext4/ops.h"
    48 //#include "../../vfs/vfs.h"
    49 
    50 #define EXT4FS_NODE(node) \
    51         ((node) ? (ext4fs_node_t *) (node)->data : NULL)
    52 
    53 /**
    54  * Type for holding an instance of mounted partition.
    55  */
    56 typedef struct ext4fs_instance {
    57         link_t link;
    58         service_id_t service_id;
    59         ext4_filesystem_t *filesystem;
    60         unsigned int open_nodes_count;
    61 } ext4fs_instance_t;
    62 
    63 /**
    64  * Type for wrapping common fs_node and add some useful pointers.
    65  */
    66 typedef struct ext4fs_node {
    67         ext4fs_instance_t *instance;
    68         ext4_inode_ref_t *inode_ref;
    69         fs_node_t *fs_node;
    70         ht_link_t link;
    71         unsigned int references;
    72 } ext4fs_node_t;
     48#include "ext4/fstypes.h"
    7349
    7450/* Forward declarations of auxiliary functions */
     
    8056static bool ext4fs_is_dots(const uint8_t *, size_t);
    8157static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **);
    82 static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t);
    83 static int ext4fs_node_put_core(ext4fs_node_t *);
    8458
    8559/* Forward declarations of ext4 libfs operations. */
     
    8963static int ext4fs_node_get(fs_node_t **, service_id_t, fs_index_t);
    9064static int ext4fs_node_open(fs_node_t *);
    91 static int ext4fs_node_put(fs_node_t *);
     65      int ext4fs_node_put(fs_node_t *);
    9266static int ext4fs_create_node(fs_node_t **, service_id_t, int);
    9367static int ext4fs_destroy_node(fs_node_t *);
     
    373347 *
    374348 */
    375 int ext4fs_node_put_core(ext4fs_node_t *enode)
     349static int ext4fs_node_put_core(ext4fs_node_t *enode)
    376350{
    377351        hash_table_remove_item(&open_nodes, &enode->link);
     
    966940                cmode = CACHE_MODE_WB;
    967941       
    968         /* Initialize the filesystem */
    969         int rc = ext4_filesystem_init(fs, service_id, cmode);
    970         if (rc != EOK) {
    971                 free(fs);
    972                 free(inst);
    973                 return rc;
    974         }
    975        
    976         /* Check flags */
    977         bool read_only;
    978         rc = ext4_filesystem_check_features(fs, &read_only);
    979         if (rc != EOK) {
    980                 ext4_filesystem_fini(fs);
    981                 free(fs);
    982                 free(inst);
    983                 return rc;
    984         }
    985        
    986942        /* Initialize instance */
    987943        link_initialize(&inst->link);
     
    990946        inst->open_nodes_count = 0;
    991947       
    992         /* Read root node */
    993         fs_node_t *root_node;
    994         rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);
    995         if (rc != EOK) {
    996                 ext4_filesystem_fini(fs);
     948        /* Initialize the filesystem */
     949        aoff64_t rnsize;
     950        int rc = ext4_filesystem_init(fs, inst, service_id, cmode, &rnsize);
     951        if (rc != EOK) {
    997952                free(fs);
    998953                free(inst);
     
    1005960        fibril_mutex_unlock(&instance_list_mutex);
    1006961       
    1007         ext4fs_node_t *enode = EXT4FS_NODE(root_node);
    1008        
    1009962        *index = EXT4_INODE_ROOT_INDEX;
    1010         *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode);
     963        *size = rnsize;
    1011964        *lnkcnt = 1;
    1012965       
    1013         return ext4fs_node_put(root_node);
     966        return EOK;
    1014967}
    1015968
Note: See TracChangeset for help on using the changeset viewer.