-/* open the metadata global channel */
-int ustctl_open_metadata(int sock, int session_handle,
- struct lttng_ust_channel_attr *chops,
- struct lttng_ust_object_data **_metadata_data)
-{
- struct ustcomm_ust_msg lum;
- struct ustcomm_ust_reply lur;
- struct lttng_ust_object_data *metadata_data;
- int ret, err = 0;
-
- if (!chops || !_metadata_data)
- return -EINVAL;
-
- metadata_data = malloc(sizeof(*metadata_data));
- if (!metadata_data)
- return -ENOMEM;
- init_object(metadata_data);
- /* Create metadata channel */
- memset(&lum, 0, sizeof(lum));
- lum.handle = session_handle;
- lum.cmd = LTTNG_UST_METADATA;
- lum.u.channel.overwrite = chops->overwrite;
- lum.u.channel.subbuf_size = chops->subbuf_size;
- lum.u.channel.num_subbuf = chops->num_subbuf;
- lum.u.channel.switch_timer_interval = chops->switch_timer_interval;
- lum.u.channel.read_timer_interval = chops->read_timer_interval;
- lum.u.channel.output = chops->output;
- ret = ustcomm_send_app_cmd(sock, &lum, &lur);
- if (ret) {
- free(metadata_data);
- return ret;
- }
- metadata_data->handle = lur.ret_val;
- DBG("received metadata handle %u", metadata_data->handle);
- metadata_data->memory_map_size = lur.u.channel.memory_map_size;
- /* get shm fd */
- ret = ustcomm_recv_fd(sock);
- if (ret < 0)
- err = ret;
- else
- metadata_data->shm_fd = ret;
- /*
- * We need to get the second FD even if the first fails, because
- * libust expects us to read the two FDs.
- */
- /* get wait fd */
- ret = ustcomm_recv_fd(sock);
- if (ret < 0)
- err = ret;
- else
- metadata_data->wait_fd = ret;
- if (err)
- goto error;
- *_metadata_data = metadata_data;
- return 0;
-
-error:
- (void) ustctl_release_object(sock, metadata_data);
- free(metadata_data);
- return err;
-}
-
-int ustctl_create_channel(int sock, int session_handle,
- struct lttng_ust_channel_attr *chops,
- struct lttng_ust_object_data **_channel_data)
-{
- struct ustcomm_ust_msg lum;
- struct ustcomm_ust_reply lur;
- struct lttng_ust_object_data *channel_data;
- int ret, err = 0;
-
- if (!chops || !_channel_data)
- return -EINVAL;
-
- channel_data = malloc(sizeof(*channel_data));
- if (!channel_data)
- return -ENOMEM;
- init_object(channel_data);
- /* Create metadata channel */
- memset(&lum, 0, sizeof(lum));
- lum.handle = session_handle;
- lum.cmd = LTTNG_UST_CHANNEL;
- lum.u.channel.overwrite = chops->overwrite;
- lum.u.channel.subbuf_size = chops->subbuf_size;
- lum.u.channel.num_subbuf = chops->num_subbuf;
- lum.u.channel.switch_timer_interval = chops->switch_timer_interval;
- lum.u.channel.read_timer_interval = chops->read_timer_interval;
- lum.u.channel.output = chops->output;
- ret = ustcomm_send_app_cmd(sock, &lum, &lur);
- if (ret) {
- free(channel_data);
- return ret;
- }
- channel_data->handle = lur.ret_val;
- DBG("received channel handle %u", channel_data->handle);
- channel_data->memory_map_size = lur.u.channel.memory_map_size;
- /* get shm fd */
- ret = ustcomm_recv_fd(sock);
- if (ret < 0)
- err = ret;
- else
- channel_data->shm_fd = ret;
- /*
- * We need to get the second FD even if the first fails, because
- * libust expects us to read the two FDs.
- */
- /* get wait fd */
- ret = ustcomm_recv_fd(sock);
- if (ret < 0)
- err = ret;
- else
- channel_data->wait_fd = ret;
- if (err)
- goto error;
- *_channel_data = channel_data;
- return 0;
-
-error:
- (void) ustctl_release_object(sock, channel_data);
- free(channel_data);
- return err;
-}
-
-/*
- * Return -LTTNG_UST_ERR_NOENT if no more stream is available for creation.
- * Return 0 on success.
- * Return negative error value on system error.
- * Return positive error value on UST error.
- */
-int ustctl_create_stream(int sock, struct lttng_ust_object_data *channel_data,
- struct lttng_ust_object_data **_stream_data)
-{
- struct ustcomm_ust_msg lum;
- struct ustcomm_ust_reply lur;
- struct lttng_ust_object_data *stream_data;
- int ret, fd, err = 0;
-
- if (!channel_data || !_stream_data)
- return -EINVAL;
-
- stream_data = malloc(sizeof(*stream_data));
- if (!stream_data)
- return -ENOMEM;
- init_object(stream_data);
- memset(&lum, 0, sizeof(lum));
- lum.handle = channel_data->handle;
- lum.cmd = LTTNG_UST_STREAM;
- ret = ustcomm_send_app_cmd(sock, &lum, &lur);
- if (ret) {
- free(stream_data);
- return ret;
- }
- stream_data->handle = lur.ret_val;
- DBG("received stream handle %u", stream_data->handle);
- stream_data->memory_map_size = lur.u.stream.memory_map_size;
- /* get shm fd */
- fd = ustcomm_recv_fd(sock);
- if (fd < 0)
- err = fd;
- else
- stream_data->shm_fd = fd;
- /*
- * We need to get the second FD even if the first fails, because
- * libust expects us to read the two FDs.
- */
- /* get wait fd */
- fd = ustcomm_recv_fd(sock);
- if (fd < 0)
- err = fd;
- else
- stream_data->wait_fd = fd;
- if (err)
- goto error;
- *_stream_data = stream_data;
- return ret;
-
-error:
- (void) ustctl_release_object(sock, stream_data);
- free(stream_data);
- return err;
-}
-