Changeset 668f1949 in mainline


Ignore:
Timestamp:
2011-04-09T15:37:20Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d0f3692
Parents:
e666ddc
Message:
  • mfs_read partially implemented, only directories are supported (yet)
  • minor code cleanup
Location:
uspace/srv/fs/minixfs
Files:
3 edited

Legend:

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

    re666ddc r668f1949  
    9999                        return;
    100100                case VFS_OUT_MOUNTED:
    101                         mfsdebug("Mount request received\n");
    102101                        mfs_mounted(callid, &call);
    103102                        break;
     
    109108                        break;
    110109                case VFS_OUT_LOOKUP:
    111                         mfsdebug("lookup called\n");
    112110                        mfs_lookup(callid, &call);
     111                        break;
     112                case VFS_OUT_READ:
     113                        mfs_read(callid, &call);
    113114                        break;
    114115                default:
  • uspace/srv/fs/minixfs/mfs.h

    re666ddc r668f1949  
    3535
    3636#include <minix.h>
     37#include <macros.h>
    3738#include <libblock.h>
    3839#include <libfs.h>
     
    153154extern void mfs_stat(ipc_callid_t rid, ipc_call_t *request);
    154155
     156extern void
     157mfs_read(ipc_callid_t rid, ipc_call_t *request);
     158
     159
    155160/*mfs_inode.c*/
    156161int
  • uspace/srv/fs/minixfs/mfs_ops.c

    re666ddc r668f1949  
    5959static int mfs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name);
    6060
    61 static
    62 int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
     61static int mfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle,
    6362                        fs_index_t index);
    6463
     
    381380        assert(mnode->ino_i);
    382381
    383         mfsdebug("inode links = %d\n", (int) mnode->ino_i->i_nlinks);
    384         mfsdebug("inode size is %d\n", (int) mnode->ino_i->i_size);
    385 
    386382        return mnode->ino_i->i_size;
    387383}
     
    399395        struct mfs_instance *instance;
    400396
    401         mfsdebug("mfs_node_get()\n");
    402 
    403397        rc = mfs_instance_get(devmap_handle, &instance);
    404398
     
    412406{
    413407        struct mfs_node *mnode = fsnode->data;
    414 
    415         mfsdebug("mfs_node_put()\n");
    416408
    417409        put_inode(mnode);
     
    435427        struct mfs_node *mnode = fsnode->data;
    436428
    437         mfsdebug("mfs_index_get()\n");
    438 
    439429        assert(mnode->ino_i);
    440430        return mnode->ino_i->index;
     
    450440
    451441        rc = mnode->ino_i->i_nlinks;
    452         mfsdebug("mfs_lnkcnt_get(): %u\n", rc);
    453442        return rc;
    454443}
     
    515504{
    516505        int rc = mfs_node_get(rfn, handle, MFS_ROOT_INO);
    517 
    518         mfsdebug("mfs_root_get %s\n", rc == EOK ? "OK" : "FAIL");
    519506        return rc;
    520507}
     
    577564}
    578565
    579 /*
    580  * Find a filesystem instance given the devmap handle
    581  */
     566void
     567mfs_read(ipc_callid_t rid, ipc_call_t *request)
     568{
     569        int rc;
     570        devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(*request);
     571        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     572        aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request),
     573                                IPC_GET_ARG4(*request));
     574        fs_node_t *fn;
     575
     576        rc = mfs_node_get(&fn, handle, index);
     577        if (rc != EOK) {
     578                async_answer_0(rid, rc);
     579                return;
     580        }
     581        if (!fn) {
     582                async_answer_0(rid, ENOENT);
     583                return;
     584        }
     585
     586        struct mfs_node *mnode;
     587        struct mfs_ino_info *ino_i;
     588        size_t len, bytes = 0;
     589        ipc_callid_t callid;
     590
     591        mnode = fn->data;
     592        ino_i = mnode->ino_i;
     593
     594        if (!async_data_read_receive(&callid, &len)) {
     595                mfs_node_put(fn);
     596                async_answer_0(callid, EINVAL);
     597                async_answer_0(rid, EINVAL);
     598                return;
     599        }
     600
     601        if (S_ISDIR(ino_i->i_mode)) {
     602                aoff64_t spos = pos;
     603                struct mfs_dentry_info *d_info;
     604
     605                while (1) {
     606                        d_info = read_directory_entry(mnode, pos);
     607                        if (!d_info) {
     608                                /*Reached the end of the dentries list*/
     609                                break;
     610                        }
     611
     612                        if (d_info->d_inum) {
     613                                /*Dentry found!*/
     614                                mfsdebug("DENTRY FOUND %s!!\n", d_info->d_name);
     615                                goto found;
     616                        }
     617
     618                        free(d_info);
     619                        pos++;
     620                }
     621
     622                rc = mfs_node_put(fn);
     623                async_answer_0(callid, rc != EOK ? rc : ENOENT);
     624                async_answer_1(rid, rc != EOK ? rc : ENOENT, 0);
     625                return;
     626found:
     627                async_data_read_finalize(callid, d_info->d_name,
     628                                str_size(d_info->d_name) + 1);
     629                bytes = ((pos - spos) + 1);
     630        }
     631
     632        rc = mfs_node_put(fn);
     633        async_answer_1(rid, rc, (sysarg_t)bytes);
     634}
     635
    582636int mfs_instance_get(devmap_handle_t handle, struct mfs_instance **instance)
    583637{
Note: See TracChangeset for help on using the changeset viewer.