Changes in / [02082f3:e48947e] in mainline


Ignore:
Location:
uspace
Files:
1 added
1 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    r02082f3 re48947e  
    316316        }
    317317       
    318         /* Make sure tmpfs is running. */
     318        /* Make sure file systems are running. */
    319319        if (str_cmp(STRING(RDFMT), "tmpfs") != 0)
    320320                srv_start("/srv/tmpfs");
    321        
     321        if (str_cmp(STRING(RDFMT), "exfat") != 0)
     322                srv_start("/srv/exfat");
     323        if (str_cmp(STRING(RDFMT), "fat") != 0)
     324                srv_start("/srv/fat");
     325        srv_start("/srv/cdfs");
    322326        srv_start("/srv/mfs");
    323327       
  • uspace/lib/c/include/types/vol.h

    r02082f3 re48947e  
    5252        fs_fat,
    5353        fs_minix,
    54         fs_ext4
     54        fs_ext4,
     55        fs_cdfs
    5556} vol_fstype_t;
    5657
  • uspace/lib/ext4/include/ext4/filesystem.h

    r02082f3 re48947e  
    3636
    3737#include <block.h>
     38#include "ext4/fstypes.h"
    3839#include "ext4/types.h"
    3940
    40 extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t,
    41     enum cache_mode);
    42 extern int ext4_filesystem_fini(ext4_filesystem_t *);
    43 extern int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
     41extern int ext4_filesystem_probe(service_id_t);
     42extern int ext4_filesystem_open(ext4_instance_t *, service_id_t,
     43    enum cache_mode, aoff64_t *, ext4_filesystem_t **);
     44extern int ext4_filesystem_close(ext4_filesystem_t *);
    4445extern uint32_t ext4_filesystem_blockaddr2_index_in_group(ext4_superblock_t *,
    4546    uint32_t);
  • uspace/lib/ext4/include/ext4/ops.h

    r02082f3 re48947e  
    3535
    3636#include <libfs.h>
     37#include "ext4/fstypes.h"
    3738
    38 extern vfs_out_ops_t ext4fs_ops;
    39 extern libfs_ops_t ext4fs_libfs_ops;
     39extern vfs_out_ops_t ext4_ops;
     40extern libfs_ops_t ext4_libfs_ops;
    4041
    41 extern int ext4fs_global_init(void);
    42 extern int ext4fs_global_fini(void);
     42extern int ext4_global_init(void);
     43extern int ext4_global_fini(void);
     44
     45extern int ext4_node_get_core(fs_node_t **, ext4_instance_t *, fs_index_t);
     46extern int ext4_node_put(fs_node_t *);
    4347
    4448
  • uspace/lib/ext4/src/balloc.c

    r02082f3 re48947e  
    3131 */
    3232/**
    33  * @file  libext4_balloc.c
     33 * @file  balloc.c
    3434 * @brief Physical block allocator.
    3535 */
  • uspace/lib/ext4/src/bitmap.c

    r02082f3 re48947e  
    3131 */
    3232/**
    33  * @file  libext4_bitmap.c
     33 * @file  bitmap.c
    3434 * @brief Ext4 bitmap operations.
    3535 */
  • uspace/lib/ext4/src/block_group.c

    r02082f3 re48947e  
    3232 */
    3333/**
    34  * @file  libext4_block_group.c
     34 * @file  block_group.c
    3535 * @brief Ext4 block group structure operations.
    3636 */
  • uspace/lib/ext4/src/directory.c

    r02082f3 re48947e  
    3232 */
    3333/**
    34  * @file  libext4_directory.c
     34 * @file  directory.c
    3535 * @brief Ext4 directory structure operations.
    3636 */
  • uspace/lib/ext4/src/directory_index.c

    r02082f3 re48947e  
    3131 */
    3232/**
    33  * @file  libext4_directory_index.c
     33 * @file  directory_index.c
    3434 * @brief Ext4 directory index operations.
    3535 */
  • uspace/lib/ext4/src/extent.c

    r02082f3 re48947e  
    3131 */
    3232/**
    33  * @file  libext4_extent.c
     33 * @file  extent.c
    3434 * @brief Ext4 extent structures operations.
    3535 */
  • uspace/lib/ext4/src/filesystem.c

    r02082f3 re48947e  
    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"
    5355
    54 /** Initialize filesystem and read all needed data.
     56static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
     57
     58/** Initialize filesystem for opening.
     59 *
     60 * But do not mark mounted just yet.
    5561 *
    5662 * @param fs         Filesystem instance to be initialized
    57  * @param service_id Identifier if device with the filesystem
     63 * @param service_id Block device to open
     64 * @param cmode      Cache mode
    5865 *
    5966 * @return Error code
    6067 *
    6168 */
    62 int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,
     69static int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,
    6370    enum cache_mode cmode)
    6471{
     
    113120                goto err_2;
    114121        }
    115        
     122
    116123        rc = ext4_superblock_check_sanity(fs->superblock);
    117124        if (rc != EOK)
    118125                goto err_2;
    119126
    120         /* Mark system as mounted */
    121         ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS);
    122         rc = ext4_superblock_write_direct(fs->device, fs->superblock);
     127        /* Check flags */
     128        bool read_only;
     129        rc = ext4_filesystem_check_features(fs, &read_only);
    123130        if (rc != EOK)
    124131                goto err_2;
    125132
    126         uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock);
    127         ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1);
    128 
    129133        return EOK;
    130 
    131134err_2:
    132135        block_cache_fini(fs->device);
     
    139142}
    140143
    141 /** Destroy filesystem instance (used by unmount operation).
     144/** Finalize filesystem.
     145 *
     146 * @param fs Filesystem to be finalized
     147 *
     148 */
     149static void ext4_filesystem_fini(ext4_filesystem_t *fs)
     150{
     151        /* Release memory space for superblock */
     152        free(fs->superblock);
     153
     154        /* Finish work with block library */
     155        block_cache_fini(fs->device);
     156        block_fini(fs->device);
     157}
     158
     159/** Probe filesystem.
     160 *
     161 * @param service_id Block device to probe
     162 *
     163 * @return EOK or negative error code.
     164 *
     165 */
     166int ext4_filesystem_probe(service_id_t service_id)
     167{
     168        ext4_filesystem_t *fs = NULL;
     169        int rc;
     170
     171        fs = calloc(1, sizeof(ext4_filesystem_t));
     172        if (fs == NULL)
     173                return ENOMEM;
     174
     175        /* Initialize the file system for opening */
     176        rc = ext4_filesystem_init(fs, service_id, CACHE_MODE_WT);
     177        if (rc != EOK) {
     178                free(fs);
     179                return rc;
     180        }
     181
     182        ext4_filesystem_fini(fs);
     183        return EOK;
     184}
     185
     186/** Open filesystem and read all needed data.
     187 *
     188 * @param fs         Filesystem to be initialized
     189 * @param inst       Instance
     190 * @param service_id Identifier if device with the filesystem
     191 * @param cmode      Cache mode
     192 * @param size       Output value - size of root node
     193 *
     194 * @return Error code
     195 *
     196 */
     197int ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id,
     198    enum cache_mode cmode, aoff64_t *size, ext4_filesystem_t **rfs)
     199{
     200        ext4_filesystem_t *fs = NULL;
     201        fs_node_t *root_node = NULL;
     202        int rc;
     203
     204        fs = calloc(1, sizeof(ext4_filesystem_t));
     205        if (fs == NULL) {
     206                rc = ENOMEM;
     207                goto error;
     208        }
     209
     210        inst->filesystem = fs;
     211
     212        /* Initialize the file system for opening */
     213        rc = ext4_filesystem_init(fs, service_id, cmode);
     214        if (rc != EOK)
     215                goto error;
     216
     217        /* Read root node */
     218        rc = ext4_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);
     219        if (rc != EOK)
     220                goto error;
     221
     222        /* Mark system as mounted */
     223        ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS);
     224        rc = ext4_superblock_write_direct(fs->device, fs->superblock);
     225        if (rc != EOK)
     226                goto error;
     227
     228        uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock);
     229        ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1);
     230
     231        ext4_node_t *enode = EXT4_NODE(root_node);
     232
     233        *size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode);
     234
     235        ext4_node_put(root_node);
     236        *rfs = fs;
     237        return EOK;
     238error:
     239        if (root_node != NULL)
     240                ext4_node_put(root_node);
     241
     242        if (fs != NULL) {
     243                ext4_filesystem_fini(fs);
     244                free(fs);
     245        }
     246
     247        return rc;
     248}
     249
     250/** Close filesystem.
    142251 *
    143252 * @param fs Filesystem to be destroyed
    144253 *
    145  * @return Error code
    146  *
    147  */
    148 int ext4_filesystem_fini(ext4_filesystem_t *fs)
     254 * @return EOK or negative error code. On error the state of the file
     255 *         system is unchanged.
     256 *
     257 */
     258int ext4_filesystem_close(ext4_filesystem_t *fs)
    149259{
    150260        /* Write the superblock to the device */
    151261        ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS);
    152262        int rc = ext4_superblock_write_direct(fs->device, fs->superblock);
    153        
    154         /* Release memory space for superblock */
    155         free(fs->superblock);
    156 
    157         /* Finish work with block library */
    158         block_cache_fini(fs->device);
    159         block_fini(fs->device);
    160        
    161         return rc;
     263        if (rc != EOK)
     264                return rc;
     265
     266        ext4_filesystem_fini(fs);
     267        return EOK;
    162268}
    163269
     
    169275 *
    170276 * @param fs        Filesystem to be checked
    171  * @param read_only Flag if filesystem should be mounted only for reading
     277 * @param read_only Place to write flag saying whether filesystem
     278 *                  should be mounted only for reading
    172279 *
    173280 * @return Error code
    174281 *
    175282 */
    176 int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *read_only)
     283static int ext4_filesystem_check_features(ext4_filesystem_t *fs,
     284    bool *read_only)
    177285{
    178286        /* Feature flags are present only in higher revisions */
  • uspace/lib/ext4/src/hash.c

    r02082f3 re48947e  
    3131 */
    3232/**
    33  * @file  libext4_hash.c
     33 * @file  hash.c
    3434 * @brief Hashing algorithms for ext4 HTree.
    3535 */
  • uspace/lib/ext4/src/ialloc.c

    r02082f3 re48947e  
    3131 */
    3232/**
    33  * @file  libext4_ialloc.c
     33 * @file  ialloc.c
    3434 * @brief I-node (de)allocation operations.
    3535 */
  • uspace/lib/ext4/src/inode.c

    r02082f3 re48947e  
    3232 */
    3333/**
    34  * @file  libext4_inode.c
     34 * @file  inode.c
    3535 * @brief Ext4 i-node structure operations.
    3636 */
  • uspace/lib/ext4/src/ops.c

    r02082f3 re48947e  
    3232 */
    3333/**
    34  * @file  ext4fs_ops.c
     34 * @file  ops.c
    3535 * @brief Operations for ext4 filesystem.
    3636 */
    3737
     38#include <adt/hash_table.h>
     39#include <adt/hash.h>
    3840#include <errno.h>
    39 #include <ext4/libext4.h>
    4041#include <fibril_synch.h>
    4142#include <libfs.h>
    4243#include <macros.h>
    4344#include <malloc.h>
    44 #include <adt/hash_table.h>
    45 #include <adt/hash.h>
     45#include <mem.h>
     46#include <str.h>
    4647#include <ipc/loc.h>
     48#include "ext4/balloc.h"
     49#include "ext4/directory.h"
     50#include "ext4/directory_index.h"
     51#include "ext4/extent.h"
     52#include "ext4/inode.h"
    4753#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;
     54#include "ext4/filesystem.h"
     55#include "ext4/fstypes.h"
     56#include "ext4/superblock.h"
    7357
    7458/* Forward declarations of auxiliary functions */
    7559
    76 static int ext4fs_read_directory(ipc_callid_t, aoff64_t, size_t,
    77     ext4fs_instance_t *, ext4_inode_ref_t *, size_t *);
    78 static int ext4fs_read_file(ipc_callid_t, aoff64_t, size_t, ext4fs_instance_t *,
     60static int ext4_read_directory(ipc_callid_t, aoff64_t, size_t,
     61    ext4_instance_t *, ext4_inode_ref_t *, size_t *);
     62static int ext4_read_file(ipc_callid_t, aoff64_t, size_t, ext4_instance_t *,
    7963    ext4_inode_ref_t *, size_t *);
    80 static bool ext4fs_is_dots(const uint8_t *, size_t);
    81 static 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 *);
     64static bool ext4_is_dots(const uint8_t *, size_t);
     65static int ext4_instance_get(service_id_t, ext4_instance_t **);
    8466
    8567/* Forward declarations of ext4 libfs operations. */
    8668
    87 static int ext4fs_root_get(fs_node_t **, service_id_t);
    88 static int ext4fs_match(fs_node_t **, fs_node_t *, const char *);
    89 static int ext4fs_node_get(fs_node_t **, service_id_t, fs_index_t);
    90 static int ext4fs_node_open(fs_node_t *);
    91 static int ext4fs_node_put(fs_node_t *);
    92 static int ext4fs_create_node(fs_node_t **, service_id_t, int);
    93 static int ext4fs_destroy_node(fs_node_t *);
    94 static int ext4fs_link(fs_node_t *, fs_node_t *, const char *);
    95 static int ext4fs_unlink(fs_node_t *, fs_node_t *, const char *);
    96 static int ext4fs_has_children(bool *, fs_node_t *);
    97 static fs_index_t ext4fs_index_get(fs_node_t *);
    98 static aoff64_t ext4fs_size_get(fs_node_t *);
    99 static unsigned ext4fs_lnkcnt_get(fs_node_t *);
    100 static bool ext4fs_is_directory(fs_node_t *);
    101 static bool ext4fs_is_file(fs_node_t *node);
    102 static service_id_t ext4fs_service_get(fs_node_t *node);
    103 static int ext4fs_size_block(service_id_t, uint32_t *);
    104 static int ext4fs_total_block_count(service_id_t, uint64_t *);
    105 static int ext4fs_free_block_count(service_id_t, uint64_t *);
     69static int ext4_root_get(fs_node_t **, service_id_t);
     70static int ext4_match(fs_node_t **, fs_node_t *, const char *);
     71static int ext4_node_get(fs_node_t **, service_id_t, fs_index_t);
     72static int ext4_node_open(fs_node_t *);
     73       int ext4_node_put(fs_node_t *);
     74static int ext4_create_node(fs_node_t **, service_id_t, int);
     75static int ext4_destroy_node(fs_node_t *);
     76static int ext4_link(fs_node_t *, fs_node_t *, const char *);
     77static int ext4_unlink(fs_node_t *, fs_node_t *, const char *);
     78static int ext4_has_children(bool *, fs_node_t *);
     79static fs_index_t ext4_index_get(fs_node_t *);
     80static aoff64_t ext4_size_get(fs_node_t *);
     81static unsigned ext4_lnkcnt_get(fs_node_t *);
     82static bool ext4_is_directory(fs_node_t *);
     83static bool ext4_is_file(fs_node_t *node);
     84static service_id_t ext4_service_get(fs_node_t *node);
     85static int ext4_size_block(service_id_t, uint32_t *);
     86static int ext4_total_block_count(service_id_t, uint64_t *);
     87static int ext4_free_block_count(service_id_t, uint64_t *);
    10688
    10789/* Static variables */
     
    127109static size_t open_nodes_hash(const ht_link_t *item)
    128110{
    129         ext4fs_node_t *enode = hash_table_get_inst(item, ext4fs_node_t, link);
     111        ext4_node_t *enode = hash_table_get_inst(item, ext4_node_t, link);
    130112        return hash_combine(enode->instance->service_id, enode->inode_ref->index);     
    131113}
     
    134116{
    135117        node_key_t *key = (node_key_t *)key_arg;
    136         ext4fs_node_t *enode = hash_table_get_inst(item, ext4fs_node_t, link);
     118        ext4_node_t *enode = hash_table_get_inst(item, ext4_node_t, link);
    137119       
    138120        return key->service_id == enode->instance->service_id
     
    156138 *
    157139 */
    158 int ext4fs_global_init(void)
     140int ext4_global_init(void)
    159141{
    160142        if (!hash_table_create(&open_nodes, 0, 0, &open_nodes_ops))
     
    170152 * @return Error code
    171153 */
    172 int ext4fs_global_fini(void)
     154int ext4_global_fini(void)
    173155{
    174156        hash_table_destroy(&open_nodes);
     
    188170 *
    189171 */
    190 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst)
     172int ext4_instance_get(service_id_t service_id, ext4_instance_t **inst)
    191173{
    192174        fibril_mutex_lock(&instance_list_mutex);
     
    197179        }
    198180       
    199         list_foreach(instance_list, link, ext4fs_instance_t, tmp) {
     181        list_foreach(instance_list, link, ext4_instance_t, tmp) {
    200182                if (tmp->service_id == service_id) {
    201183                        *inst = tmp;
     
    217199 *
    218200 */
    219 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id)
    220 {
    221         return ext4fs_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX);
     201int ext4_root_get(fs_node_t **rfn, service_id_t service_id)
     202{
     203        return ext4_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX);
    222204}
    223205
     
    233215 *
    234216 */
    235 int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
    236 {
    237         ext4fs_node_t *eparent = EXT4FS_NODE(pfn);
     217int ext4_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
     218{
     219        ext4_node_t *eparent = EXT4_NODE(pfn);
    238220        ext4_filesystem_t *fs = eparent->instance->filesystem;
    239221       
     
    257239        /* Load node from search result */
    258240        uint32_t inode = ext4_directory_entry_ll_get_inode(result.dentry);
    259         rc = ext4fs_node_get_core(rfn, eparent->instance, inode);
     241        rc = ext4_node_get_core(rfn, eparent->instance, inode);
    260242        if (rc != EOK)
    261243                goto exit;
     
    280262 *
    281263 */
    282 int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
    283 {
    284         ext4fs_instance_t *inst;
    285         int rc = ext4fs_instance_get(service_id, &inst);
    286         if (rc != EOK)
    287                 return rc;
    288        
    289         return ext4fs_node_get_core(rfn, inst, index);
     264int ext4_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
     265{
     266        ext4_instance_t *inst;
     267        int rc = ext4_instance_get(service_id, &inst);
     268        if (rc != EOK)
     269                return rc;
     270       
     271        return ext4_node_get_core(rfn, inst, index);
    290272}
    291273
     
    299281 *
    300282 */
    301 int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst,
     283int ext4_node_get_core(fs_node_t **rfn, ext4_instance_t *inst,
    302284    fs_index_t index)
    303285{
     
    311293       
    312294        ht_link_t *already_open = hash_table_find(&open_nodes, &key);
    313         ext4fs_node_t *enode = NULL;
     295        ext4_node_t *enode = NULL;
    314296        if (already_open) {
    315                 enode = hash_table_get_inst(already_open, ext4fs_node_t, link);
     297                enode = hash_table_get_inst(already_open, ext4_node_t, link);
    316298                *rfn = enode->fs_node;
    317299                enode->references++;
     
    322304       
    323305        /* Prepare new enode */
    324         enode = malloc(sizeof(ext4fs_node_t));
     306        enode = malloc(sizeof(ext4_node_t));
    325307        if (enode == NULL) {
    326308                fibril_mutex_unlock(&open_nodes_lock);
     
    373355 *
    374356 */
    375 int ext4fs_node_put_core(ext4fs_node_t *enode)
     357static int ext4_node_put_core(ext4_node_t *enode)
    376358{
    377359        hash_table_remove_item(&open_nodes, &enode->link);
     
    400382 *
    401383 */
    402 int ext4fs_node_open(fs_node_t *fn)
     384int ext4_node_open(fs_node_t *fn)
    403385{
    404386        /* Stateless operation */
     
    414396 *
    415397 */
    416 int ext4fs_node_put(fs_node_t *fn)
     398int ext4_node_put(fs_node_t *fn)
    417399{
    418400        fibril_mutex_lock(&open_nodes_lock);
    419401       
    420         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     402        ext4_node_t *enode = EXT4_NODE(fn);
    421403        assert(enode->references > 0);
    422404        enode->references--;
    423405        if (enode->references == 0) {
    424                 int rc = ext4fs_node_put_core(enode);
     406                int rc = ext4_node_put_core(enode);
    425407                if (rc != EOK) {
    426408                        fibril_mutex_unlock(&open_nodes_lock);
     
    443425 *
    444426 */
    445 int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
     427int ext4_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
    446428{
    447429        /* Allocate enode */
    448         ext4fs_node_t *enode;
    449         enode = malloc(sizeof(ext4fs_node_t));
     430        ext4_node_t *enode;
     431        enode = malloc(sizeof(ext4_node_t));
    450432        if (enode == NULL)
    451433                return ENOMEM;
     
    460442       
    461443        /* Load instance */
    462         ext4fs_instance_t *inst;
    463         int rc = ext4fs_instance_get(service_id, &inst);
     444        ext4_instance_t *inst;
     445        int rc = ext4_instance_get(service_id, &inst);
    464446        if (rc != EOK) {
    465447                free(enode);
     
    504486 *
    505487 */
    506 int ext4fs_destroy_node(fs_node_t *fn)
     488int ext4_destroy_node(fs_node_t *fn)
    507489{
    508490        /* If directory, check for children */
    509491        bool has_children;
    510         int rc = ext4fs_has_children(&has_children, fn);
    511         if (rc != EOK) {
    512                 ext4fs_node_put(fn);
     492        int rc = ext4_has_children(&has_children, fn);
     493        if (rc != EOK) {
     494                ext4_node_put(fn);
    513495                return rc;
    514496        }
    515497       
    516498        if (has_children) {
    517                 ext4fs_node_put(fn);
     499                ext4_node_put(fn);
    518500                return EINVAL;
    519501        }
    520502       
    521         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     503        ext4_node_t *enode = EXT4_NODE(fn);
    522504        ext4_inode_ref_t *inode_ref = enode->inode_ref;
    523505       
     
    525507        rc = ext4_filesystem_truncate_inode(inode_ref, 0);
    526508        if (rc != EOK) {
    527                 ext4fs_node_put(fn);
     509                ext4_node_put(fn);
    528510                return rc;
    529511        }
     
    539521        rc = ext4_filesystem_free_inode(inode_ref);
    540522        if (rc != EOK) {
    541                 ext4fs_node_put(fn);
    542                 return rc;
    543         }
    544        
    545         return ext4fs_node_put(fn);
     523                ext4_node_put(fn);
     524                return rc;
     525        }
     526       
     527        return ext4_node_put(fn);
    546528}
    547529
     
    555537 *
    556538 */
    557 int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
     539int ext4_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
    558540{
    559541        /* Check maximum name length */
     
    561543                return ENAMETOOLONG;
    562544       
    563         ext4fs_node_t *parent = EXT4FS_NODE(pfn);
    564         ext4fs_node_t *child = EXT4FS_NODE(cfn);
     545        ext4_node_t *parent = EXT4_NODE(pfn);
     546        ext4_node_t *child = EXT4_NODE(cfn);
    565547        ext4_filesystem_t *fs = parent->instance->filesystem;
    566548       
     
    628610 *
    629611 */
    630 int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)
     612int ext4_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)
    631613{
    632614        bool has_children;
    633         int rc = ext4fs_has_children(&has_children, cfn);
     615        int rc = ext4_has_children(&has_children, cfn);
    634616        if (rc != EOK)
    635617                return rc;
     
    640622       
    641623        /* Remove entry from parent directory */
    642         ext4_inode_ref_t *parent = EXT4FS_NODE(pfn)->inode_ref;
     624        ext4_inode_ref_t *parent = EXT4_NODE(pfn)->inode_ref;
    643625        rc = ext4_directory_remove_entry(parent, name);
    644626        if (rc != EOK)
     
    646628       
    647629        /* Decrement links count */
    648         ext4_inode_ref_t *child_inode_ref = EXT4FS_NODE(cfn)->inode_ref;
     630        ext4_inode_ref_t *child_inode_ref = EXT4_NODE(cfn)->inode_ref;
    649631       
    650632        uint32_t lnk_count =
     
    653635       
    654636        /* If directory - handle links from parent */
    655         if ((lnk_count <= 1) && (ext4fs_is_directory(cfn))) {
     637        if ((lnk_count <= 1) && (ext4_is_directory(cfn))) {
    656638                assert(lnk_count == 1);
    657639               
    658640                lnk_count--;
    659641               
    660                 ext4_inode_ref_t *parent_inode_ref = EXT4FS_NODE(pfn)->inode_ref;
     642                ext4_inode_ref_t *parent_inode_ref = EXT4_NODE(pfn)->inode_ref;
    661643               
    662644                uint32_t parent_lnk_count = ext4_inode_get_links_count(
     
    701683 *
    702684 */
    703 int ext4fs_has_children(bool *has_children, fs_node_t *fn)
    704 {
    705         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     685int ext4_has_children(bool *has_children, fs_node_t *fn)
     686{
     687        ext4_node_t *enode = EXT4_NODE(fn);
    706688        ext4_filesystem_t *fs = enode->instance->filesystem;
    707689       
     
    725707                            ext4_directory_entry_ll_get_name_length(fs->superblock,
    726708                            it.current);
    727                         if (!ext4fs_is_dots(it.current->name, name_size)) {
     709                        if (!ext4_is_dots(it.current->name, name_size)) {
    728710                                found = true;
    729711                                break;
     
    754736 *
    755737 */
    756 fs_index_t ext4fs_index_get(fs_node_t *fn)
    757 {
    758         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     738fs_index_t ext4_index_get(fs_node_t *fn)
     739{
     740        ext4_node_t *enode = EXT4_NODE(fn);
    759741        return enode->inode_ref->index;
    760742}
     
    767749 *
    768750 */
    769 aoff64_t ext4fs_size_get(fs_node_t *fn)
    770 {
    771         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     751aoff64_t ext4_size_get(fs_node_t *fn)
     752{
     753        ext4_node_t *enode = EXT4_NODE(fn);
    772754        ext4_superblock_t *sb = enode->instance->filesystem->superblock;
    773755        return ext4_inode_get_size(sb, enode->inode_ref->inode);
     
    781763 *
    782764 */
    783 unsigned ext4fs_lnkcnt_get(fs_node_t *fn)
    784 {
    785         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     765unsigned ext4_lnkcnt_get(fs_node_t *fn)
     766{
     767        ext4_node_t *enode = EXT4_NODE(fn);
    786768        uint32_t lnkcnt = ext4_inode_get_links_count(enode->inode_ref->inode);
    787769       
    788         if (ext4fs_is_directory(fn)) {
     770        if (ext4_is_directory(fn)) {
    789771                if (lnkcnt > 1)
    790772                        return 1;
     
    804786 *
    805787 */
    806 bool ext4fs_is_directory(fs_node_t *fn)
    807 {
    808         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     788bool ext4_is_directory(fs_node_t *fn)
     789{
     790        ext4_node_t *enode = EXT4_NODE(fn);
    809791        ext4_superblock_t *sb = enode->instance->filesystem->superblock;
    810792       
     
    820802 *
    821803 */
    822 bool ext4fs_is_file(fs_node_t *fn)
    823 {
    824         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     804bool ext4_is_file(fs_node_t *fn)
     805{
     806        ext4_node_t *enode = EXT4_NODE(fn);
    825807        ext4_superblock_t *sb = enode->instance->filesystem->superblock;
    826808       
     
    836818 *
    837819 */
    838 service_id_t ext4fs_service_get(fs_node_t *fn)
    839 {
    840         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     820service_id_t ext4_service_get(fs_node_t *fn)
     821{
     822        ext4_node_t *enode = EXT4_NODE(fn);
    841823        return enode->instance->service_id;
    842824}
    843825
    844 int ext4fs_size_block(service_id_t service_id, uint32_t *size)
    845 {
    846         ext4fs_instance_t *inst;
    847         int rc = ext4fs_instance_get(service_id, &inst);
     826int ext4_size_block(service_id_t service_id, uint32_t *size)
     827{
     828        ext4_instance_t *inst;
     829        int rc = ext4_instance_get(service_id, &inst);
    848830        if (rc != EOK)
    849831                return rc;
     
    858840}
    859841
    860 int ext4fs_total_block_count(service_id_t service_id, uint64_t *count)
    861 {
    862         ext4fs_instance_t *inst;
    863         int rc = ext4fs_instance_get(service_id, &inst);
     842int ext4_total_block_count(service_id_t service_id, uint64_t *count)
     843{
     844        ext4_instance_t *inst;
     845        int rc = ext4_instance_get(service_id, &inst);
    864846        if (rc != EOK)
    865847                return rc;
     
    874856}
    875857
    876 int ext4fs_free_block_count(service_id_t service_id, uint64_t *count)
    877 {
    878         ext4fs_instance_t *inst;
    879         int rc = ext4fs_instance_get(service_id, &inst);
     858int ext4_free_block_count(service_id_t service_id, uint64_t *count)
     859{
     860        ext4_instance_t *inst;
     861        int rc = ext4_instance_get(service_id, &inst);
    880862        if (rc != EOK)
    881863                return rc;
     
    890872 * libfs operations.
    891873 */
    892 libfs_ops_t ext4fs_libfs_ops = {
    893         .root_get = ext4fs_root_get,
    894         .match = ext4fs_match,
    895         .node_get = ext4fs_node_get,
    896         .node_open = ext4fs_node_open,
    897         .node_put = ext4fs_node_put,
    898         .create = ext4fs_create_node,
    899         .destroy = ext4fs_destroy_node,
    900         .link = ext4fs_link,
    901         .unlink = ext4fs_unlink,
    902         .has_children = ext4fs_has_children,
    903         .index_get = ext4fs_index_get,
    904         .size_get = ext4fs_size_get,
    905         .lnkcnt_get = ext4fs_lnkcnt_get,
    906         .is_directory = ext4fs_is_directory,
    907         .is_file = ext4fs_is_file,
    908         .service_get = ext4fs_service_get,
    909         .size_block = ext4fs_size_block,
    910         .total_block_count = ext4fs_total_block_count,
    911         .free_block_count = ext4fs_free_block_count
     874libfs_ops_t ext4_libfs_ops = {
     875        .root_get = ext4_root_get,
     876        .match = ext4_match,
     877        .node_get = ext4_node_get,
     878        .node_open = ext4_node_open,
     879        .node_put = ext4_node_put,
     880        .create = ext4_create_node,
     881        .destroy = ext4_destroy_node,
     882        .link = ext4_link,
     883        .unlink = ext4_unlink,
     884        .has_children = ext4_has_children,
     885        .index_get = ext4_index_get,
     886        .size_get = ext4_size_get,
     887        .lnkcnt_get = ext4_lnkcnt_get,
     888        .is_directory = ext4_is_directory,
     889        .is_file = ext4_is_file,
     890        .service_get = ext4_service_get,
     891        .size_block = ext4_size_block,
     892        .total_block_count = ext4_total_block_count,
     893        .free_block_count = ext4_free_block_count
    912894};
    913895
     
    925907 * @return Error code
    926908 */
    927 static int ext4fs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
    928 {
    929         return ENOTSUP;
     909static int ext4_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
     910{
     911        return ext4_filesystem_probe(service_id);
    930912}
    931913
     
    943925 *
    944926 */
    945 static int ext4fs_mounted(service_id_t service_id, const char *opts,
     927static int ext4_mounted(service_id_t service_id, const char *opts,
    946928    fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
    947929{
    948         /* Allocate libext4 filesystem structure */
    949         ext4_filesystem_t *fs = (ext4_filesystem_t *)
    950             malloc(sizeof(ext4_filesystem_t));
    951         if (fs == NULL)
     930        ext4_filesystem_t *fs;
     931       
     932        /* Allocate instance structure */
     933        ext4_instance_t *inst = (ext4_instance_t *)
     934            malloc(sizeof(ext4_instance_t));
     935        if (inst == NULL)
    952936                return ENOMEM;
    953        
    954         /* Allocate instance structure */
    955         ext4fs_instance_t *inst = (ext4fs_instance_t *)
    956             malloc(sizeof(ext4fs_instance_t));
    957         if (inst == NULL) {
    958                 free(fs);
    959                 return ENOMEM;
    960         }
    961937       
    962938        enum cache_mode cmode;
     
    966942                cmode = CACHE_MODE_WB;
    967943       
    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        
    986944        /* Initialize instance */
    987945        link_initialize(&inst->link);
    988946        inst->service_id = service_id;
    989         inst->filesystem = fs;
    990947        inst->open_nodes_count = 0;
    991948       
    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);
    997                 free(fs);
     949        /* Initialize the filesystem */
     950        aoff64_t rnsize;
     951        int rc = ext4_filesystem_open(inst, service_id, cmode, &rnsize, &fs);
     952        if (rc != EOK) {
    998953                free(inst);
    999954                return rc;
     
    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
     
    1023976 *
    1024977 */
    1025 static int ext4fs_unmounted(service_id_t service_id)
    1026 {
    1027         ext4fs_instance_t *inst;
    1028         int rc = ext4fs_instance_get(service_id, &inst);
     978static int ext4_unmounted(service_id_t service_id)
     979{
     980        ext4_instance_t *inst;
     981        int rc = ext4_instance_get(service_id, &inst);
    1029982        if (rc != EOK)
    1030983                return rc;
     
    1044997        fibril_mutex_unlock(&open_nodes_lock);
    1045998       
    1046         return ext4_filesystem_fini(inst->filesystem);
     999        rc = ext4_filesystem_close(inst->filesystem);
     1000        if (rc != EOK) {
     1001                fibril_mutex_lock(&instance_list_mutex);
     1002                list_append(&inst->link, &instance_list);
     1003                fibril_mutex_unlock(&instance_list_mutex);
     1004        }
     1005
     1006        free(inst);
     1007        return EOK;
    10471008}
    10481009
     
    10571018 *
    10581019 */
    1059 static int ext4fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
     1020static int ext4_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
    10601021    size_t *rbytes)
    10611022{
     
    10701031        }
    10711032       
    1072         ext4fs_instance_t *inst;
    1073         int rc = ext4fs_instance_get(service_id, &inst);
     1033        ext4_instance_t *inst;
     1034        int rc = ext4_instance_get(service_id, &inst);
    10741035        if (rc != EOK) {
    10751036                async_answer_0(callid, rc);
     
    10881049        if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode,
    10891050            EXT4_INODE_MODE_FILE)) {
    1090                 rc = ext4fs_read_file(callid, pos, size, inst, inode_ref,
     1051                rc = ext4_read_file(callid, pos, size, inst, inode_ref,
    10911052                    rbytes);
    10921053        } else if (ext4_inode_is_type(inst->filesystem->superblock,
    10931054            inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) {
    1094                 rc = ext4fs_read_directory(callid, pos, size, inst, inode_ref,
     1055                rc = ext4_read_directory(callid, pos, size, inst, inode_ref,
    10951056                    rbytes);
    10961057        } else {
     
    11131074 *
    11141075 */
    1115 bool ext4fs_is_dots(const uint8_t *name, size_t name_size)
     1076bool ext4_is_dots(const uint8_t *name, size_t name_size)
    11161077{
    11171078        if ((name_size == 1) && (name[0] == '.'))
     
    11361097 *
    11371098 */
    1138 int ext4fs_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size,
    1139     ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
     1099int ext4_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size,
     1100    ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
    11401101{
    11411102        ext4_directory_iterator_t it;
     
    11601121               
    11611122                /* Skip . and .. */
    1162                 if (ext4fs_is_dots(it.current->name, name_size))
     1123                if (ext4_is_dots(it.current->name, name_size))
    11631124                        goto skip;
    11641125               
     
    12271188 *
    12281189 */
    1229 int ext4fs_read_file(ipc_callid_t callid, aoff64_t pos, size_t size,
    1230     ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
     1190int ext4_read_file(ipc_callid_t callid, aoff64_t pos, size_t size,
     1191    ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
    12311192{
    12321193        ext4_superblock_t *sb = inst->filesystem->superblock;
     
    13161277 *
    13171278 */
    1318 static int ext4fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
     1279static int ext4_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
    13191280    size_t *wbytes, aoff64_t *nsize)
    13201281{
    13211282        fs_node_t *fn;
    1322         int rc = ext4fs_node_get(&fn, service_id, index);
     1283        int rc = ext4_node_get(&fn, service_id, index);
    13231284        if (rc != EOK)
    13241285                return rc;
     
    13321293        }
    13331294       
    1334         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     1295        ext4_node_t *enode = EXT4_NODE(fn);
    13351296        ext4_filesystem_t *fs = enode->instance->filesystem;
    13361297       
     
    14381399        ;
    14391400
    1440         int const rc2 = ext4fs_node_put(fn);
     1401        int const rc2 = ext4_node_put(fn);
    14411402        return rc == EOK ? rc2 : rc;
    14421403}
     
    14531414 *
    14541415 */
    1455 static int ext4fs_truncate(service_id_t service_id, fs_index_t index,
     1416static int ext4_truncate(service_id_t service_id, fs_index_t index,
    14561417    aoff64_t new_size)
    14571418{
    14581419        fs_node_t *fn;
    1459         int rc = ext4fs_node_get(&fn, service_id, index);
    1460         if (rc != EOK)
    1461                 return rc;
    1462        
    1463         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     1420        int rc = ext4_node_get(&fn, service_id, index);
     1421        if (rc != EOK)
     1422                return rc;
     1423       
     1424        ext4_node_t *enode = EXT4_NODE(fn);
    14641425        ext4_inode_ref_t *inode_ref = enode->inode_ref;
    14651426       
    14661427        rc = ext4_filesystem_truncate_inode(inode_ref, new_size);
    1467         int const rc2 = ext4fs_node_put(fn);
     1428        int const rc2 = ext4_node_put(fn);
    14681429       
    14691430        return rc == EOK ? rc2 : rc;
     
    14781439 *
    14791440 */
    1480 static int ext4fs_close(service_id_t service_id, fs_index_t index)
     1441static int ext4_close(service_id_t service_id, fs_index_t index)
    14811442{
    14821443        return EOK;
     
    14911452 *
    14921453 */
    1493 static int ext4fs_destroy(service_id_t service_id, fs_index_t index)
     1454static int ext4_destroy(service_id_t service_id, fs_index_t index)
    14941455{
    14951456        fs_node_t *fn;
    1496         int rc = ext4fs_node_get(&fn, service_id, index);
     1457        int rc = ext4_node_get(&fn, service_id, index);
    14971458        if (rc != EOK)
    14981459                return rc;
    14991460       
    15001461        /* Destroy the inode */
    1501         return ext4fs_destroy_node(fn);
     1462        return ext4_destroy_node(fn);
    15021463}
    15031464
     
    15081469 *
    15091470 */
    1510 static int ext4fs_sync(service_id_t service_id, fs_index_t index)
     1471static int ext4_sync(service_id_t service_id, fs_index_t index)
    15111472{
    15121473        fs_node_t *fn;
    1513         int rc = ext4fs_node_get(&fn, service_id, index);
    1514         if (rc != EOK)
    1515                 return rc;
    1516        
    1517         ext4fs_node_t *enode = EXT4FS_NODE(fn);
     1474        int rc = ext4_node_get(&fn, service_id, index);
     1475        if (rc != EOK)
     1476                return rc;
     1477       
     1478        ext4_node_t *enode = EXT4_NODE(fn);
    15181479        enode->inode_ref->dirty = true;
    15191480       
    1520         return ext4fs_node_put(fn);
     1481        return ext4_node_put(fn);
    15211482}
    15221483
     
    15241485 *
    15251486 */
    1526 vfs_out_ops_t ext4fs_ops = {
    1527         .fsprobe = ext4fs_fsprobe,
    1528         .mounted = ext4fs_mounted,
    1529         .unmounted = ext4fs_unmounted,
    1530         .read = ext4fs_read,
    1531         .write = ext4fs_write,
    1532         .truncate = ext4fs_truncate,
    1533         .close = ext4fs_close,
    1534         .destroy = ext4fs_destroy,
    1535         .sync = ext4fs_sync
     1487vfs_out_ops_t ext4_ops = {
     1488        .fsprobe = ext4_fsprobe,
     1489        .mounted = ext4_mounted,
     1490        .unmounted = ext4_unmounted,
     1491        .read = ext4_read,
     1492        .write = ext4_write,
     1493        .truncate = ext4_truncate,
     1494        .close = ext4_close,
     1495        .destroy = ext4_destroy,
     1496        .sync = ext4_sync
    15361497};
    15371498
  • uspace/lib/ext4/src/superblock.c

    r02082f3 re48947e  
    3333
    3434/**
    35  * @file  libext4_superblock.c
     35 * @file  superblock.c
    3636 * @brief Ext4 superblock operations.
    3737 */
  • uspace/lib/fdisk/src/fdisk.c

    r02082f3 re48947e  
    824824                sfstype = "Ext4";
    825825                break;
     826        case fs_cdfs:
     827                sfstype = "ISO 9660";
     828                break;
    826829        }
    827830
     
    993996                pcnt = lpc_ext4;
    994997                break;
     998        case fs_cdfs:
     999                return EINVAL; /* You cannot create an ISO partition */
    9951000        }
    9961001
  • uspace/srv/fs/cdfs/cdfs_ops.c

    r02082f3 re48947e  
    906906}
    907907
    908 static bool iso_readfs(cdfs_t *fs, fs_node_t *rfn,
    909     cdfs_lba_t altroot)
     908/** Read the volume descriptors. */
     909static bool iso_read_vol_desc(service_id_t sid, cdfs_lba_t altroot,
     910    uint32_t *rlba, uint32_t *rsize, cdfs_enc_t *enc)
    910911{
    911912        /* First 16 blocks of isofs are empty */
    912913        block_t *block;
    913         int rc = block_get(&block, fs->service_id, altroot + 16, BLOCK_FLAGS_NONE);
     914        int rc = block_get(&block, sid, altroot + 16, BLOCK_FLAGS_NONE);
    914915        if (rc != EOK)
    915916                return false;
     
    956957        // TODO: implement path table support
    957958       
    958         cdfs_node_t *node = CDFS_NODE(rfn);
    959        
    960959        /* Search for Joliet SVD */
    961960       
     
    963962        uint32_t jrsize;
    964963       
    965         rc = cdfs_find_joliet_svd(fs->service_id, altroot, &jrlba, &jrsize);
     964        rc = cdfs_find_joliet_svd(sid, altroot, &jrlba, &jrsize);
    966965        if (rc == EOK) {
    967966                /* Found */
    968                 node->lba = jrlba;
    969                 node->size = jrsize;
    970                 fs->enc = enc_ucs2;
     967                *rlba = jrlba;
     968                *rsize = jrsize;
     969                *enc = enc_ucs2;
    971970        } else {
    972                 node->lba = uint32_lb(vol_desc->data.prisec.root_dir.lba);
    973                 node->size = uint32_lb(vol_desc->data.prisec.root_dir.size);
    974                 fs->enc = enc_ascii;
    975         }
    976        
    977         if (!cdfs_readdir(fs, rfn)) {
    978                 block_put(block);
    979                 return false;
     971                *rlba = uint32_lb(vol_desc->data.prisec.root_dir.lba);
     972                *rsize = uint32_lb(vol_desc->data.prisec.root_dir.size);
     973                *enc = enc_ascii;
    980974        }
    981975       
    982976        block_put(block);
    983977        return true;
     978}
     979
     980static bool iso_readfs(cdfs_t *fs, fs_node_t *rfn,
     981    cdfs_lba_t altroot)
     982{
     983        int rc;
     984       
     985        cdfs_node_t *node = CDFS_NODE(rfn);
     986       
     987        rc = iso_read_vol_desc(fs->service_id, altroot, &node->lba,
     988            &node->size, &fs->enc);
     989        if (rc != EOK)
     990                return false;
     991       
     992        return cdfs_readdir(fs, rfn);
    984993}
    985994
     
    10231032static int cdfs_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
    10241033{
    1025         return ENOTSUP;
     1034        /* Initialize the block layer */
     1035        int rc = block_init(service_id, BLOCK_SIZE);
     1036        if (rc != EOK)
     1037                return rc;
     1038       
     1039        cdfs_lba_t altroot = 0;
     1040       
     1041        /*
     1042         * Read TOC multisession information and get the start address
     1043         * of the first track in the last session
     1044         */
     1045        scsi_toc_multisess_data_t toc;
     1046
     1047        rc = block_read_toc(service_id, 1, &toc, sizeof(toc));
     1048        if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10))
     1049                altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
     1050       
     1051        /* Initialize the block cache */
     1052        rc = block_cache_init(service_id, BLOCK_SIZE, 0, CACHE_MODE_WT);
     1053        if (rc != EOK) {
     1054                block_fini(service_id);
     1055                return rc;
     1056        }
     1057       
     1058        /* Check if this device is not already mounted */
     1059        fs_node_t *rootfn;
     1060        rc = cdfs_root_get(&rootfn, service_id);
     1061        if ((rc == EOK) && (rootfn)) {
     1062                cdfs_node_put(rootfn);
     1063                block_cache_fini(service_id);
     1064                block_fini(service_id);
     1065                return EOK;
     1066        }
     1067       
     1068        /* Read volume descriptors */
     1069        uint32_t rlba;
     1070        uint32_t rsize;
     1071        cdfs_enc_t enc;
     1072        if (!iso_read_vol_desc(service_id, altroot, &rlba, &rsize, &enc)) {
     1073                block_cache_fini(service_id);
     1074                block_fini(service_id);
     1075                return EIO;
     1076        }
     1077       
     1078        return EOK;
    10261079}
    10271080
  • uspace/srv/fs/exfat/exfat_fat.c

    r02082f3 re48947e  
    540540 * does not contain a exfat file system.
    541541 */
    542 int exfat_sanity_check(exfat_bs_t *bs, service_id_t service_id)
     542int exfat_sanity_check(exfat_bs_t *bs)
    543543{
    544544        if (str_cmp((char const *)bs->oem_name, "EXFAT   "))
  • uspace/srv/fs/exfat/exfat_fat.h

    r02082f3 re48947e  
    7272extern int exfat_set_cluster(struct exfat_bs *, service_id_t, exfat_cluster_t,
    7373    exfat_cluster_t);
    74 extern int exfat_sanity_check(struct exfat_bs *, service_id_t);
     74extern int exfat_sanity_check(struct exfat_bs *);
    7575
    7676extern int exfat_append_clusters(struct exfat_bs *, struct exfat_node *,
  • uspace/srv/fs/exfat/exfat_ops.c

    r02082f3 re48947e  
    10531053static int exfat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
    10541054{
    1055         return ENOTSUP;
     1055        int rc;
     1056        exfat_bs_t *bs;
     1057
     1058        /* initialize libblock */
     1059        rc = block_init(service_id, BS_SIZE);
     1060        if (rc != EOK)
     1061                return rc;
     1062
     1063        /* prepare the boot block */
     1064        rc = block_bb_read(service_id, BS_BLOCK);
     1065        if (rc != EOK) {
     1066                block_fini(service_id);
     1067                return rc;
     1068        }
     1069
     1070        /* get the buffer with the boot sector */
     1071        bs = block_bb_get(service_id);
     1072
     1073        /* Do some simple sanity checks on the file system. */
     1074        rc = exfat_sanity_check(bs);
     1075
     1076        (void) block_cache_fini(service_id);
     1077        block_fini(service_id);
     1078        return rc;
    10561079}
    10571080
     
    10861109        bs = block_bb_get(service_id);
    10871110
     1111        /* Do some simple sanity checks on the file system. */
     1112        rc = exfat_sanity_check(bs);
     1113        if (rc != EOK) {
     1114                (void) block_cache_fini(service_id);
     1115                block_fini(service_id);
     1116                return rc;
     1117        }
     1118
    10881119        /* Initialize the block cache */
    10891120        rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode);
    10901121        if (rc != EOK) {
    1091                 block_fini(service_id);
    1092                 return rc;
    1093         }
    1094 
    1095         /* Do some simple sanity checks on the file system. */
    1096         rc = exfat_sanity_check(bs, service_id);
    1097         if (rc != EOK) {
    1098                 (void) block_cache_fini(service_id);
    10991122                block_fini(service_id);
    11001123                return rc;
  • uspace/srv/fs/ext4fs/ext4fs.c

    r02082f3 re48947e  
    7272        }
    7373       
    74         int rc = ext4fs_global_init();
     74        int rc = ext4_global_init();
    7575        if (rc != EOK) {
    7676                printf("%s: Global initialization failed\n", NAME);
     
    7878        }
    7979       
    80         rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4fs_ops,
    81             &ext4fs_libfs_ops);
     80        rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4_ops,
     81            &ext4_libfs_ops);
    8282        if (rc != EOK) {
    8383                printf("%s: Failed to register file system\n", NAME);
  • uspace/srv/fs/fat/fat_ops.c

    r02082f3 re48947e  
    915915static int fat_fsprobe(service_id_t service_id, vfs_fs_probe_info_t *info)
    916916{
    917         return ENOTSUP;
     917        fat_bs_t *bs;
     918        int rc;
     919
     920        /* initialize libblock */
     921        rc = block_init(service_id, BS_SIZE);
     922        if (rc != EOK)
     923                return rc;
     924
     925        /* prepare the boot block */
     926        rc = block_bb_read(service_id, BS_BLOCK);
     927        if (rc != EOK) {
     928                block_fini(service_id);
     929                return rc;
     930        }
     931
     932        /* get the buffer with the boot sector */
     933        bs = block_bb_get(service_id);
     934
     935        if (BPS(bs) != BS_SIZE) {
     936                block_fini(service_id);
     937                return ENOTSUP;
     938        }
     939
     940        /* Initialize the block cache */
     941        rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, CACHE_MODE_WB);
     942        if (rc != EOK) {
     943                block_fini(service_id);
     944                return rc;
     945        }
     946
     947        /* Do some simple sanity checks on the file system. */
     948        rc = fat_sanity_check(bs, service_id);
     949
     950        (void) block_cache_fini(service_id);
     951        block_fini(service_id);
     952
     953        return rc;
    918954}
    919955
  • uspace/srv/volsrv/mkfs.c

    r02082f3 re48947e  
    119119                break;
    120120        case fs_ext4:
     121        case fs_cdfs:
    121122                cmd = NULL;
    122123                break;
  • uspace/srv/volsrv/part.c

    r02082f3 re48947e  
    5353static FIBRIL_MUTEX_INITIALIZE(vol_parts_lock);
    5454
     55struct fsname_type {
     56        const char *name;
     57        vol_fstype_t fstype;
     58};
     59
     60static struct fsname_type fstab[] = {
     61        { "ext4fs", fs_ext4 },
     62        { "cdfs", fs_cdfs },
     63        { "exfat", fs_exfat },
     64        { "fat", fs_fat },
     65        { "mfs", fs_minix },
     66        { NULL, 0 }
     67};
     68
    5569/** Check for new partitions */
    5670static int vol_part_check_new(void)
     
    134148        bool empty;
    135149        vfs_fs_probe_info_t info;
     150        struct fsname_type *fst;
    136151        int rc;
    137152
     
    157172
    158173        log_msg(LOG_DEFAULT, LVL_NOTE, "Probe partition %s", part->svc_name);
    159         rc = vfs_fsprobe("mfs", sid, &info);
    160         if (rc == EOK) {
     174
     175        fst = &fstab[0];
     176        while (fst->name != NULL) {
     177                rc = vfs_fsprobe(fst->name, sid, &info);
     178                if (rc == EOK)
     179                        break;
     180                ++fst;
     181        }
     182
     183        if (fst->name != NULL) {
     184                log_msg(LOG_DEFAULT, LVL_NOTE, "Found %s", fst->name);
    161185                part->pcnt = vpc_fs;
    162                 part->fstype = fs_minix;
     186                part->fstype = fst->fstype;
    163187        } else {
    164188                log_msg(LOG_DEFAULT, LVL_NOTE, "Partition does not contain "
Note: See TracChangeset for help on using the changeset viewer.