}
if (dirent->d_type != DT_DIR &&
- !!strcmp(dirent->d_name, "ustd")) {
+ !!strcmp(dirent->d_name, "ust-consumer")) {
sscanf(dirent->d_name, "%u", (unsigned int *) &ret[i]);
/* FIXME: Here we previously called pid_is_online, which
* @param pid Traced process ID
* @return 0 if successful, or errors {USTCMD_ERR_GEN, USTCMD_ERR_ARG}
*/
-int ustcmd_set_marker_state(const char *channel, const char *marker,
- int state, pid_t pid)
+int ustcmd_set_marker_state(const char *trace, const char *channel,
+ const char *marker, int state, pid_t pid)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_marker_info marker_inf;
result = ustcomm_pack_marker_info(&req_header,
&marker_inf,
+ trace,
channel,
marker);
if (result < 0) {
* @param pid Traced process ID
* @return 0 if successful, or error
*/
-int ustcmd_set_subbuf_size(const char *channel, unsigned int subbuf_size,
- pid_t pid)
+int ustcmd_set_subbuf_size(const char *trace, const char *channel,
+ unsigned int subbuf_size, pid_t pid)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_channel_info ch_inf;
result = ustcomm_pack_channel_info(&req_header,
&ch_inf,
+ trace,
channel);
if (result < 0) {
errno = -result;
* @param pid Traced process ID
* @return 0 if successful, or error
*/
-int ustcmd_set_subbuf_num(const char *channel, unsigned int num,
- pid_t pid)
+int ustcmd_set_subbuf_num(const char *trace, const char *channel,
+ unsigned int num, pid_t pid)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_channel_info ch_inf;
result = ustcomm_pack_channel_info(&req_header,
&ch_inf,
+ trace,
channel);
if (result < 0) {
errno = -result;
}
-static int ustcmd_get_subbuf_num_size(const char *channel, pid_t pid,
- int *num, int *size)
+static int ustcmd_get_subbuf_num_size(const char *trace, const char *channel,
+ pid_t pid, int *num, int *size)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_channel_info ch_inf, *ch_inf_res;
result = ustcomm_pack_channel_info(&req_header,
&ch_inf,
+ trace,
channel);
if (result < 0) {
errno = -result;
* @param pid Traced process ID
* @return subbuf cnf if successful, or error
*/
-int ustcmd_get_subbuf_num(const char *channel, pid_t pid)
+int ustcmd_get_subbuf_num(const char *trace, const char *channel, pid_t pid)
{
int num, size, result;
- result = ustcmd_get_subbuf_num_size(channel, pid,
+ result = ustcmd_get_subbuf_num_size(trace, channel, pid,
&num, &size);
if (result < 0) {
errno = -result;
* @param pid Traced process ID
* @return subbuf size if successful, or error
*/
-int ustcmd_get_subbuf_size(const char *channel, pid_t pid)
+int ustcmd_get_subbuf_size(const char *trace, const char *channel, pid_t pid)
{
int num, size, result;
- result = ustcmd_get_subbuf_num_size(channel, pid,
+ result = ustcmd_get_subbuf_num_size(trace, channel, pid,
&num, &size);
if (result < 0) {
errno = -result;
return size;
}
+
+static int do_trace_cmd(const char *trace, pid_t pid, int command)
+{
+ struct ustcomm_header req_header, res_header;
+ struct ustcomm_single_field trace_inf;
+ int result;
+
+ result = ustcomm_pack_single_field(&req_header,
+ &trace_inf,
+ trace);
+ if (result < 0) {
+ errno = -result;
+ return -1;
+ }
+
+ req_header.command = command;
+
+ return do_cmd(pid, &req_header, (char *)&trace_inf, &res_header, NULL);
+}
+
/**
* Destroys an UST trace according to a PID.
*
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_destroy_trace(pid_t pid)
+int ustcmd_destroy_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = DESTROY_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, DESTROY_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_setup_and_start(pid_t pid)
+int ustcmd_setup_and_start(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = START;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, START);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_create_trace(pid_t pid)
+int ustcmd_create_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = CREATE_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, CREATE_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_start_trace(pid_t pid)
+int ustcmd_start_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = START_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, START_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_alloc_trace(pid_t pid)
+int ustcmd_alloc_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = ALLOC_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, ALLOC_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_stop_trace(pid_t pid)
+int ustcmd_stop_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = STOP_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, STOP_TRACE);
}
/**
*/
int ustcmd_set_sock_path(const char *sock_path, pid_t pid)
{
- int offset = 0;
+ int result;
struct ustcomm_header req_header, res_header;
- struct ustcomm_sock_path sock_path_msg;
+ struct ustcomm_single_field sock_path_msg;
- sock_path_msg.sock_path = ustcomm_print_data(sock_path_msg.data,
- sizeof(sock_path_msg.data),
- &offset,
- sock_path);
- if (sock_path_msg.sock_path == USTCOMM_POISON_PTR) {
+ result = ustcomm_pack_single_field(&req_header,
+ &sock_path_msg,
+ sock_path);
+ if (result < 0) {
+ errno = -result;
return -1;
}
req_header.command = SET_SOCK_PATH;
- req_header.size = COMPUTE_MSG_SIZE(&sock_path_msg, offset);
return do_cmd(pid, &req_header, (char *)&sock_path_msg,
&res_header, NULL);
{
int result;
struct ustcomm_header req_header, res_header;
- struct ustcomm_sock_path *sock_path_msg;
+ struct ustcomm_single_field *sock_path_msg;
req_header.command = GET_SOCK_PATH;
req_header.size = 0;
return -1;
}
- result = ustcomm_unpack_sock_path(sock_path_msg);
+ result = ustcomm_unpack_single_field(sock_path_msg);
if (result < 0) {
return result;
}
- *sock_path = strdup(sock_path_msg->sock_path);
+ *sock_path = strdup(sock_path_msg->field);
free(sock_path_msg);