Skip to content

Commit

Permalink
sd-journal: use stat_verify_regular_full()
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwata committed Feb 15, 2024
1 parent 5ed024e commit cd82f8f
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/libsystemd/sd-journal/journal-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ static int journal_file_verify_header(JournalFile *f) {
}

int journal_file_fstat(JournalFile *f) {
int r;

assert(f);
assert(f->fd >= 0);

Expand All @@ -726,16 +724,9 @@ int journal_file_fstat(JournalFile *f) {

f->last_stat_usec = now(CLOCK_MONOTONIC);

/* Refuse dealing with files that aren't regular */
r = stat_verify_regular(&f->last_stat);
if (r < 0)
return r;

/* Refuse appending to files that are already deleted */
if (f->last_stat.st_nlink <= 0)
return -EIDRM;

return 0;
/* Refuse dealing with files that aren't regular. Also, refuse appending to files that are already
* deleted. */
return stat_verify_regular_full(&f->last_stat, /* check_removed = */ true);
}

static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
Expand Down

0 comments on commit cd82f8f

Please sign in to comment.