Changeset bd64680 in mainline


Ignore:
Timestamp:
2011-03-31T19:29:45Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2cada66
Parents:
147c9f6
Message:

Link mfs_match() to the libfs_ops structure

Location:
uspace/srv/fs/minixfs
Files:
2 edited

Legend:

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

    r147c9f6 rbd64680  
    4343
    4444#define DEBUG_MODE
     45
     46#define min(a, b)       ((a) < (b) ? (a) : (b))
    4547
    4648#ifdef DEBUG_MODE
     
    8991        int ino_per_block;
    9092        int dirsize;
     93        unsigned max_name_len;
    9194        bool long_names;
    9295        bool native;
  • uspace/srv/fs/minixfs/mfs_ops.c

    r147c9f6 rbd64680  
    5555static devmap_handle_t mfs_device_get(fs_node_t *fsnode);
    5656static aoff64_t mfs_size_get(fs_node_t *node);
     57static int mfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component);
    5758
    5859static
     
    7475        .node_open = mfs_node_open,
    7576        .index_get = mfs_index_get,
     77        .match = mfs_match,
    7678        .plb_get_char = mfs_plb_get_char,
    7779        .has_children = mfs_has_children,
     
    190192                sbi->block_size = conv16(native, sb3->s_block_size);
    191193                sbi->dirsize = MFS3_DIRSIZE;
     194                sbi->max_name_len = MFS3_MAX_NAME_LEN;
    192195        } else {
    193196                sbi->ninodes = conv16(native, sb->s_ninodes);
     
    202205                        sbi->nzones = conv32(native, sb->s_nzones2);
    203206                sbi->dirsize = longnames ? MFSL_DIRSIZE : MFS_DIRSIZE;
     207                sbi->max_name_len = longnames ? MFS_L_MAX_NAME_LEN :
     208                                MFS_MAX_NAME_LEN;
    204209        }
    205210 
     
    238243        struct mfs_node *node = fsnode->data;
    239244        return node->instance->handle;
     245}
     246
     247static int mfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
     248{
     249        struct mfs_node *mnode = pfn->data;
     250        struct mfs_ino_info *ino_i = mnode->ino_i;
     251        struct mfs_dentry_info *d_info;
     252
     253        if (!S_ISDIR(ino_i->i_mode))
     254                return ENOTDIR;
     255
     256        mfsdebug("mfs_match()\n");
     257
     258        struct mfs_sb_info *sbi = mnode->instance->sbi;
     259        const size_t comp_size = str_size(component);
     260
     261        int i = 2;
     262        while (1) {
     263                d_info = read_directory_entry(mnode, i++);
     264                if (!d_info) {
     265                        /*Reached the end of the directory entry list*/
     266                        break;
     267                }
     268
     269                if (!d_info->d_inum) {
     270                        /*This entry is not used*/
     271                        continue;
     272                }
     273
     274                if (!bcmp(component, d_info->d_name, min(sbi->max_name_len,
     275                                comp_size))) {
     276                        /*Hit!*/
     277                        mfs_node_core_get(rfn, mnode->instance,
     278                                d_info->d_inum);
     279                        goto found;
     280                }
     281        }
     282        *rfn = NULL;
     283        return ENOENT;
     284found:
     285        return EOK;
    240286}
    241287
     
    475521
    476522        for (link = inst_list.next; link != &inst_list; link = link->next) {
    477                 instance_ptr = list_get_instance(link, struct mfs_instance, link);
     523                instance_ptr = list_get_instance(link, struct mfs_instance,
     524                                link);
    478525               
    479526                if (instance_ptr->handle == handle) {
Note: See TracChangeset for help on using the changeset viewer.