int to_close_fd;
/* Index packet data. This is the data that is written on disk. */
- struct lttng_packet_index index_data;
+ struct ctf_packet_index index_data;
/* key1 = stream_id, key2 = net_seq_num */
struct lttng_ht_two_u64 key;
{
int ret;
char fullpath[PATH_MAX];
- struct lttng_packet_index_file_hdr hdr;
+ struct ctf_packet_index_file_hdr hdr;
if (stream->tracefile_count > 0) {
ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR "/%s_%"
PERROR("Reading index header");
goto error;
}
- if (strncmp(hdr.magic, INDEX_MAGIC, sizeof(hdr.magic)) != 0) {
+ if (be32toh(hdr.magic) != CTF_INDEX_MAGIC) {
ERR("Invalid header magic");
ret = -1;
goto error;
}
- if (be32toh(hdr.index_major) != INDEX_MAJOR ||
- be32toh(hdr.index_minor) != INDEX_MINOR) {
+ if (be32toh(hdr.index_major) != CTF_INDEX_MAJOR ||
+ be32toh(hdr.index_minor) != CTF_INDEX_MINOR) {
ERR("Invalid header version");
ret = -1;
goto error;
if (seek_last && viewer_stream->index_read_fd > 0) {
ret = lseek(viewer_stream->index_read_fd,
viewer_stream->total_index_received *
- sizeof(struct lttng_packet_index),
+ sizeof(struct ctf_packet_index),
SEEK_CUR);
if (ret < 0) {
goto error;
int ret;
struct lttng_viewer_get_next_index request_index;
struct lttng_viewer_index viewer_index;
- struct lttng_packet_index packet_index;
+ struct ctf_packet_index packet_index;
struct relay_viewer_stream *vstream;
struct relay_stream *rstream;
#include <urcu/wfqueue.h>
#include <common/hashtable/hashtable.h>
-#include <common/index/lttng-index.h>
+#include <common/index/ctf-index.h>
#include "ctf-trace.h"
* Return 0 on success or else a negative value.
*/
int consumer_stream_write_index(struct lttng_consumer_stream *stream,
- struct lttng_packet_index *index)
+ struct ctf_packet_index *index)
{
int ret;
struct consumer_relayd_sock_pair *relayd;
ssize_t size_ret;
size_ret = index_write(stream->index_fd, index,
- sizeof(struct lttng_packet_index));
- if (size_ret < sizeof(struct lttng_packet_index)) {
+ sizeof(struct ctf_packet_index));
+ if (size_ret < sizeof(struct ctf_packet_index)) {
ret = -1;
} else {
ret = 0;
* Write index of a specific stream either on the relayd or local disk.
*/
int consumer_stream_write_index(struct lttng_consumer_stream *stream,
- struct lttng_packet_index *index);
+ struct ctf_packet_index *index);
int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
uint64_t session_id);
static int send_empty_index(struct lttng_consumer_stream *stream, uint64_t ts)
{
int ret;
- struct lttng_packet_index index;
+ struct ctf_packet_index index;
memset(&index, 0, sizeof(index));
index.timestamp_end = htobe64(ts);
struct lttng_consumer_local_data *ctx,
struct lttng_consumer_stream *stream, unsigned long len,
unsigned long padding,
- struct lttng_packet_index *index)
+ struct ctf_packet_index *index)
{
unsigned long mmap_offset;
void *mmap_base;
struct lttng_consumer_local_data *ctx,
struct lttng_consumer_stream *stream, unsigned long len,
unsigned long padding,
- struct lttng_packet_index *index)
+ struct ctf_packet_index *index)
{
ssize_t ret = 0, written = 0, ret_splice = 0;
loff_t offset = 0;
#include <common/compat/uuid.h>
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/pipe.h>
-#include <common/index/lttng-index.h>
+#include <common/index/ctf-index.h>
/* Commands for consumer */
enum lttng_consumer_command {
struct lttng_consumer_local_data *ctx,
struct lttng_consumer_stream *stream, unsigned long len,
unsigned long padding,
- struct lttng_packet_index *index);
+ struct ctf_packet_index *index);
ssize_t lttng_consumer_on_read_subbuffer_splice(
struct lttng_consumer_local_data *ctx,
struct lttng_consumer_stream *stream, unsigned long len,
unsigned long padding,
- struct lttng_packet_index *index);
+ struct ctf_packet_index *index);
int lttng_consumer_take_snapshot(struct lttng_consumer_stream *stream);
int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
unsigned long *pos);
noinst_LTLIBRARIES = libindex.la
-libindex_la_SOURCES = index.c index.h lttng-index.h
+libindex_la_SOURCES = index.c index.h ctf-index.h
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef LTTNG_INDEX_H
+#define LTTNG_INDEX_H
+
+#include <limits.h>
+
+#define CTF_INDEX_MAGIC 0xC1F1DCC1
+#define CTF_INDEX_MAJOR 1
+#define CTF_INDEX_MINOR 0
+
+/*
+ * Header at the beginning of each index file.
+ * All integer fields are stored in big endian.
+ */
+struct ctf_packet_index_file_hdr {
+ uint32_t magic;
+ uint32_t index_major;
+ uint32_t index_minor;
+ /* struct packet_index_len, in bytes */
+ uint32_t packet_index_len;
+} __attribute__((__packed__));
+
+/*
+ * Packet index generated for each trace packet store in a trace file.
+ * All integer fields are stored in big endian.
+ */
+struct ctf_packet_index {
+ uint64_t offset; /* offset of the packet in the file, in bytes */
+ uint64_t packet_size; /* packet size, in bits */
+ uint64_t content_size; /* content size, in bits */
+ uint64_t timestamp_begin;
+ uint64_t timestamp_end;
+ uint64_t events_discarded;
+ uint64_t stream_id;
+} __attribute__((__packed__));
+
+#endif /* LTTNG_INDEX_H */
{
int ret, fd = -1;
ssize_t size_ret;
- struct lttng_packet_index_file_hdr hdr;
+ struct ctf_packet_index_file_hdr hdr;
char fullpath[PATH_MAX];
ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR,
}
fd = ret;
- memcpy(hdr.magic, INDEX_MAGIC, sizeof(hdr.magic));
- hdr.index_major = htobe32(INDEX_MAJOR);
- hdr.index_minor = htobe32(INDEX_MINOR);
+ hdr.magic = htobe32(CTF_INDEX_MAGIC);
+ hdr.index_major = htobe32(CTF_INDEX_MAJOR);
+ hdr.index_minor = htobe32(CTF_INDEX_MINOR);
+ hdr.packet_index_len = sizeof(struct ctf_packet_index);
size_ret = lttng_write(fd, &hdr, sizeof(hdr));
if (size_ret < sizeof(hdr)) {
* Return "len" on success or else < len on error. errno contains error
* details.
*/
-ssize_t index_write(int fd, struct lttng_packet_index *index, size_t len)
+ssize_t index_write(int fd, struct ctf_packet_index *index, size_t len)
{
ssize_t ret;
#include <inttypes.h>
-#include "lttng-index.h"
+#include "ctf-index.h"
int index_create_file(char *path_name, char *stream_name, int uid, int gid,
uint64_t size, uint64_t count);
-ssize_t index_write(int fd, struct lttng_packet_index *index, size_t len);
+ssize_t index_write(int fd, struct ctf_packet_index *index, size_t len);
#endif /* _INDEX_H */
+++ /dev/null
-/*
- * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
- * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * David Goulet <dgoulet@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef LTTNG_INDEX_H
-#define LTTNG_INDEX_H
-
-#include <limits.h>
-
-#define INDEX_MAGIC "CTFIDX"
-#define INDEX_MAJOR 1
-#define INDEX_MINOR 0
-
-/*
- * Header at the beginning of each index file.
- * All integer fields are stored in big endian.
- */
-struct lttng_packet_index_file_hdr {
- char magic[6];
- uint32_t index_major;
- uint32_t index_minor;
-} __attribute__((__packed__));
-
-/*
- * Packet index generated for each trace packet store in a trace file.
- * All integer fields are stored in big endian.
- */
-struct lttng_packet_index {
- uint64_t offset; /* offset of the packet in the file, in bytes */
- uint64_t packet_size; /* packet size, in bits */
- uint64_t content_size; /* content size, in bits */
- uint64_t timestamp_begin;
- uint64_t timestamp_end;
- uint64_t events_discarded;
- uint64_t stream_id;
-} __attribute__((__packed__));
-
-#endif /* LTTNG_INDEX_H */
*
* Return 0 on success or else a negative value.
*/
-static int get_index_values(struct lttng_packet_index *index, int infd)
+static int get_index_values(struct ctf_packet_index *index, int infd)
{
int ret;
int err, write_index = 1;
ssize_t ret = 0;
int infd = stream->wait_fd;
- struct lttng_packet_index index;
+ struct ctf_packet_index index;
DBG("In read_subbuffer (infd : %d)", infd);
#include <common/common.h>
#include <common/defaults.h>
#include <common/sessiond-comm/relayd.h>
-#include <common/index/lttng-index.h>
+#include <common/index/ctf-index.h>
#include "relayd.h"
* Send index to the relayd.
*/
int relayd_send_index(struct lttcomm_relayd_sock *rsock,
- struct lttng_packet_index *index, uint64_t relay_stream_id,
+ struct ctf_packet_index *index, uint64_t relay_stream_id,
uint64_t net_seq_num)
{
int ret;
int relayd_end_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id,
unsigned int *is_data_inflight);
int relayd_send_index(struct lttcomm_relayd_sock *rsock,
- struct lttng_packet_index *index, uint64_t relay_stream_id,
+ struct ctf_packet_index *index, uint64_t relay_stream_id,
uint64_t net_seq_num);
#endif /* _RELAYD_H */
#include <lttng/lttng.h>
#include <common/defaults.h>
-#include <common/index/lttng-index.h>
+#include <common/index/ctf-index.h>
#include <config.h>
#define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR
*
* Return 0 on success or else a negative value.
*/
-static int get_index_values(struct lttng_packet_index *index,
+static int get_index_values(struct ctf_packet_index *index,
struct ustctl_consumer_stream *ustream)
{
int ret;
long ret = 0;
char dummy;
struct ustctl_consumer_stream *ustream;
- struct lttng_packet_index index;
+ struct ctf_packet_index index;
assert(stream);
assert(stream->ustream);
#include <common/common.h>
#include <bin/lttng-relayd/lttng-viewer.h>
-#include <common/index/lttng-index.h>
+#include <common/index/ctf-index.h>
#define SESSION1 "test1"
#define RELAYD_URL "net://localhost"