Changeset a3fcfba in mainline


Ignore:
Timestamp:
2012-06-13T22:03:59Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75b9c3d
Parents:
3f57fb7
Message:

In loc print server name instead of handle.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/loc/loc.c

    r3f57fb7 ra3fcfba  
    4848        size_t svc_cnt;
    4949        char *svc_name;
     50        char *server_name;
    5051        int rc;
    5152        size_t j;
     
    6768                        continue;
    6869                }
    69                 printf("\t%s (%" PRIun ")\n", svc_name, svc_ids[j]);
     70
     71                rc = loc_service_get_server_name(svc_ids[j], &server_name);
     72                if (rc != EOK && rc != EINVAL) {
     73                        free(svc_name);
     74                        printf(NAME ": Unknown service name (SID %"
     75                            PRIun ").\n", svc_ids[j]);
     76                        continue;
     77                }
     78
     79                if (rc == EOK)
     80                        printf("\t%s : %s\n", svc_name, server_name);
     81                else
     82                        printf("\t%s\n", svc_name);
     83       
    7084                free(svc_name);
     85                free(server_name);
    7186        }
    7287
  • uspace/lib/c/generic/loc.c

    r3f57fb7 ra3fcfba  
    450450}
    451451
     452/** Get service server name.
     453 *
     454 * Provided ID of a service, return the name of its server.
     455 *
     456 * @param svc_id        Service ID
     457 * @param name          Place to store pointer to new string. Caller should
     458 *                      free it using free().
     459 * @return              EOK on success or negative error code
     460 */
     461int loc_service_get_server_name(service_id_t svc_id, char **name)
     462{
     463        return loc_get_name_internal(LOC_SERVICE_GET_SERVER_NAME, svc_id, name);
     464}
     465
    452466int loc_namespace_get_id(const char *name, service_id_t *handle,
    453467    unsigned int flags)
  • uspace/lib/c/include/ipc/loc.h

    r3f57fb7 ra3fcfba  
    5656        LOC_SERVICE_GET_ID,
    5757        LOC_SERVICE_GET_NAME,
     58        LOC_SERVICE_GET_SERVER_NAME,
    5859        LOC_NAMESPACE_GET_ID,
    5960        LOC_CALLBACK_CREATE,
  • uspace/lib/c/include/loc.h

    r3f57fb7 ra3fcfba  
    5656    unsigned int);
    5757extern int loc_service_get_name(service_id_t, char **);
     58extern int loc_service_get_server_name(service_id_t, char **);
    5859extern int loc_namespace_get_id(const char *, service_id_t *,
    5960    unsigned int);
  • uspace/srv/locsrv/locsrv.c

    r3f57fb7 ra3fcfba  
    656656}
    657657
     658static void loc_service_get_server_name(ipc_callid_t iid, ipc_call_t *icall)
     659{
     660        ipc_callid_t callid;
     661        size_t size;
     662        size_t act_size;
     663        loc_service_t *svc;
     664       
     665        if (!async_data_read_receive(&callid, &size)) {
     666                async_answer_0(callid, EREFUSED);
     667                async_answer_0(iid, EREFUSED);
     668                return;
     669        }
     670       
     671        fibril_mutex_lock(&services_list_mutex);
     672       
     673        svc = loc_service_find_id(IPC_GET_ARG1(*icall));
     674        if (svc == NULL) {
     675                fibril_mutex_unlock(&services_list_mutex);
     676                async_answer_0(callid, ENOENT);
     677                async_answer_0(iid, ENOENT);
     678                return;
     679        }
     680       
     681        if (svc->server == NULL) {
     682                fibril_mutex_unlock(&services_list_mutex);
     683                async_answer_0(callid, EINVAL);
     684                async_answer_0(iid, EINVAL);
     685                return;
     686        }
     687       
     688        act_size = str_size(svc->server->name);
     689        if (act_size > size) {
     690                fibril_mutex_unlock(&services_list_mutex);
     691                async_answer_0(callid, EOVERFLOW);
     692                async_answer_0(iid, EOVERFLOW);
     693                return;
     694        }
     695       
     696        sysarg_t retval = async_data_read_finalize(callid, svc->server->name,
     697            min(size, act_size));
     698       
     699        fibril_mutex_unlock(&services_list_mutex);
     700       
     701        async_answer_0(iid, retval);
     702}
     703
    658704/** Connect client to the service.
    659705 *
     
    14041450                case LOC_SERVICE_GET_NAME:
    14051451                        loc_service_get_name(callid, &call);
     1452                        break;
     1453                case LOC_SERVICE_GET_SERVER_NAME:
     1454                        loc_service_get_server_name(callid, &call);
    14061455                        break;
    14071456                case LOC_NAMESPACE_GET_ID:
Note: See TracChangeset for help on using the changeset viewer.