Changeset 763e0cd in mainline


Ignore:
Timestamp:
2011-08-18T14:25:52Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d0dd7b5, f55b12b
Parents:
1dc4a5e
Message:

Locinfo utility. Right now displays yellow pages.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r1dc4a5e r763e0cd  
    150150        $(USPACE_PATH)/app/kill/kill \
    151151        $(USPACE_PATH)/app/killall/killall \
     152        $(USPACE_PATH)/app/locinfo/locinfo \
    152153        $(USPACE_PATH)/app/mkfat/mkfat \
    153154        $(USPACE_PATH)/app/lsusb/lsusb \
  • uspace/Makefile

    r1dc4a5e r763e0cd  
    4444        app/killall \
    4545        app/klog \
     46        app/locinfo \
    4647        app/lsusb \
    4748        app/mkfat \
  • uspace/lib/c/generic/loc.c

    r1dc4a5e r763e0cd  
    364364}
    365365
    366 /** Get service name.
    367  *
    368  * Provided ID of a service, return its name.
    369  *
    370  * @param svc_id        Service ID
     366/** Get object name.
     367 *
     368 * Provided ID of an object, return its name.
     369 *
     370 * @param method        IPC method
     371 * @param id            Object ID
    371372 * @param name          Place to store pointer to new string. Caller should
    372373 *                      free it using free().
    373374 * @return              EOK on success or negative error code
    374375 */
    375 int loc_service_get_name(service_id_t svc_id, char **name)
     376static int loc_get_name_internal(sysarg_t method, sysarg_t id, char **name)
    376377{
    377378        async_exch_t *exch;
     
    385386       
    386387        ipc_call_t answer;
    387         aid_t req = async_send_1(exch, LOC_SERVICE_GET_NAME, svc_id, &answer);
     388        aid_t req = async_send_1(exch, method, id, &answer);
    388389        aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN,
    389390            &dreply);
     
    414415}
    415416
     417/** Get category name.
     418 *
     419 * Provided ID of a service, return its name.
     420 *
     421 * @param cat_id        Category ID
     422 * @param name          Place to store pointer to new string. Caller should
     423 *                      free it using free().
     424 * @return              EOK on success or negative error code
     425 */
     426int loc_category_get_name(category_id_t cat_id, char **name)
     427{
     428        return loc_get_name_internal(LOC_CATEGORY_GET_NAME, cat_id, name);
     429}
     430
     431/** Get service name.
     432 *
     433 * Provided ID of a service, return its name.
     434 *
     435 * @param svc_id        Service ID
     436 * @param name          Place to store pointer to new string. Caller should
     437 *                      free it using free().
     438 * @return              EOK on success or negative error code
     439 */
     440int loc_service_get_name(service_id_t svc_id, char **name)
     441{
     442        return loc_get_name_internal(LOC_SERVICE_GET_NAME, svc_id, name);
     443}
    416444
    417445int loc_namespace_get_id(const char *name, service_id_t *handle,
  • uspace/lib/c/include/ipc/loc.h

    r1dc4a5e r763e0cd  
    5959        LOC_CALLBACK_CREATE,
    6060        LOC_CATEGORY_GET_ID,
     61        LOC_CATEGORY_GET_NAME,
    6162        LOC_CATEGORY_GET_SVCS,
    6263        LOC_ID_PROBE,
  • uspace/srv/loc/loc.c

    r1dc4a5e r763e0cd  
    536536}
    537537
     538static void loc_category_get_name(ipc_callid_t iid, ipc_call_t *icall)
     539{
     540        ipc_callid_t callid;
     541        size_t size;
     542        size_t act_size;
     543        category_t *cat;
     544       
     545        if (!async_data_read_receive(&callid, &size)) {
     546                async_answer_0(callid, EREFUSED);
     547                async_answer_0(iid, EREFUSED);
     548                return;
     549        }
     550       
     551        fibril_mutex_lock(&cdir.mutex);
     552       
     553        cat = category_get(&cdir, IPC_GET_ARG1(*icall));
     554        if (cat == NULL) {
     555                fibril_mutex_unlock(&cdir.mutex);
     556                async_answer_0(callid, ENOENT);
     557                async_answer_0(iid, ENOENT);
     558                return;
     559        }
     560       
     561        act_size = str_size(cat->name);
     562        if (act_size > size) {
     563                fibril_mutex_unlock(&cdir.mutex);
     564                async_answer_0(callid, EOVERFLOW);
     565                async_answer_0(iid, EOVERFLOW);
     566                return;
     567        }
     568       
     569        sysarg_t retval = async_data_read_finalize(callid, cat->name,
     570            min(size, act_size));
     571       
     572        fibril_mutex_unlock(&cdir.mutex);
     573       
     574        async_answer_0(iid, retval);
     575}
     576
    538577static void loc_service_get_name(ipc_callid_t iid, ipc_call_t *icall)
    539578{
     
    574613        async_answer_0(iid, retval);
    575614}
    576 
    577615
    578616/** Connect client to the service.
     
    12981336                        loc_category_get_id(callid, &call);
    12991337                        break;
     1338                case LOC_CATEGORY_GET_NAME:
     1339                        loc_category_get_name(callid, &call);
     1340                        break;
    13001341                case LOC_CATEGORY_GET_SVCS:
    13011342                        loc_category_get_svcs(callid, &call);
Note: See TracChangeset for help on using the changeset viewer.