uint64_t size, uint64_t count)
{
int ret, fd = -1;
- struct lttng_packet_index_file_hdr hdr;
+ ssize_t size_ret;
+ 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);
- do {
- ret = write(fd, &hdr, sizeof(hdr));
- } while (ret < 0 && errno == EINTR);
- if (ret < 0) {
+ size_ret = lttng_write(fd, &hdr, sizeof(hdr));
+ if (size_ret < sizeof(hdr)) {
PERROR("write index header");
+ ret = -1;
goto error;
}
/*
* Write index values to the given fd of size len.
*
- * Return 0 on success or else a negative value on error.
+ * Return "len" on success or else < len on error. errno contains error
+ * details.
*/
-int 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)
{
- int ret;
+ ssize_t ret;
assert(fd >= 0);
assert(index);
- do {
- ret = write(fd, index, len);
- } while (ret < 0 && errno == EINTR);
- if (ret < 0) {
+ ret = lttng_write(fd, index, len);
+ if (ret < len) {
PERROR("writing index file");
}