+static bool whole_file_precedes_location(JournalFile *f, Location *l, direction_t direction) {
+ assert(f);
+ assert(l);
+
+ if (l->type != LOCATION_DISCRETE && l->type != LOCATION_SEEK)
+ return false;
+
+ if (l->seqnum_set && sd_id128_equal(l->seqnum_id, f->header->seqnum_id))
+ return direction == DIRECTION_DOWN ?
+ l->seqnum > le64toh(f->header->tail_entry_seqnum) :
+ l->seqnum < le64toh(f->header->head_entry_seqnum);
+
+ if (l->realtime_set)
+ return direction == DIRECTION_DOWN ?
+ l->realtime > le64toh(f->header->tail_entry_realtime) :
+ l->realtime < le64toh(f->header->head_entry_realtime);
+
+ return false;
+}
+
+static bool file_may_have_preceding_entry(JournalFile *f, JournalFile *of, uint64_t op, direction_t direction) {
+ Object *o;
+ int r;
+
+ assert(f);
+ assert(of);
+
+ r = journal_file_move_to_object(of, OBJECT_ENTRY, op, &o);
+ if (r < 0)
+ return true;
+
+ if (sd_id128_equal(f->header->seqnum_id, of->header->seqnum_id))
+ return direction == DIRECTION_DOWN ?
+ le64toh(o->entry.seqnum) >= le64toh(f->header->head_entry_seqnum) :
+ le64toh(o->entry.seqnum) <= le64toh(f->header->tail_entry_seqnum);
+
+ return direction == DIRECTION_DOWN ?
+ le64toh(o->entry.realtime) >= le64toh(f->header->head_entry_realtime) :
+ le64toh(o->entry.realtime) <= le64toh(f->header->tail_entry_realtime);
+}
+