Changeset 41202a9 in mainline


Ignore:
Timestamp:
2011-03-26T10:38:09Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7cb975e
Parents:
54caa41b
Message:

Lot of improvements to the MinixFS driver:

  • Add mfs_node_put()
  • Add mfs_node_open()
  • Add mfs_index_get()
  • Add mfs_lnkcnt_get()

Add the mfs_dentry.c file which I forgot to add before.

Location:
uspace/srv/fs/minixfs
Files:
1 added
3 edited

Legend:

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

    r54caa41b r41202a9  
    9494       
    9595                callid = async_get_call(&call);
    96                 switch  (IPC_GET_IMETHOD(call)) {
     96                int method = IPC_GET_IMETHOD(call);
     97
     98                mfsdebug(NAME "method = %d\n", method);
     99                switch  (method) {
    97100                case IPC_M_PHONE_HUNGUP:
    98101                        return;
     
    108111                        break;
    109112                case VFS_OUT_LOOKUP:
     113                        mfsdebug("lookup called\n");
    110114                        mfs_lookup(callid, &call);
    111115                        break;
  • uspace/srv/fs/minixfs/mfs.h

    r54caa41b r41202a9  
    9898
    9999        bool dirty;
     100        fs_index_t index;
    100101};
    101102
  • uspace/srv/fs/minixfs/mfs_ops.c

    r54caa41b r41202a9  
    4444                        fs_index_t index);
    4545
     46static int mfs_node_put(fs_node_t *fsnode);
     47static int mfs_node_open(fs_node_t *fsnode);
     48static fs_index_t mfs_index_get(fs_node_t *fsnode);
     49static unsigned mfs_lnkcnt_get(fs_node_t *fsnode);
     50
    4651static LIST_INITIALIZE(inst_list);
    4752static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex);
     
    5459        .is_file = mfs_is_file,
    5560        .node_get = mfs_node_get,
     61        .node_put = mfs_node_put,
     62        .node_open = mfs_node_open,
     63        .index_get = mfs_index_get,
    5664        .plb_get_char = mfs_plb_get_char,
    57         .has_children = mfs_has_children
     65        .has_children = mfs_has_children,
     66        .lnkcnt_get = mfs_lnkcnt_get
    5867};
    5968
     
    221230        assert(mnode->ino_i);
    222231
     232        mfsdebug("inode size is %d\n", (int) mnode->ino_i->i_size);
     233
    223234        return mnode->ino_i->i_size;
    224235}
     
    236247        struct mfs_instance *instance;
    237248
     249        mfsdebug("node_get called\n");
     250
    238251        rc = mfs_instance_get(devmap_handle, &instance);
    239252
     
    242255
    243256        return mfs_node_core_get(rfn, instance, index);
     257}
     258
     259static int mfs_node_put(fs_node_t *fsnode)
     260{
     261        struct mfs_node *mnode = fsnode->data;
     262
     263        mfsdebug("mfs_node_put()\n");
     264
     265        assert(mnode->ino_i);
     266
     267        if (mnode->ino_i->dirty) {
     268                /*TODO: Write inode on disk*/
     269        }
     270
     271        free(mnode->ino_i);
     272        free(mnode);
     273
     274        return EOK;
     275}
     276
     277static int mfs_node_open(fs_node_t *fsnode)
     278{
     279        mfsdebug("mfs_node_open()\n");
     280        /*
     281         * Opening a file is stateless, nothing
     282         * to be done here.
     283         */
     284        return EOK;
     285}
     286
     287static fs_index_t mfs_index_get(fs_node_t *fsnode)
     288{
     289        struct mfs_node *mnode = fsnode->data;
     290
     291        mfsdebug("mfs_index_get()\n");
     292
     293        assert(mnode->ino_i);
     294        return mnode->ino_i->index;
     295}
     296
     297static unsigned mfs_lnkcnt_get(fs_node_t *fsnode)
     298{
     299        unsigned rc;
     300        struct mfs_node *mnode = fsnode->data;
     301
     302        assert(mnode);
     303        assert(mnode->ino_i);
     304
     305        rc = mnode->ino_i->i_nlinks;
     306        mfsdebug("mfs_lnkcnt_get(): %u\n", rc);
     307        return rc;
    244308}
    245309
     
    280344                return -1;
    281345
     346        ino_i->index = index;
    282347        mnode->ino_i = ino_i;
    283348
     
    285350        node->data = mnode;
    286351        *rfn = node;
     352
     353        mfsdebug("node_get_core(%d) OK\n", (int) index);
    287354
    288355        return EOK;
     
    310377int mfs_root_get(fs_node_t **rfn, devmap_handle_t handle)
    311378{
    312         return mfs_node_get(rfn, handle, MFS_ROOT_INO);
     379        int rc = mfs_node_get(rfn, handle, MFS_ROOT_INO);
     380
     381        mfsdebug("mfs_root_get %s\n", rc == EOK ? "OK" : "FAIL");
     382        return rc;
    313383}
    314384
     
    353423        }
    354424
     425out:
     426
    355427        if (*has_children)
    356428                mfsdebug("Has children\n");
     
    358430                mfsdebug("Has not children\n");
    359431
    360 out:
    361432        return EOK;
    362433}
Note: See TracChangeset for help on using the changeset viewer.