Changeset f49b0ea in mainline


Ignore:
Timestamp:
2008-06-06T15:16:41Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cde485d
Parents:
f86c184
Message:

Split the 'mount another filesystem here' and 'you are being mounted and the
device is this' mount semantics. Add VFS_MOUNTED VFS operation that corresponds
to the latter and reserve VFS_MOUNT only for the former. Because of this
change, the VFS server does not maintain the mr_node VFS node for the name space
root anymore and the VFS_LOOKUP operation is now not meant to be used on
unmounted file system, not even for looking up the root node of unmounted file
systems. In the light of these changes, TMPFS is now initialized from
tmpfs_mounted() function.

Location:
uspace/srv
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs.c

    rf86c184 rf49b0ea  
    6262                [IPC_METHOD_TO_VFS_OP(VFS_TRUNCATE)] = VFS_OP_DEFINED,
    6363                [IPC_METHOD_TO_VFS_OP(VFS_MOUNT)] = VFS_OP_DEFINED,
     64                [IPC_METHOD_TO_VFS_OP(VFS_MOUNTED)] = VFS_OP_DEFINED,
    6465                [IPC_METHOD_TO_VFS_OP(VFS_UNMOUNT)] = VFS_OP_NULL,
    6566                [IPC_METHOD_TO_VFS_OP(VFS_DESTROY)] = VFS_OP_DEFINED,
     
    106107                callid = async_get_call(&call);
    107108                switch  (IPC_GET_METHOD(call)) {
     109                case VFS_MOUNTED:
     110                        tmpfs_mounted(callid, &call);
     111                        break;
    108112                case VFS_MOUNT:
    109113                        tmpfs_mount(callid, &call);
  • uspace/srv/fs/tmpfs/tmpfs.h

    rf86c184 rf49b0ea  
    4141#include <libadt/hash_table.h>
    4242
     43#ifndef dprintf
    4344#define dprintf(...)    printf(__VA_ARGS__)
     45#endif
    4446
    4547typedef struct tmpfs_dentry {
     
    6365extern libfs_ops_t tmpfs_libfs_ops;
    6466
     67extern void tmpfs_mounted(ipc_callid_t, ipc_call_t *);
    6568extern void tmpfs_mount(ipc_callid_t, ipc_call_t *);
    6669extern void tmpfs_lookup(ipc_callid_t, ipc_call_t *);
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    rf86c184 rf49b0ea  
    394394}
    395395
    396 void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request)
    397 {
    398         dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
    399         fs_index_t mr_index = (fs_index_t) IPC_GET_ARG2(*request);
    400         fs_handle_t mp_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
    401         dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);
    402         fs_index_t mp_index = (fs_index_t) IPC_GET_ARG5(*request);
    403        
    404         if ((mr_index == root->index) &&
    405                 (mp_fs_handle == tmpfs_reg.fs_handle) &&
    406                 (mp_index == mr_index)) {
    407                
    408                 if (mr_dev_handle >= 0) {
    409                         if (tmpfs_restore(mr_dev_handle))
    410                                 ipc_answer_0(rid, EOK);
    411                         else
    412                                 ipc_answer_0(rid, ELIMIT);
    413                 } else
    414                         ipc_answer_0(rid, EOK);
    415         } else
    416                 ipc_answer_0(rid, ENOTSUP);
    417 }
    418 
    419 void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request)
    420 {
     396void tmpfs_mounted(ipc_callid_t rid, ipc_call_t *request)
     397{
     398        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     399
    421400        /* Initialize TMPFS. */
    422401        if (!root && !tmpfs_init()) {
     
    424403                return;
    425404        }
     405
     406        if (dev_handle >= 0) {
     407                if (tmpfs_restore(dev_handle))
     408                        ipc_answer_0(rid, EOK);
     409                else
     410                        ipc_answer_0(rid, ELIMIT);
     411        } else {
     412                        ipc_answer_0(rid, EOK);
     413        }
     414}
     415
     416void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request)
     417{
     418        dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     419        fs_index_t mp_index = (fs_index_t) IPC_GET_ARG2(*request);
     420        fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
     421        dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);
     422       
     423        ipc_answer_0(rid, ENOTSUP);
     424}
     425
     426void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request)
     427{
    426428        libfs_lookup(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request);
    427429}
  • uspace/srv/vfs/vfs.h

    rf86c184 rf49b0ea  
    6666typedef enum {
    6767        VFS_LOOKUP = VFS_LAST_CMN,
     68        VFS_MOUNTED,
    6869        VFS_DESTROY,
    6970        VFS_LAST_CLNT,  /* keep this the last member of this enum */
     
    245246extern link_t fs_head;          /**< List of registered file systems. */
    246247
    247 extern vfs_triplet_t rootfs;    /**< Root node of the root file system. */
     248extern vfs_pair_t rootfs;       /**< Root file system. */
    248249
    249250#define MAX_PATH_LEN            (64 * 1024)
  • uspace/srv/vfs/vfs_lookup.c

    rf86c184 rf49b0ea  
    7373                root = altroot;
    7474        else
    75                 root = (vfs_pair_t *) &rootfs;
     75                root = &rootfs;
    7676
    7777        if (!root->fs_handle)
  • uspace/srv/vfs/vfs_ops.c

    rf86c184 rf49b0ea  
    6363
    6464futex_t rootfs_futex = FUTEX_INITIALIZER;
    65 vfs_triplet_t rootfs = {
     65vfs_pair_t rootfs = {
    6666        .fs_handle = 0,
    67         .dev_handle = 0,
    68         .index = 0,
     67        .dev_handle = 0
    6968};
    70 
    71 static int
    72 lookup_root(fs_handle_t fs_handle, dev_handle_t dev_handle,
    73     vfs_lookup_res_t *result)
    74 {
    75         vfs_pair_t altroot = {
    76                 .fs_handle = fs_handle,
    77                 .dev_handle = dev_handle,
    78         };
    79 
    80         return vfs_lookup_internal("/", L_DIRECTORY, result, &altroot);
    81 }
    8269
    8370void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
     
    164151        buf[size] = '\0';
    165152
    166         /*
    167          * Lookup the root node of the filesystem being mounted.
    168          * In this case, we don't need to take the namespace_futex as the root
    169          * node cannot be removed. However, we do take a reference to it so
    170          * that we can track how many times it has been mounted.
    171          */
    172         vfs_lookup_res_t mr_res;
    173         rc = lookup_root(fs_handle, dev_handle, &mr_res);
    174         if (rc != EOK) {
    175                 free(buf);
    176                 ipc_answer_0(rid, rc);
    177                 return;
    178         }
    179         vfs_node_t *mr_node = vfs_node_get(&mr_res);
    180         if (!mr_node) {
    181                 free(buf);
    182                 ipc_answer_0(rid, ENOMEM);
    183                 return;
    184         }
    185 
    186         /* Finally, we need to resolve the path to the mountpoint. */
     153        /* Resolve the path to the mountpoint. */
    187154        vfs_lookup_res_t mp_res;
    188155        futex_down(&rootfs_futex);
     
    194161                        rwlock_write_unlock(&namespace_rwlock);
    195162                        futex_up(&rootfs_futex);
    196                         vfs_node_put(mr_node);
    197163                        free(buf);
    198164                        ipc_answer_0(rid, EBUSY);
     
    204170                        rwlock_write_unlock(&namespace_rwlock);
    205171                        futex_up(&rootfs_futex);
    206                         vfs_node_put(mr_node);  /* failed -> drop reference */
    207172                        free(buf);
    208173                        ipc_answer_0(rid, rc);
     
    213178                        rwlock_write_unlock(&namespace_rwlock);
    214179                        futex_up(&rootfs_futex);
    215                         vfs_node_put(mr_node);  /* failed -> drop reference */
    216180                        free(buf);
    217181                        ipc_answer_0(rid, ENOMEM);
     
    233197                        free(buf);
    234198                       
    235                         /* Inform the mount point about the root mount. */
    236                         phone = vfs_grab_phone(mr_res.triplet.fs_handle);
    237                         rc = async_req_5_0(phone, VFS_MOUNT,
    238                             (ipcarg_t) mr_res.triplet.dev_handle,
    239                             (ipcarg_t) mr_res.triplet.index,
    240                             (ipcarg_t) mr_res.triplet.fs_handle,
    241                             (ipcarg_t) mr_res.triplet.dev_handle,
    242                             (ipcarg_t) mr_res.triplet.index);
     199                        /* Tell the mountee that it is being mounted. */
     200                        phone = vfs_grab_phone(fs_handle);
     201                        rc = async_req_1_0(phone, VFS_MOUNTED,
     202                            (ipcarg_t) dev_handle);
    243203                        vfs_release_phone(phone);
    244204
    245                         if (rc == EOK)
    246                                 rootfs = mr_res.triplet;
    247                         else
    248                                 vfs_node_put(mr_node);
     205                        if (rc == EOK) {
     206                                rootfs.fs_handle = fs_handle;
     207                                rootfs.dev_handle = dev_handle;
     208                        }
    249209
    250210                        futex_up(&rootfs_futex);
     
    258218                        futex_up(&rootfs_futex);
    259219                        free(buf);
    260                         vfs_node_put(mr_node);  /* failed -> drop reference */
    261220                        ipc_answer_0(rid, ENOENT);
    262221                        return;
     
    269228        /*
    270229         * At this point, we have all necessary pieces: file system and device
    271          * handles, and we know the mount point VFS node and also the root node
    272          * of the file system being mounted.
    273          */
    274 
    275         /**
    276          * @todo
    277          * Add more IPC parameters so that we can send mount mode/flags.
    278          */
     230         * handles, and we know the mount point VFS node.
     231         */
     232
    279233        phone = vfs_grab_phone(mp_res.triplet.fs_handle);
    280         rc = async_req_5_0(phone, VFS_MOUNT,
     234        rc = async_req_4_0(phone, VFS_MOUNT,
    281235            (ipcarg_t) mp_res.triplet.dev_handle,
    282236            (ipcarg_t) mp_res.triplet.index,
    283             (ipcarg_t) mr_res.triplet.fs_handle,
    284             (ipcarg_t) mr_res.triplet.dev_handle,
    285             (ipcarg_t) mr_res.triplet.index);
     237            (ipcarg_t) fs_handle,
     238            (ipcarg_t) dev_handle);
    286239        vfs_release_phone(phone);
    287240
    288241        if (rc != EOK) {
    289                 /* Mount failed, drop references to mr_node and mp_node. */
    290                 vfs_node_put(mr_node);
     242                /* Mount failed, drop reference to mp_node. */
    291243                if (mp_node)
    292244                        vfs_node_put(mp_node);
Note: See TracChangeset for help on using the changeset viewer.