Changeset 984a9ba in mainline for uspace/lib/ext4/src/ops.c


Ignore:
Timestamp:
2018-07-05T09:34:09Z (6 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/lib/ext4/src/ops.c

    r76f566d r984a9ba  
    5858/* Forward declarations of auxiliary functions */
    5959
    60 static errno_t ext4_read_directory(cap_call_handle_t, aoff64_t, size_t,
     60static errno_t ext4_read_directory(ipc_call_t *, aoff64_t, size_t,
    6161    ext4_instance_t *, ext4_inode_ref_t *, size_t *);
    62 static errno_t ext4_read_file(cap_call_handle_t, aoff64_t, size_t, ext4_instance_t *,
     62static errno_t ext4_read_file(ipc_call_t *, aoff64_t, size_t, ext4_instance_t *,
    6363    ext4_inode_ref_t *, size_t *);
    6464static bool ext4_is_dots(const uint8_t *, size_t);
     
    10211021         * Receive the read request.
    10221022         */
    1023         cap_call_handle_t chandle;
     1023        ipc_call_t call;
    10241024        size_t size;
    1025         if (!async_data_read_receive(&chandle, &size)) {
    1026                 async_answer_0(chandle, EINVAL);
     1025        if (!async_data_read_receive(&call, &size)) {
     1026                async_answer_0(&call, EINVAL);
    10271027                return EINVAL;
    10281028        }
     
    10311031        errno_t rc = ext4_instance_get(service_id, &inst);
    10321032        if (rc != EOK) {
    1033                 async_answer_0(chandle, rc);
     1033                async_answer_0(&call, rc);
    10341034                return rc;
    10351035        }
     
    10391039        rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref);
    10401040        if (rc != EOK) {
    1041                 async_answer_0(chandle, rc);
     1041                async_answer_0(&call, rc);
    10421042                return rc;
    10431043        }
     
    10461046        if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode,
    10471047            EXT4_INODE_MODE_FILE)) {
    1048                 rc = ext4_read_file(chandle, pos, size, inst, inode_ref,
     1048                rc = ext4_read_file(&call, pos, size, inst, inode_ref,
    10491049                    rbytes);
    10501050        } else if (ext4_inode_is_type(inst->filesystem->superblock,
    10511051            inode_ref->inode, EXT4_INODE_MODE_DIRECTORY)) {
    1052                 rc = ext4_read_directory(chandle, pos, size, inst, inode_ref,
     1052                rc = ext4_read_directory(&call, pos, size, inst, inode_ref,
    10531053                    rbytes);
    10541054        } else {
    10551055                /* Other inode types not supported */
    1056                 async_answer_0(chandle, ENOTSUP);
     1056                async_answer_0(&call, ENOTSUP);
    10571057                rc = ENOTSUP;
    10581058        }
     
    10841084/** Read data from directory.
    10851085 *
    1086  * @param chandle    IPC id of call (for communication)
     1086 * @param call      IPC call
    10871087 * @param pos       Position to start reading from
    10881088 * @param size      How many bytes to read
     
    10941094 *
    10951095 */
    1096 errno_t ext4_read_directory(cap_call_handle_t chandle, aoff64_t pos, size_t size,
     1096errno_t ext4_read_directory(ipc_call_t *call, aoff64_t pos, size_t size,
    10971097    ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
    10981098{
     
    11001100        errno_t rc = ext4_directory_iterator_init(&it, inode_ref, pos);
    11011101        if (rc != EOK) {
    1102                 async_answer_0(chandle, rc);
     1102                async_answer_0(call, rc);
    11031103                return rc;
    11041104        }
     
    11291129                if (buf == NULL) {
    11301130                        ext4_directory_iterator_fini(&it);
    1131                         async_answer_0(chandle, ENOMEM);
     1131                        async_answer_0(call, ENOMEM);
    11321132                        return ENOMEM;
    11331133                }
     
    11371137                found = true;
    11381138
    1139                 (void) async_data_read_finalize(chandle, buf, name_size + 1);
     1139                (void) async_data_read_finalize(call, buf, name_size + 1);
    11401140                free(buf);
    11411141                break;
     
    11451145                if (rc != EOK) {
    11461146                        ext4_directory_iterator_fini(&it);
    1147                         async_answer_0(chandle, rc);
     1147                        async_answer_0(call, rc);
    11481148                        return rc;
    11491149                }
     
    11681168                return EOK;
    11691169        } else {
    1170                 async_answer_0(chandle, ENOENT);
     1170                async_answer_0(call, ENOENT);
    11711171                return ENOENT;
    11721172        }
     
    11751175/** Read data from file.
    11761176 *
    1177  * @param chandle    IPC id of call (for communication)
     1177 * @param call      IPC call
    11781178 * @param pos       Position to start reading from
    11791179 * @param size      How many bytes to read
     
    11851185 *
    11861186 */
    1187 errno_t ext4_read_file(cap_call_handle_t chandle, aoff64_t pos, size_t size,
     1187errno_t ext4_read_file(ipc_call_t *call, aoff64_t pos, size_t size,
    11881188    ext4_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
    11891189{
     
    11931193        if (pos >= file_size) {
    11941194                /* Read 0 bytes successfully */
    1195                 async_data_read_finalize(chandle, NULL, 0);
     1195                async_data_read_finalize(call, NULL, 0);
    11961196                *rbytes = 0;
    11971197                return EOK;
     
    12131213            file_block, &fs_block);
    12141214        if (rc != EOK) {
    1215                 async_answer_0(chandle, rc);
     1215                async_answer_0(call, rc);
    12161216                return rc;
    12171217        }
     
    12271227                buffer = malloc(bytes);
    12281228                if (buffer == NULL) {
    1229                         async_answer_0(chandle, ENOMEM);
     1229                        async_answer_0(call, ENOMEM);
    12301230                        return ENOMEM;
    12311231                }
     
    12331233                memset(buffer, 0, bytes);
    12341234
    1235                 rc = async_data_read_finalize(chandle, buffer, bytes);
     1235                rc = async_data_read_finalize(call, buffer, bytes);
    12361236                *rbytes = bytes;
    12371237
     
    12441244        rc = block_get(&block, inst->service_id, fs_block, BLOCK_FLAGS_NONE);
    12451245        if (rc != EOK) {
    1246                 async_answer_0(chandle, rc);
     1246                async_answer_0(call, rc);
    12471247                return rc;
    12481248        }
    12491249
    12501250        assert(offset_in_block + bytes <= block_size);
    1251         rc = async_data_read_finalize(chandle, block->data + offset_in_block, bytes);
     1251        rc = async_data_read_finalize(call, block->data + offset_in_block, bytes);
    12521252        if (rc != EOK) {
    12531253                block_put(block);
     
    12831283                return rc;
    12841284
    1285         cap_call_handle_t chandle;
     1285        ipc_call_t call;
    12861286        size_t len;
    1287         if (!async_data_write_receive(&chandle, &len)) {
     1287        if (!async_data_write_receive(&call, &len)) {
    12881288                rc = EINVAL;
    1289                 async_answer_0(chandle, rc);
     1289                async_answer_0(&call, rc);
    12901290                goto exit;
    12911291        }
     
    13111311            &fblock);
    13121312        if (rc != EOK) {
    1313                 async_answer_0(chandle, rc);
     1313                async_answer_0(&call, rc);
    13141314                goto exit;
    13151315        }
     
    13281328                                    &fblock, true);
    13291329                                if (rc != EOK) {
    1330                                         async_answer_0(chandle, rc);
     1330                                        async_answer_0(&call, rc);
    13311331                                        goto exit;
    13321332                                }
     
    13361336                            &fblock, false);
    13371337                        if (rc != EOK) {
    1338                                 async_answer_0(chandle, rc);
     1338                                async_answer_0(&call, rc);
    13391339                                goto exit;
    13401340                        }
     
    13421342                        rc = ext4_balloc_alloc_block(inode_ref, &fblock);
    13431343                        if (rc != EOK) {
    1344                                 async_answer_0(chandle, rc);
     1344                                async_answer_0(&call, rc);
    13451345                                goto exit;
    13461346                        }
     
    13501350                        if (rc != EOK) {
    13511351                                ext4_balloc_free_block(inode_ref, fblock);
    1352                                 async_answer_0(chandle, rc);
     1352                                async_answer_0(&call, rc);
    13531353                                goto exit;
    13541354                        }
     
    13631363        rc = block_get(&write_block, service_id, fblock, flags);
    13641364        if (rc != EOK) {
    1365                 async_answer_0(chandle, rc);
     1365                async_answer_0(&call, rc);
    13661366                goto exit;
    13671367        }
     
    13701370                memset(write_block->data, 0, block_size);
    13711371
    1372         rc = async_data_write_finalize(chandle, write_block->data +
     1372        rc = async_data_write_finalize(&call, write_block->data +
    13731373            (pos % block_size), bytes);
    13741374        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.