Subversion Repositories HelenOS

Rev

Rev 4537 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4537 Rev 4668
Line 41... Line 41...
41
#include <ipc/ipc.h>
41
#include <ipc/ipc.h>
42
#include <as.h>
42
#include <as.h>
43
#include <assert.h>
43
#include <assert.h>
44
#include <dirent.h>
44
#include <dirent.h>
45
#include <mem.h>
45
#include <mem.h>
-
 
46
#include <sys/stat.h>
46
 
47
 
47
/** Register file system server.
48
/** Register file system server.
48
 *
49
 *
49
 * This function abstracts away the tedious registration protocol from
50
 * This function abstracts away the tedious registration protocol from
50
 * file system implementations and lets them to reuse this registration glue
51
 * file system implementations and lets them to reuse this registration glue
Line 67... Line 68...
67
     * Tell VFS that we are here and want to get registered.
68
     * Tell VFS that we are here and want to get registered.
68
     * We use the async framework because VFS will answer the request
69
     * We use the async framework because VFS will answer the request
69
     * out-of-order, when it knows that the operation succeeded or failed.
70
     * out-of-order, when it knows that the operation succeeded or failed.
70
     */
71
     */
71
    ipc_call_t answer;
72
    ipc_call_t answer;
72
    aid_t req = async_send_0(vfs_phone, VFS_REGISTER, &answer);
73
    aid_t req = async_send_0(vfs_phone, VFS_IN_REGISTER, &answer);
73
 
74
 
74
    /*
75
    /*
75
     * Send our VFS info structure to VFS.
76
     * Send our VFS info structure to VFS.
76
     */
77
     */
77
    int rc = ipc_data_write_start(vfs_phone, info, sizeof(*info));
78
    int rc = ipc_data_write_start(vfs_phone, info, sizeof(*info));
Line 102... Line 103...
102
        async_wait_for(req, NULL);
103
        async_wait_for(req, NULL);
103
        return rc;
104
        return rc;
104
    }
105
    }
105
     
106
     
106
    /*
107
    /*
107
     * Pick up the answer for the request to the VFS_REQUEST call.
108
     * Pick up the answer for the request to the VFS_IN_REQUEST call.
108
     */
109
     */
109
    async_wait_for(req, NULL);
110
    async_wait_for(req, NULL);
110
    reg->fs_handle = (int) IPC_GET_ARG1(answer);
111
    reg->fs_handle = (int) IPC_GET_ARG1(answer);
111
   
112
   
112
    /*
113
    /*
Line 184... Line 185...
184
        ipc_answer_0(rid, rc);
185
        ipc_answer_0(rid, rc);
185
        return;
186
        return;
186
    }
187
    }
187
   
188
   
188
    ipc_call_t answer;
189
    ipc_call_t answer;
189
    aid_t msg = async_send_1(mountee_phone, VFS_MOUNTED, mr_dev_handle,
190
    aid_t msg = async_send_1(mountee_phone, VFS_OUT_MOUNTED, mr_dev_handle,
190
        &answer);
191
        &answer);
191
    ipc_forward_fast(callid, mountee_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
192
    ipc_forward_fast(callid, mountee_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
192
    async_wait_for(msg, &rc);
193
    async_wait_for(msg, &rc);
193
   
194
   
194
    if (rc == EOK) {
195
    if (rc == EOK) {
Line 211... Line 212...
211
 *
212
 *
212
 * @param ops       libfs operations structure with function pointers to
213
 * @param ops       libfs operations structure with function pointers to
213
 *                  file system implementation
214
 *                  file system implementation
214
 * @param fs_handle File system handle of the file system where to perform
215
 * @param fs_handle File system handle of the file system where to perform
215
 *                  the lookup.
216
 *                  the lookup.
216
 * @param rid       Request ID of the VFS_LOOKUP request.
217
 * @param rid       Request ID of the VFS_OUT_LOOKUP request.
217
 * @param request   VFS_LOOKUP request data itself.
218
 * @param request   VFS_OUT_LOOKUP request data itself.
218
 *
219
 *
219
 */
220
 */
220
void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
221
void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
221
    ipc_call_t *request)
222
    ipc_call_t *request)
