Changeset ac28650 in mainline


Ignore:
Timestamp:
2011-03-27T10:10:23Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a04b62d
Parents:
557ea4f6
Message:
  • Fix a bug in mfs_has_children() function
  • Some functions shold be declared as static
Location:
uspace/srv/fs/minixfs
Files:
4 edited

Legend:

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

    r557ea4f6 rac28650  
    4848#include <stdio.h>
    4949#include "mfs.h"
    50 
    51 #define NAME    "mfs"
    5250
    5351vfs_info_t mfs_vfs_info = {
  • uspace/srv/fs/minixfs/mfs.h

    r557ea4f6 rac28650  
    3939#include <adt/list.h>
    4040#include "../../vfs/vfs.h"
     41
     42#define NAME            "mfs"
    4143
    4244#define DEBUG_MODE
     
    125127extern void mfs_mount(ipc_callid_t rid, ipc_call_t *request);
    126128extern void mfs_lookup(ipc_callid_t rid, ipc_call_t *request);
    127 extern aoff64_t mfs_size_get(fs_node_t *node);
    128 extern bool mfs_is_directory(fs_node_t *fsnode);
    129 extern bool mfs_is_file(fs_node_t *fsnode);
    130 extern char mfs_plb_get_char(unsigned pos);
    131 extern int mfs_has_children(bool *has_children, fs_node_t *fsnode);
    132 extern int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle);
    133 extern devmap_handle_t mfs_device_get(fs_node_t *fsnode);
    134129extern int mfs_instance_get(devmap_handle_t handle,
    135130                                struct mfs_instance **instance);
    136 extern
    137 int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
    138                         fs_index_t index);
    139131
    140132extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request);
  • uspace/srv/fs/minixfs/mfs_dentry.c

    r557ea4f6 rac28650  
    5050                return NULL;
    5151
    52         int r = read_map(&block, mnode, index *sbi->dirsize);
     52        int r = read_map(&block, mnode, index * sbi->dirsize);
    5353
    5454        if (r != EOK || block == 0)
  • uspace/srv/fs/minixfs/mfs_ops.c

    r557ea4f6 rac28650  
    4848static fs_index_t mfs_index_get(fs_node_t *fsnode);
    4949static unsigned mfs_lnkcnt_get(fs_node_t *fsnode);
     50static char mfs_plb_get_char(unsigned pos);
     51static bool mfs_is_directory(fs_node_t *fsnode);
     52static bool mfs_is_file(fs_node_t *fsnode);
     53static int mfs_has_children(bool *has_children, fs_node_t *fsnode);
     54static int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle);
     55static devmap_handle_t mfs_device_get(fs_node_t *fsnode);
     56static aoff64_t mfs_size_get(fs_node_t *node);
     57
     58static
     59int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
     60                        fs_index_t index);
     61
    5062
    5163static LIST_INITIALIZE(inst_list);
     
    221233}
    222234
    223 aoff64_t mfs_size_get(fs_node_t *node)
    224 {
    225         mfsdebug("request for inode size\n");
     235static aoff64_t mfs_size_get(fs_node_t *node)
     236{
    226237        assert(node);
    227238
     
    241252}
    242253
    243 int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
     254static int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
    244255                        fs_index_t index)
    245256{
     
    277288static int mfs_node_open(fs_node_t *fsnode)
    278289{
    279         mfsdebug("mfs_node_open()\n");
    280290        /*
    281291         * Opening a file is stateless, nothing
     
    363373}
    364374
    365 bool mfs_is_directory(fs_node_t *fsnode)
     375static bool mfs_is_directory(fs_node_t *fsnode)
    366376{
    367377        const struct mfs_node *node = fsnode->data;
     
    369379}
    370380
    371 bool mfs_is_file(fs_node_t *fsnode)
     381static bool mfs_is_file(fs_node_t *fsnode)
    372382{
    373383        struct mfs_node *node = fsnode->data;
     
    375385}
    376386
    377 int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle)
     387static int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle)
    378388{
    379389        int rc = mfs_node_get(rfn, handle, MFS_ROOT_INO);
     
    388398}
    389399
    390 char mfs_plb_get_char(unsigned pos)
     400static char mfs_plb_get_char(unsigned pos)
    391401{
    392402        return mfs_reg.plb_ro[pos % PLB_SIZE];
    393403}
    394404
    395 int mfs_has_children(bool *has_children, fs_node_t *fsnode)
     405static int mfs_has_children(bool *has_children, fs_node_t *fsnode)
    396406{
    397407        struct mfs_node *mnode = fsnode->data;
     
    399409        const struct mfs_instance *inst = mnode->instance;
    400410        const struct mfs_sb_info *sbi = inst->sbi;
    401         int i;
     411        uint32_t n_dentries = 0;
    402412
    403413        *has_children = false;
     
    407417
    408418        struct mfs_dentry_info *d_info;
    409 
    410         for (i = 2; i < ino_i->i_size / sbi->dirsize; ++i) {
    411                 d_info = read_directory_entry(mnode, i);
     419        n_dentries =  ino_i->i_size / sbi->dirsize;
     420       
     421        /* The first two dentries are always . and .. */
     422        assert(n_dentries >= 2);
     423
     424        if (n_dentries == 2)
     425                goto out;
     426
     427        int i = 2;
     428        while (1) {
     429                d_info = read_directory_entry(mnode, i++);
    412430
    413431                if (!d_info)
     
    424442
    425443out:
     444
     445        if (n_dentries > 2 && !*has_children)
     446                printf(NAME ": Filesystem corruption detected");
    426447
    427448        if (*has_children)
Note: See TracChangeset for help on using the changeset viewer.