X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fkernel-ctl%2Fkernel-ctl.c;h=5ea3e1ae12a122761750c291a7240708b4c36469;hp=a93d25102ad4bb7b2bf6a4afe8ad5d0edd3fb096;hb=d3e2ba59faddb31870e2ce29b6a881f7ad5ad883;hpb=4dbc372b53ef1ac713497164e7a8b92100db7ae2 diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index a93d25102..5ea3e1ae1 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -82,7 +82,13 @@ int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops) old_channel.switch_timer_interval = chops->switch_timer_interval; old_channel.read_timer_interval = chops->read_timer_interval; old_channel.output = chops->output; - memcpy(old_channel.padding, chops->padding, sizeof(old_channel.padding)); + + memset(old_channel.padding, 0, sizeof(old_channel.padding)); + /* + * The new channel padding is smaller than the old ABI so we use the + * new ABI padding size for the memcpy. + */ + memcpy(old_channel.padding, chops->padding, sizeof(chops->padding)); return ioctl(fd, LTTNG_KERNEL_OLD_METADATA, &old_channel); } @@ -93,7 +99,7 @@ int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops) channel.switch_timer_interval = chops->switch_timer_interval; channel.read_timer_interval = chops->read_timer_interval; channel.output = chops->output; - memcpy(channel.padding, chops->padding, sizeof(channel.padding)); + memcpy(channel.padding, chops->padding, sizeof(chops->padding)); return ioctl(fd, LTTNG_KERNEL_METADATA, &channel); } @@ -111,7 +117,13 @@ int kernctl_create_channel(int fd, struct lttng_channel_attr *chops) old_channel.switch_timer_interval = chops->switch_timer_interval; old_channel.read_timer_interval = chops->read_timer_interval; old_channel.output = chops->output; - memcpy(old_channel.padding, chops->padding, sizeof(old_channel.padding)); + + memset(old_channel.padding, 0, sizeof(old_channel.padding)); + /* + * The new channel padding is smaller than the old ABI so we use the + * new ABI padding size for the memcpy. + */ + memcpy(old_channel.padding, chops->padding, sizeof(chops->padding)); return ioctl(fd, LTTNG_KERNEL_OLD_CHANNEL, &old_channel); } @@ -122,7 +134,7 @@ int kernctl_create_channel(int fd, struct lttng_channel_attr *chops) channel.switch_timer_interval = chops->switch_timer_interval; channel.read_timer_interval = chops->read_timer_interval; channel.output = chops->output; - memcpy(channel.padding, chops->padding, sizeof(channel.padding)); + memcpy(channel.padding, chops->padding, sizeof(chops->padding)); return ioctl(fd, LTTNG_KERNEL_CHANNEL, &channel); } @@ -379,8 +391,44 @@ int kernctl_put_subbuf(int fd) return ioctl(fd, RING_BUFFER_PUT_SUBBUF); } -/* Set the stream_id */ -int kernctl_set_stream_id(int fd, unsigned long *stream_id) +/* Returns the timestamp begin of the current sub-buffer. */ +int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin) +{ + return ioctl(fd, LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN, timestamp_begin); +} + +/* Returns the timestamp end of the current sub-buffer. */ +int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end) +{ + return ioctl(fd, LTTNG_RING_BUFFER_GET_TIMESTAMP_END, timestamp_end); +} + +/* Returns the number of discarded events in the current sub-buffer. */ +int kernctl_get_events_discarded(int fd, uint64_t *events_discarded) +{ + return ioctl(fd, LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED, events_discarded); +} + +/* Returns the content size in the current sub-buffer. */ +int kernctl_get_content_size(int fd, uint64_t *content_size) +{ + return ioctl(fd, LTTNG_RING_BUFFER_GET_CONTENT_SIZE, content_size); +} + +/* Returns the packet size in the current sub-buffer. */ +int kernctl_get_packet_size(int fd, uint64_t *packet_size) +{ + return ioctl(fd, LTTNG_RING_BUFFER_GET_PACKET_SIZE, packet_size); +} + +/* Returns the stream id of the current sub-buffer. */ +int kernctl_get_stream_id(int fd, uint64_t *stream_id) +{ + return ioctl(fd, LTTNG_RING_BUFFER_GET_STREAM_ID, stream_id); +} + +/* Returns the current timestamp. */ +int kernctl_get_current_timestamp(int fd, uint64_t *ts) { - return ioctl(fd, RING_BUFFER_SET_STREAM_ID, stream_id); + return ioctl(fd, LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP, ts); }