Changeset 984a9ba in mainline for uspace/srv/fs/tmpfs


Ignore:
Timestamp:
2018-07-05T09:34:09Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63d46341
Parents:
76f566d
Message:

do not expose the call capability handler from the async framework

Keep the call capability handler encapsulated within the async framework
and do not expose it explicitly via its API. Use the pointer to
ipc_call_t as the sole object identifying an IPC call in the code that
uses the async framework.

This plugs a major leak in the abstraction and also simplifies both the
async framework (slightly) and all IPC servers.

File:
1 edited

Legend:

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

    r76f566d r984a9ba  
    5555
    5656/** All root nodes have index 0. */
    57 #define TMPFS_SOME_ROOT         0
     57#define TMPFS_SOME_ROOT  0
     58
    5859/** Global counter for assigning node indices. Shared by all instances. */
    5960fs_index_t tmpfs_next_index = 1;
     
    308309        if (!nodep)
    309310                return ENOMEM;
     311
    310312        tmpfs_node_initialize(nodep);
    311313        nodep->bp = malloc(sizeof(fs_node_t));
     
    314316                return ENOMEM;
    315317        }
     318
    316319        fs_node_initialize(nodep->bp);
    317         nodep->bp->data = nodep;        /* link the FS and TMPFS nodes */
     320        nodep->bp->data = nodep;  /* Link the FS and TMPFS nodes */
    318321
    319322        rc = tmpfs_root_get(&rootfn, service_id);
     
    323326        else
    324327                nodep->index = tmpfs_next_index++;
     328
    325329        nodep->service_id = service_id;
    326330        if (lflag & L_DIRECTORY)
     
    480484         * Receive the read request.
    481485         */
    482         cap_call_handle_t chandle;
     486        ipc_call_t call;
    483487        size_t size;
    484         if (!async_data_read_receive(&chandle, &size)) {
    485                 async_answer_0(chandle, EINVAL);
     488        if (!async_data_read_receive(&call, &size)) {
     489                async_answer_0(&call, EINVAL);
    486490                return EINVAL;
    487491        }
     
    490494        if (nodep->type == TMPFS_FILE) {
    491495                bytes = min(nodep->size - pos, size);
    492                 (void) async_data_read_finalize(chandle, nodep->data + pos,
     496                (void) async_data_read_finalize(&call, nodep->data + pos,
    493497                    bytes);
    494498        } else {
     
    506510
    507511                if (lnk == NULL) {
    508                         async_answer_0(chandle, ENOENT);
     512                        async_answer_0(&call, ENOENT);
    509513                        return ENOENT;
    510514                }
     
    512516                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    513517
    514                 (void) async_data_read_finalize(chandle, dentryp->name,
     518                (void) async_data_read_finalize(&call, dentryp->name,
    515519                    str_size(dentryp->name) + 1);
    516520                bytes = 1;
     
    543547         * Receive the write request.
    544548         */
    545         cap_call_handle_t chandle;
     549        ipc_call_t call;
    546550        size_t size;
    547         if (!async_data_write_receive(&chandle, &size)) {
    548                 async_answer_0(chandle, EINVAL);
     551        if (!async_data_write_receive(&call, &size)) {
     552                async_answer_0(&call, EINVAL);
    549553                return EINVAL;
    550554        }
     
    555559        if (pos + size <= nodep->size) {
    556560                /* The file size is not changing. */
    557                 (void) async_data_write_finalize(chandle, nodep->data + pos,
     561                (void) async_data_write_finalize(&call, nodep->data + pos,
    558562                    size);
    559563                goto out;
     
    569573        void *newdata = realloc(nodep->data, nodep->size + delta);
    570574        if (!newdata) {
    571                 async_answer_0(chandle, ENOMEM);
     575                async_answer_0(&call, ENOMEM);
    572576                size = 0;
    573577                goto out;
     
    577581        nodep->size += delta;
    578582        nodep->data = newdata;
    579         (void) async_data_write_finalize(chandle, nodep->data + pos, size);
     583        (void) async_data_write_finalize(&call, nodep->data + pos, size);
    580584
    581585out:
Note: See TracChangeset for help on using the changeset viewer.