Changeset 984a9ba in mainline for uspace/srv/fs


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.

Location:
uspace/srv/fs
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/cdfs/cdfs_ops.c

    r76f566d r984a9ba  
    12731273        }
    12741274
    1275         cap_call_handle_t chandle;
     1275        ipc_call_t call;
    12761276        size_t len;
    1277         if (!async_data_read_receive(&chandle, &len)) {
    1278                 async_answer_0(chandle, EINVAL);
     1277        if (!async_data_read_receive(&call, &len)) {
     1278                async_answer_0(&call, EINVAL);
    12791279                return EINVAL;
    12801280        }
     
    12831283                if (pos >= node->size) {
    12841284                        *rbytes = 0;
    1285                         async_data_read_finalize(chandle, NULL, 0);
     1285                        async_data_read_finalize(&call, NULL, 0);
    12861286                } else {
    12871287                        cdfs_lba_t lba = pos / BLOCK_SIZE;
     
    12951295                            BLOCK_FLAGS_NONE);
    12961296                        if (rc != EOK) {
    1297                                 async_answer_0(chandle, rc);
     1297                                async_answer_0(&call, rc);
    12981298                                return rc;
    12991299                        }
    13001300
    1301                         async_data_read_finalize(chandle, block->data + offset,
     1301                        async_data_read_finalize(&call, block->data + offset,
    13021302                            *rbytes);
    13031303                        rc = block_put(block);
     
    13081308                link_t *link = list_nth(&node->cs_list, pos);
    13091309                if (link == NULL) {
    1310                         async_answer_0(chandle, ENOENT);
     1310                        async_answer_0(&call, ENOENT);
    13111311                        return ENOENT;
    13121312                }
     
    13161316
    13171317                *rbytes = 1;
    1318                 async_data_read_finalize(chandle, dentry->name,
     1318                async_data_read_finalize(&call, dentry->name,
    13191319                    str_size(dentry->name) + 1);
    13201320        }
  • uspace/srv/fs/exfat/exfat_ops.c

    r76f566d r984a9ba  
    13411341        nodep = EXFAT_NODE(fn);
    13421342
    1343         cap_call_handle_t chandle;
     1343        ipc_call_t call;
    13441344        size_t len;
    1345         if (!async_data_read_receive(&chandle, &len)) {
     1345        if (!async_data_read_receive(&call, &len)) {
    13461346                exfat_node_put(fn);
    1347                 async_answer_0(chandle, EINVAL);
     1347                async_answer_0(&call, EINVAL);
    13481348                return EINVAL;
    13491349        }
     
    13601360                        /* reading beyond the EOF */
    13611361                        bytes = 0;
    1362                         (void) async_data_read_finalize(chandle, NULL, 0);
     1362                        (void) async_data_read_finalize(&call, NULL, 0);
    13631363                } else {
    13641364                        bytes = min(len, BPS(bs) - pos % BPS(bs));
     
    13681368                        if (rc != EOK) {
    13691369                                exfat_node_put(fn);
    1370                                 async_answer_0(chandle, rc);
     1370                                async_answer_0(&call, rc);
    13711371                                return rc;
    13721372                        }
    1373                         (void) async_data_read_finalize(chandle,
     1373                        (void) async_data_read_finalize(&call,
    13741374                            b->data + pos % BPS(bs), bytes);
    13751375                        rc = block_put(b);
     
    13811381        } else {
    13821382                if (nodep->type != EXFAT_DIRECTORY) {
    1383                         async_answer_0(chandle, ENOTSUP);
     1383                        async_answer_0(&call, ENOTSUP);
    13841384                        return ENOTSUP;
    13851385                }
     
    14151415        err:
    14161416                (void) exfat_node_put(fn);
    1417                 async_answer_0(chandle, rc);
     1417                async_answer_0(&call, rc);
    14181418                return rc;
    14191419
     
    14231423                        goto err;
    14241424                rc = exfat_node_put(fn);
    1425                 async_answer_0(chandle, rc != EOK ? rc : ENOENT);
     1425                async_answer_0(&call, rc != EOK ? rc : ENOENT);
    14261426                *rbytes = 0;
    14271427                return rc != EOK ? rc : ENOENT;
     
    14321432                if (rc != EOK)
    14331433                        goto err;
    1434                 (void) async_data_read_finalize(chandle, name,
     1434                (void) async_data_read_finalize(&call, name,
    14351435                    str_size(name) + 1);
    14361436                bytes = (pos - spos) + 1;
     
    14851485        nodep = EXFAT_NODE(fn);
    14861486
    1487         cap_call_handle_t chandle;
     1487        ipc_call_t call;
    14881488        size_t len;
    1489         if (!async_data_write_receive(&chandle, &len)) {
     1489        if (!async_data_write_receive(&call, &len)) {
    14901490                (void) exfat_node_put(fn);
    1491                 async_answer_0(chandle, EINVAL);
     1491                async_answer_0(&call, EINVAL);
    14921492                return EINVAL;
    14931493        }
     
    15141514                        /* could not expand node */
    15151515                        (void) exfat_node_put(fn);
    1516                         async_answer_0(chandle, rc);
     1516                        async_answer_0(&call, rc);
    15171517                        return rc;
    15181518                }
     
    15331533        if (rc != EOK) {
    15341534                (void) exfat_node_put(fn);
    1535                 async_answer_0(chandle, rc);
    1536                 return rc;
    1537         }
    1538 
    1539         (void) async_data_write_finalize(chandle,
     1535                async_answer_0(&call, rc);
     1536                return rc;
     1537        }
     1538
     1539        (void) async_data_write_finalize(&call,
    15401540            b->data + pos % BPS(bs), bytes);
    15411541        b->dirty = true;                /* need to sync block */
  • uspace/srv/fs/fat/fat_ops.c

    r76f566d r984a9ba  
    12261226        nodep = FAT_NODE(fn);
    12271227
    1228         cap_call_handle_t chandle;
     1228        ipc_call_t call;
    12291229        size_t len;
    1230         if (!async_data_read_receive(&chandle, &len)) {
     1230        if (!async_data_read_receive(&call, &len)) {
    12311231                fat_node_put(fn);
    1232                 async_answer_0(chandle, EINVAL);
     1232                async_answer_0(&call, EINVAL);
    12331233                return EINVAL;
    12341234        }
     
    12451245                        /* reading beyond the EOF */
    12461246                        bytes = 0;
    1247                         (void) async_data_read_finalize(chandle, NULL, 0);
     1247                        (void) async_data_read_finalize(&call, NULL, 0);
    12481248                } else {
    12491249                        bytes = min(len, BPS(bs) - pos % BPS(bs));
     
    12531253                        if (rc != EOK) {
    12541254                                fat_node_put(fn);
    1255                                 async_answer_0(chandle, rc);
     1255                                async_answer_0(&call, rc);
    12561256                                return rc;
    12571257                        }
    1258                         (void) async_data_read_finalize(chandle,
     1258                        (void) async_data_read_finalize(&call,
    12591259                            b->data + pos % BPS(bs), bytes);
    12601260                        rc = block_put(b);
     
    12911291        err:
    12921292                (void) fat_node_put(fn);
    1293                 async_answer_0(chandle, rc);
     1293                async_answer_0(&call, rc);
    12941294                return rc;
    12951295
     
    12991299                        goto err;
    13001300                rc = fat_node_put(fn);
    1301                 async_answer_0(chandle, rc != EOK ? rc : ENOENT);
     1301                async_answer_0(&call, rc != EOK ? rc : ENOENT);
    13021302                *rbytes = 0;
    13031303                return rc != EOK ? rc : ENOENT;
     
    13081308                if (rc != EOK)
    13091309                        goto err;
    1310                 (void) async_data_read_finalize(chandle, name,
     1310                (void) async_data_read_finalize(&call, name,
    13111311                    str_size(name) + 1);
    13121312                bytes = (pos - spos) + 1;
     
    13381338        nodep = FAT_NODE(fn);
    13391339
    1340         cap_call_handle_t chandle;
     1340        ipc_call_t call;
    13411341        size_t len;
    1342         if (!async_data_write_receive(&chandle, &len)) {
     1342        if (!async_data_write_receive(&call, &len)) {
    13431343                (void) fat_node_put(fn);
    1344                 async_answer_0(chandle, EINVAL);
     1344                async_answer_0(&call, EINVAL);
    13451345                return EINVAL;
    13461346        }
     
    13701370                if (rc != EOK) {
    13711371                        (void) fat_node_put(fn);
    1372                         async_answer_0(chandle, rc);
     1372                        async_answer_0(&call, rc);
    13731373                        return rc;
    13741374                }
     
    13761376                if (rc != EOK) {
    13771377                        (void) fat_node_put(fn);
    1378                         async_answer_0(chandle, rc);
     1378                        async_answer_0(&call, rc);
    13791379                        return rc;
    13801380                }
    1381                 (void) async_data_write_finalize(chandle,
     1381                (void) async_data_write_finalize(&call,
    13821382                    b->data + pos % BPS(bs), bytes);
    13831383                b->dirty = true;                /* need to sync block */
     
    14091409                        /* could not allocate a chain of nclsts clusters */
    14101410                        (void) fat_node_put(fn);
    1411                         async_answer_0(chandle, rc);
     1411                        async_answer_0(&call, rc);
    14121412                        return rc;
    14131413                }
     
    14171417                        (void) fat_free_clusters(bs, service_id, mcl);
    14181418                        (void) fat_node_put(fn);
    1419                         async_answer_0(chandle, rc);
     1419                        async_answer_0(&call, rc);
    14201420                        return rc;
    14211421                }
     
    14251425                        (void) fat_free_clusters(bs, service_id, mcl);
    14261426                        (void) fat_node_put(fn);
    1427                         async_answer_0(chandle, rc);
     1427                        async_answer_0(&call, rc);
    14281428                        return rc;
    14291429                }
    1430                 (void) async_data_write_finalize(chandle,
     1430                (void) async_data_write_finalize(&call,
    14311431                    b->data + pos % BPS(bs), bytes);
    14321432                b->dirty = true;                /* need to sync block */
  • uspace/srv/fs/locfs/locfs_ops.c

    r76f566d r984a9ba  
    478478{
    479479        if (index == 0) {
    480                 cap_call_handle_t chandle;
     480                ipc_call_t call;
    481481                size_t size;
    482                 if (!async_data_read_receive(&chandle, &size)) {
    483                         async_answer_0(chandle, EINVAL);
     482                if (!async_data_read_receive(&call, &size)) {
     483                        async_answer_0(&call, EINVAL);
    484484                        return EINVAL;
    485485                }
     
    500500
    501501                if (pos < count) {
    502                         async_data_read_finalize(chandle, desc[pos].name, str_size(desc[pos].name) + 1);
     502                        async_data_read_finalize(&call, desc[pos].name, str_size(desc[pos].name) + 1);
    503503                        free(desc);
    504504                        *rbytes = 1;
     
    515515
    516516                        if (pos < count) {
    517                                 async_data_read_finalize(chandle, desc[pos].name, str_size(desc[pos].name) + 1);
     517                                async_data_read_finalize(&call, desc[pos].name, str_size(desc[pos].name) + 1);
    518518                                free(desc);
    519519                                *rbytes = 1;
     
    524524                }
    525525
    526                 async_answer_0(chandle, ENOENT);
     526                async_answer_0(&call, ENOENT);
    527527                return ENOENT;
    528528        }
     
    532532        if (type == LOC_OBJECT_NAMESPACE) {
    533533                /* Namespace directory */
    534                 cap_call_handle_t chandle;
     534                ipc_call_t call;
    535535                size_t size;
    536                 if (!async_data_read_receive(&chandle, &size)) {
    537                         async_answer_0(chandle, EINVAL);
     536                if (!async_data_read_receive(&call, &size)) {
     537                        async_answer_0(&call, EINVAL);
    538538                        return EINVAL;
    539539                }
     
    543543
    544544                if (pos < count) {
    545                         async_data_read_finalize(chandle, desc[pos].name, str_size(desc[pos].name) + 1);
     545                        async_data_read_finalize(&call, desc[pos].name, str_size(desc[pos].name) + 1);
    546546                        free(desc);
    547547                        *rbytes = 1;
     
    550550
    551551                free(desc);
    552                 async_answer_0(chandle, ENOENT);
     552                async_answer_0(&call, ENOENT);
    553553                return ENOENT;
    554554        }
     
    568568                assert(dev->sess);
    569569
    570                 cap_call_handle_t chandle;
    571                 if (!async_data_read_receive(&chandle, NULL)) {
     570                ipc_call_t call;
     571                if (!async_data_read_receive(&call, NULL)) {
    572572                        fibril_mutex_unlock(&services_mutex);
    573                         async_answer_0(chandle, EINVAL);
     573                        async_answer_0(&call, EINVAL);
    574574                        return EINVAL;
    575575                }
     
    583583
    584584                /* Forward the IPC_M_DATA_READ request to the driver */
    585                 async_forward_fast(chandle, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     585                async_forward_fast(&call, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    586586
    587587                async_exchange_end(exch);
     
    632632                assert(dev->sess);
    633633
    634                 cap_call_handle_t chandle;
    635                 if (!async_data_write_receive(&chandle, NULL)) {
     634                ipc_call_t call;
     635                if (!async_data_write_receive(&call, NULL)) {
    636636                        fibril_mutex_unlock(&services_mutex);
    637                         async_answer_0(chandle, EINVAL);
     637                        async_answer_0(&call, EINVAL);
    638638                        return EINVAL;
    639639                }
     
    647647
    648648                /* Forward the IPC_M_DATA_WRITE request to the driver */
    649                 async_forward_fast(chandle, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     649                async_forward_fast(&call, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    650650
    651651                async_exchange_end(exch);
  • uspace/srv/fs/mfs/mfs_ops.c

    r76f566d r984a9ba  
    839839        struct mfs_ino_info *ino_i;
    840840        size_t len, bytes = 0;
    841         cap_call_handle_t chandle;
     841        ipc_call_t call;
    842842
    843843        mnode = fn->data;
    844844        ino_i = mnode->ino_i;
    845845
    846         if (!async_data_read_receive(&chandle, &len)) {
     846        if (!async_data_read_receive(&call, &len)) {
    847847                rc = EINVAL;
    848848                goto out_error;
     
    871871
    872872                rc = mfs_node_put(fn);
    873                 async_answer_0(chandle, rc != EOK ? rc : ENOENT);
     873                async_answer_0(&call, rc != EOK ? rc : ENOENT);
    874874                return rc;
    875875        found:
    876                 async_data_read_finalize(chandle, d_info.d_name,
     876                async_data_read_finalize(&call, d_info.d_name,
    877877                    str_size(d_info.d_name) + 1);
    878878                bytes = ((pos - spos) + 1);
     
    883883                        /* Trying to read beyond the end of file */
    884884                        bytes = 0;
    885                         (void) async_data_read_finalize(chandle, NULL, 0);
     885                        (void) async_data_read_finalize(&call, NULL, 0);
    886886                        goto out_success;
    887887                }
     
    905905                        }
    906906                        memset(buf, 0, sizeof(sbi->block_size));
    907                         async_data_read_finalize(chandle,
     907                        async_data_read_finalize(&call,
    908908                            buf + pos % sbi->block_size, bytes);
    909909                        free(buf);
     
    915915                        goto out_error;
    916916
    917                 async_data_read_finalize(chandle, b->data +
     917                async_data_read_finalize(&call, b->data +
    918918                    pos % sbi->block_size, bytes);
    919919
     
    930930out_error:
    931931        tmp = mfs_node_put(fn);
    932         async_answer_0(chandle, tmp != EOK ? tmp : rc);
     932        async_answer_0(&call, tmp != EOK ? tmp : rc);
    933933        return tmp != EOK ? tmp : rc;
    934934}
     
    948948                return ENOENT;
    949949
    950         cap_call_handle_t chandle;
     950        ipc_call_t call;
    951951        size_t len;
    952952
    953         if (!async_data_write_receive(&chandle, &len)) {
     953        if (!async_data_write_receive(&call, &len)) {
    954954                r = EINVAL;
    955955                goto out_err;
     
    994994                memset(b->data, 0, sbi->block_size);
    995995
    996         async_data_write_finalize(chandle, b->data + (pos % bs), bytes);
     996        async_data_write_finalize(&call, b->data + (pos % bs), bytes);
    997997        b->dirty = true;
    998998
     
    10141014out_err:
    10151015        mfs_node_put(fn);
    1016         async_answer_0(chandle, r);
     1016        async_answer_0(&call, r);
    10171017        return r;
    10181018}
  • 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:
  • uspace/srv/fs/udf/udf_file.c

    r76f566d r984a9ba  
    568568 *
    569569 * @param read_len Returned value. Length file or part file which we could read.
    570  * @param chandle
     570 * @param call     IPC call
    571571 * @param node     UDF node
    572572 * @param pos      Position in file since we have to read.
     
    576576 *
    577577 */
    578 errno_t udf_read_file(size_t *read_len, cap_call_handle_t chandle, udf_node_t *node,
     578errno_t udf_read_file(size_t *read_len, ipc_call_t *call, udf_node_t *node,
    579579    aoff64_t pos, size_t len)
    580580{
     
    598598            BLOCK_FLAGS_NONE);
    599599        if (rc != EOK) {
    600                 async_answer_0(chandle, rc);
     600                async_answer_0(call, rc);
    601601                return rc;
    602602        }
     
    619619        }
    620620
    621         async_data_read_finalize(chandle, block->data + sector_pos, *read_len);
     621        async_data_read_finalize(call, block->data + sector_pos, *read_len);
    622622        return block_put(block);
    623623}
  • uspace/srv/fs/udf/udf_file.h

    r76f566d r984a9ba  
    198198extern errno_t udf_read_allocation_sequence(udf_node_t *, uint8_t *, uint16_t,
    199199    uint32_t, uint32_t);
    200 extern errno_t udf_read_file(size_t *, cap_call_handle_t, udf_node_t *, aoff64_t,
     200extern errno_t udf_read_file(size_t *, ipc_call_t *, udf_node_t *, aoff64_t,
    201201    size_t);
    202202extern errno_t udf_get_fid(udf_file_identifier_descriptor_t **, block_t **,
  • uspace/srv/fs/udf/udf_ops.c

    r76f566d r984a9ba  
    464464        udf_node_t *node = UDF_NODE(rfn);
    465465
    466         cap_call_handle_t chandle;
     466        ipc_call_t call;
    467467        size_t len = 0;
    468         if (!async_data_read_receive(&chandle, &len)) {
    469                 async_answer_0(chandle, EINVAL);
     468        if (!async_data_read_receive(&call, &len)) {
     469                async_answer_0(&call, EINVAL);
    470470                udf_node_put(rfn);
    471471                return EINVAL;
     
    475475                if (pos >= node->data_size) {
    476476                        *rbytes = 0;
    477                         async_data_read_finalize(chandle, NULL, 0);
     477                        async_data_read_finalize(&call, NULL, 0);
    478478                        udf_node_put(rfn);
    479479                        return EOK;
     
    482482                size_t read_len = 0;
    483483                if (node->data == NULL)
    484                         rc = udf_read_file(&read_len, chandle, node, pos, len);
     484                        rc = udf_read_file(&read_len, &call, node, pos, len);
    485485                else {
    486486                        /* File in allocation descriptors area */
    487487                        read_len = (len < node->data_size) ? len : node->data_size;
    488                         async_data_read_finalize(chandle, node->data + pos, read_len);
     488                        async_data_read_finalize(&call, node->data + pos, read_len);
    489489                        rc = EOK;
    490490                }
     
    505505                            fid->lenght_file_id, &node->instance->charset);
    506506
    507                         async_data_read_finalize(chandle, name, str_size(name) + 1);
     507                        async_data_read_finalize(&call, name, str_size(name) + 1);
    508508                        *rbytes = 1;
    509509                        free(name);
     
    517517                        *rbytes = 0;
    518518                        udf_node_put(rfn);
    519                         async_answer_0(chandle, ENOENT);
     519                        async_answer_0(&call, ENOENT);
    520520                        return ENOENT;
    521521                }
Note: See TracChangeset for help on using the changeset viewer.