Changeset 54caa41b in mainline for uspace/srv/fs/minixfs/mfs_ops.c


Ignore:
Timestamp:
2011-03-24T21:30:52Z (14 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41202a9
Parents:
cfbcd86
Message:

Link mfs_has_children() function to the libfs_ops structure

File:
1 edited

Legend:

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

    rcfbcd86 r54caa41b  
    5454        .is_file = mfs_is_file,
    5555        .node_get = mfs_node_get,
    56         .plb_get_char = mfs_plb_get_char
     56        .plb_get_char = mfs_plb_get_char,
     57        .has_children = mfs_has_children
    5758};
    5859
     
    312313}
    313314
     315void mfs_lookup(ipc_callid_t rid, ipc_call_t *request)
     316{
     317        libfs_lookup(&mfs_libfs_ops, mfs_reg.fs_handle, rid, request);
     318}
     319
    314320char mfs_plb_get_char(unsigned pos)
    315321{
    316322        return mfs_reg.plb_ro[pos % PLB_SIZE];
     323}
     324
     325int mfs_has_children(bool *has_children, fs_node_t *fsnode)
     326{
     327        struct mfs_node *mnode = fsnode->data;
     328        const struct mfs_ino_info *ino_i = mnode->ino_i;
     329        const struct mfs_instance *inst = mnode->instance;
     330        const struct mfs_sb_info *sbi = inst->sbi;
     331        int i;
     332
     333        *has_children = false;
     334
     335        if (!S_ISDIR(mnode->ino_i->i_mode))
     336                goto out;
     337
     338        struct mfs_dentry_info *d_info;
     339
     340        for (i = 2; i < ino_i->i_size / sbi->dirsize; ++i) {
     341                d_info = read_directory_entry(mnode, i);
     342
     343                if (!d_info)
     344                        goto out;
     345
     346                if (d_info->d_inum) {
     347                        *has_children = true;
     348                        free(d_info);
     349                        break;
     350                }
     351
     352                free(d_info);
     353        }
     354
     355        if (*has_children)
     356                mfsdebug("Has children\n");
     357        else
     358                mfsdebug("Has not children\n");
     359
     360out:
     361        return EOK;
    317362}
    318363
Note: See TracChangeset for help on using the changeset viewer.