summaryrefslogtreecommitdiffstats
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-04-25 03:10:39 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-08-01 00:31:44 +0200
commit6ecee6cf2b38d9ca35de9fd5e2034099aac1870b (patch)
tree1063c1647a638acdeee84b6127ba9160fab21576 /src/shared/logs-show.c
parentMerge pull request #33886 from DaanDeMeyer/autologin (diff)
downloadsystemd-6ecee6cf2b38d9ca35de9fd5e2034099aac1870b.tar.xz
systemd-6ecee6cf2b38d9ca35de9fd5e2034099aac1870b.zip
logs-show: rename BootId -> LogId
The struct itself is generic, and can be used for other ID. Let's rename it to more generic one. No functional change, just refactoring and preparation for later commits.
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 7dcc77e114..5dbe0d7727 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -1767,9 +1767,9 @@ int show_journal_by_unit(
static int discover_next_boot(
sd_journal *j,
- sd_id128_t previous_boot_id,
+ sd_id128_t previous_id,
bool advance_older,
- BootId *ret) {
+ LogId *ret) {
_cleanup_set_free_ Set *broken_ids = NULL;
int r;
@@ -1790,18 +1790,18 @@ static int discover_next_boot(
for (;;) {
sd_id128_t *id_dup;
- BootId boot;
+ LogId id;
r = sd_journal_step_one(j, !advance_older);
if (r < 0)
return r;
if (r == 0) {
sd_journal_flush_matches(j);
- *ret = (BootId) {};
+ *ret = (LogId) {};
return 0; /* End of journal, yay. */
}
- r = sd_journal_get_monotonic_usec(j, NULL, &boot.id);
+ r = sd_journal_get_monotonic_usec(j, NULL, &id.id);
if (r < 0)
return r;
@@ -1813,16 +1813,16 @@ static int discover_next_boot(
* speed things up, but let's not trust that it is complete, and hence, manually advance as
* necessary. */
- if (!sd_id128_is_null(previous_boot_id) && sd_id128_equal(boot.id, previous_boot_id))
+ if (!sd_id128_is_null(previous_id) && sd_id128_equal(id.id, previous_id))
continue;
- if (set_contains(broken_ids, &boot.id))
+ if (set_contains(broken_ids, &id.id))
continue;
/* Yay, we found a new boot ID from the entry object. Let's check there exist corresponding
* entries matching with the _BOOT_ID= data. */
- r = add_match_boot_id(j, boot.id);
+ r = add_match_boot_id(j, id.id);
if (r < 0)
return r;
@@ -1843,11 +1843,11 @@ static int discover_next_boot(
if (r == 0) {
log_debug("Whoopsie! We found a boot ID %s but can't read its first entry. "
"The journal seems to be corrupted. Ignoring the boot ID.",
- SD_ID128_TO_STRING(boot.id));
+ SD_ID128_TO_STRING(id.id));
goto try_again;
}
- r = sd_journal_get_realtime_usec(j, advance_older ? &boot.last_usec : &boot.first_usec);
+ r = sd_journal_get_realtime_usec(j, advance_older ? &id.last_usec : &id.first_usec);
if (r < 0)
return r;
@@ -1865,21 +1865,21 @@ static int discover_next_boot(
if (r == 0) {
log_debug("Whoopsie! We found a boot ID %s but can't read its last entry. "
"The journal seems to be corrupted. Ignoring the boot ID.",
- SD_ID128_TO_STRING(boot.id));
+ SD_ID128_TO_STRING(id.id));
goto try_again;
}
- r = sd_journal_get_realtime_usec(j, advance_older ? &boot.first_usec : &boot.last_usec);
+ r = sd_journal_get_realtime_usec(j, advance_older ? &id.first_usec : &id.last_usec);
if (r < 0)
return r;
sd_journal_flush_matches(j);
- *ret = boot;
+ *ret = id;
return 1;
try_again:
/* Save the bad boot ID. */
- id_dup = newdup(sd_id128_t, &boot.id, 1);
+ id_dup = newdup(sd_id128_t, &id.id, 1);
if (!id_dup)
return -ENOMEM;
@@ -1890,8 +1890,8 @@ static int discover_next_boot(
/* Move to the previous position again. */
sd_journal_flush_matches(j);
- if (!sd_id128_is_null(previous_boot_id)) {
- r = add_match_boot_id(j, previous_boot_id);
+ if (!sd_id128_is_null(previous_id)) {
+ r = add_match_boot_id(j, previous_id);
if (r < 0)
return r;
}
@@ -1909,7 +1909,7 @@ static int discover_next_boot(
if (r == 0)
return log_debug_errno(SYNTHETIC_ERRNO(ENODATA),
"Whoopsie! Cannot seek to the last entry of boot %s.",
- SD_ID128_TO_STRING(previous_boot_id));
+ SD_ID128_TO_STRING(previous_id));
sd_journal_flush_matches(j);
}
@@ -1972,9 +1972,9 @@ int journal_find_boot(sd_journal *j, sd_id128_t boot_id, int offset, sd_id128_t
* position us at the newest/oldest entry we have. */
for (int off = offset_start; ; off += advance_older ? -1 : 1) {
- BootId boot;
+ LogId id;
- r = discover_next_boot(j, boot_id, advance_older, &boot);
+ r = discover_next_boot(j, boot_id, advance_older, &id);
if (r < 0)
return r;
if (r == 0) {
@@ -1982,7 +1982,7 @@ int journal_find_boot(sd_journal *j, sd_id128_t boot_id, int offset, sd_id128_t
return false;
}
- boot_id = boot.id;
+ boot_id = id.id;
log_debug("Found boot ID %s by offset %i", SD_ID128_TO_STRING(boot_id), off);
if (off == offset) {
@@ -1996,16 +1996,16 @@ int journal_get_boots(
sd_journal *j,
bool advance_older,
size_t max_ids,
- BootId **ret_boots,
- size_t *ret_n_boots) {
+ LogId **ret_ids,
+ size_t *ret_n_ids) {
- _cleanup_free_ BootId *boots = NULL;
- size_t n_boots = 0;
+ _cleanup_free_ LogId *ids = NULL;
+ size_t n_ids = 0;
int r;
assert(j);
- assert(ret_boots);
- assert(ret_n_boots);
+ assert(ret_ids);
+ assert(ret_n_ids);
sd_journal_flush_matches(j);
@@ -2021,33 +2021,33 @@ int journal_get_boots(
* At this point the read pointer is positioned before the oldest entry in the whole journal. The
* next invocation of _next() will hence position us at the oldest entry we have. */
- sd_id128_t previous_boot_id = SD_ID128_NULL;
+ sd_id128_t previous_id = SD_ID128_NULL;
for (;;) {
- BootId boot;
+ LogId id;
- if (n_boots >= max_ids)
+ if (n_ids >= max_ids)
break;
- r = discover_next_boot(j, previous_boot_id, advance_older, &boot);
+ r = discover_next_boot(j, previous_id, advance_older, &id);
if (r < 0)
return r;
if (r == 0)
break;
- previous_boot_id = boot.id;
+ previous_id = id.id;
- FOREACH_ARRAY(i, boots, n_boots)
- if (sd_id128_equal(i->id, boot.id))
+ FOREACH_ARRAY(i, ids, n_ids)
+ if (sd_id128_equal(i->id, id.id))
/* The boot id is already stored, something wrong with the journal files.
* Exiting as otherwise this problem would cause an infinite loop. */
goto finish;
- if (!GREEDY_REALLOC_APPEND(boots, n_boots, &boot, 1))
+ if (!GREEDY_REALLOC_APPEND(ids, n_ids, &id, 1))
return -ENOMEM;
}
finish:
- *ret_boots = TAKE_PTR(boots);
- *ret_n_boots = n_boots;
- return n_boots > 0;
+ *ret_ids = TAKE_PTR(ids);
+ *ret_n_ids = n_ids;
+ return n_ids > 0;
}