Changeset 4bfad34 in mainline for uspace/lib/ext4/src/filesystem.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/filesystem.c

    r71fe4723 r4bfad34  
    3232 */
    3333/**
    34  * @file  libext4_filesystem.c
     34 * @file  filesystem.c
    3535 * @brief More complex filesystem operations.
    3636 */
     
    4242#include <crypto.h>
    4343#include <ipc/vfs.h>
     44#include <libfs.h>
    4445#include <stdlib.h>
    4546#include "ext4/balloc.h"
     
    5051#include "ext4/ialloc.h"
    5152#include "ext4/inode.h"
     53#include "ext4/ops.h"
    5254#include "ext4/superblock.h"
     55
     56static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
    5357
    5458/** Initialize filesystem and read all needed data.
     
    5660 * @param fs         Filesystem instance to be initialized
    5761 * @param service_id Identifier if device with the filesystem
    58  *
    59  * @return Error code
    60  *
    61  */
    62 int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,
    63     enum cache_mode cmode)
     62 * @param cmode      Cache mode
     63 * @param read_only  Place to store read only flag
     64 * @param index      Output value - index of root node
     65 * @param size       Output value - size of root node
     66 * @param lnkcnt     Output value - link count of root node
     67 *
     68 * @return Error code
     69 *
     70 */
     71int ext4_filesystem_init(ext4_filesystem_t *fs, ext4fs_instance_t *inst,
     72    service_id_t service_id, enum cache_mode cmode, aoff64_t *size)
    6473{
    6574        int rc;
     
    118127                goto err_2;
    119128
     129        /* Check flags */
     130        bool read_only;
     131        rc = ext4_filesystem_check_features(fs, &read_only);
     132        if (rc != EOK)
     133                goto err_2;
     134
     135        /* Read root node */
     136        fs_node_t *root_node;
     137        rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);
     138        if (rc != EOK)
     139                goto err_2;
     140
    120141        /* Mark system as mounted */
    121142        ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS);
    122143        rc = ext4_superblock_write_direct(fs->device, fs->superblock);
    123144        if (rc != EOK)
    124                 goto err_2;
     145                goto err_3;
    125146
    126147        uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock);
    127148        ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1);
    128149
     150        ext4fs_node_t *enode = EXT4FS_NODE(root_node);
     151       
     152        *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode);
     153
     154        ext4fs_node_put(root_node);
    129155        return EOK;
    130 
     156err_3:
     157        ext4fs_node_put(root_node);
    131158err_2:
    132159        block_cache_fini(fs->device);
     
    169196 *
    170197 * @param fs        Filesystem to be checked
    171  * @param read_only Flag if filesystem should be mounted only for reading
    172  *
    173  * @return Error code
    174  *
    175  */
    176 int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *read_only)
     198 * @param read_only Place to write flag saying whether filesystem
     199 *                  should be mounted only for reading
     200 *
     201 * @return Error code
     202 *
     203 */
     204static int ext4_filesystem_check_features(ext4_filesystem_t *fs,
     205    bool *read_only)
    177206{
    178207        /* Feature flags are present only in higher revisions */
Note: See TracChangeset for help on using the changeset viewer.