222
{
223
{
Line 235... Line 236...
235
    fs_node_t *par = NULL;
236
    fs_node_t *par = NULL;
236
    fs_node_t *cur = ops->root_get(dev_handle);
237
    fs_node_t *cur = ops->root_get(dev_handle);
237
    fs_node_t *tmp = NULL;
238
    fs_node_t *tmp = NULL;
238
 
239
 
239
    if (cur->mp_data.mp_active) {
240
    if (cur->mp_data.mp_active) {
240
        ipc_forward_slow(rid, cur->mp_data.phone, VFS_LOOKUP,
241
        ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
241
            next, last, cur->mp_data.dev_handle, lflag, index,
242
            next, last, cur->mp_data.dev_handle, lflag, index,
242
            IPC_FF_ROUTE_FROM_ME);
243
            IPC_FF_ROUTE_FROM_ME);
243
        ops->node_put(cur);
244
        ops->node_put(cur);
244
        return;
245
        return;
245
    }
246
    }
Line 270... Line 271...
270
            if (next > last)
271
            if (next > last)
271
                next = last = first;
272
                next = last = first;
272
            else
273
            else
273
                next--;
274
                next--;
274
               
275
               
275
            ipc_forward_slow(rid, tmp->mp_data.phone, VFS_LOOKUP,
276
            ipc_forward_slow(rid, tmp->mp_data.phone,
276
                next, last, tmp->mp_data.dev_handle, lflag, index,
277
                VFS_OUT_LOOKUP, next, last, tmp->mp_data.dev_handle,
277
                IPC_FF_ROUTE_FROM_ME);
278
                lflag, index, IPC_FF_ROUTE_FROM_ME);
278
            ops->node_put(cur);
279
            ops->node_put(cur);
279
            ops->node_put(tmp);
280
            ops->node_put(tmp);
280
            if (par)
281
            if (par)
281
                ops->node_put(par);
282
                ops->node_put(par);
282
            return;
283
            return;
Line 426... Line 427...
426
        ops->node_put(cur);
427
        ops->node_put(cur);
427
    if (tmp)
428
    if (tmp)
428
        ops->node_put(tmp);
429
        ops->node_put(tmp);
429
}
430
}
430
 
431
 
-
 
432
void libfs_stat(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
-
 
433
    ipc_call_t *request)
-
 
434
{
-
 
435
    dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
-
 
436
    fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-
 
437
    fs_node_t *fn = ops->node_get(dev_handle, index);
-
 
438
 
-
 
439
    ipc_callid_t callid;
-
 
440
    size_t size;
-
 
441
    if (!ipc_data_read_receive(&callid, &size) ||
-
 
442
        size != sizeof(struct stat)) {
-
 
443
        ipc_answer_0(callid, EINVAL);
-
 
444
        ipc_answer_0(rid, EINVAL);
-
 
445
        return;
-
 
446
    }
-
 
447
 
-
 
448
    struct stat stat;
-
 
449
    memset(&stat, 0, sizeof(struct stat));
-
 
450
   
-
 
451
    stat.fs_handle = fs_handle;
-
 
452
    stat.dev_handle = dev_handle;
-
 
453
    stat.index = index;
-
 
454
    stat.lnkcnt = ops->lnkcnt_get(fn);
-
 
455
    stat.is_file = ops->is_file(fn);
-
 
456
    stat.size = ops->size_get(fn);
-
 
457
 
-
 
458
    ipc_data_read_finalize(callid, &stat, sizeof(struct stat));
-
 
459
    ipc_answer_0(rid, EOK);
-
 
460
}
-
 
461
 
431
/** Open VFS triplet.
462
/** Open VFS triplet.
432
 *
463
 *
433
 * @param ops       libfs operations structure with function pointers to
464
 * @param ops       libfs operations structure with function pointers to
434
 *                  file system implementation
465
 *                  file system implementation
435
 * @param rid       Request ID of the VFS_OPEN_NODE request.
466
 * @param rid       Request ID of the VFS_OUT_OPEN_NODE request.
436
 * @param request   VFS_OPEN_NODE request data itself.
467
 * @param request   VFS_OUT_OPEN_NODE request data itself.
437
 *
468
 *
438
 */
469
 */
439
void libfs_open_node(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
470
void libfs_open_node(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
440
    ipc_call_t *request)
471
    ipc_call_t *request)
441
{
472
{