ret = run_as_mkdir(fullpath, S_IRWXU | S_IRWXG, uid, gid);
if (ret < 0) {
if (ret != -EEXIST) {
- ERR("Index trace directory creation error");
+ PERROR("Index trace directory creation error");
goto error;
}
}
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);
+ hdr.packet_index_len = htobe32(sizeof(struct ctf_packet_index));
size_ret = lttng_write(fd, &hdr, sizeof(hdr));
if (size_ret < sizeof(hdr)) {
{
ssize_t ret;
- assert(fd >= 0);
assert(index);
+ if (fd < 0) {
+ ret = -EINVAL;
+ goto error;
+ }
+
ret = lttng_write(fd, index, len);
if (ret < len) {
PERROR("writing index file");
}
+error:
return ret;
}