JournalFile *f,
const dual_timestamp *ts,
const sd_id128_t *boot_id,
+ const sd_id128_t *machine_id,
uint64_t xor_hash,
const EntryItem items[],
size_t n_items,
}
}
+ if (machine_id && sd_id128_is_null(f->header->machine_id))
+ /* Initialize machine ID when not set yet */
+ f->header->machine_id = *machine_id;
+
osize = offsetof(Object, entry.items) + (n_items * journal_file_entry_item_size(f));
r = journal_file_append_object(f, OBJECT_ENTRY, osize, &o, &np);
EntryItem *items;
uint64_t xor_hash = 0;
struct dual_timestamp _ts;
- sd_id128_t _boot_id;
+ sd_id128_t _boot_id, _machine_id, *machine_id;
int r;
assert(f);
boot_id = &_boot_id;
}
+ r = sd_id128_get_machine(&_machine_id);
+ if (r < 0) {
+ if (!ERRNO_IS_MACHINE_ID_UNSET(r))
+ return r;
+
+ /* If the machine ID is not initialized yet, handle gracefully */
+ machine_id = NULL;
+ } else
+ machine_id = &_machine_id;
+
#if HAVE_GCRYPT
r = journal_file_maybe_append_tag(f, ts->realtime);
if (r < 0)
typesafe_qsort(items, n_iovec, entry_item_cmp);
n_iovec = remove_duplicate_entry_items(items, n_iovec);
- r = journal_file_append_entry_internal(f, ts, boot_id, xor_hash, items, n_iovec, seqnum, seqnum_id, ret_object, ret_offset);
+ r = journal_file_append_entry_internal(
+ f,
+ ts,
+ boot_id,
+ machine_id,
+ xor_hash,
+ items,
+ n_iovec,
+ seqnum,
+ seqnum_id,
+ ret_object,
+ ret_offset);
/* If the memory mapping triggered a SIGBUS then we return an
* IO error and ignore the error code passed down to us, since
return r;
}
- r = journal_file_append_entry_internal(to, &ts, boot_id, xor_hash, items, n, seqnum, seqnum_id, NULL, NULL);
+ r = journal_file_append_entry_internal(
+ to,
+ &ts,
+ boot_id,
+ &from->header->machine_id,
+ xor_hash,
+ items,
+ n,
+ seqnum,
+ seqnum_id,
+ /* ret_object= */ NULL,
+ /* ret_offset= */ NULL);
if (mmap_cache_fd_got_sigbus(to->cache_fd))
return -EIO;