mirror of
https://github.com/systemd/systemd
synced 2026-03-26 16:54:53 +01:00
Compare commits
4 Commits
c21d094c65
...
a4121e965f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4121e965f | ||
|
|
fad45198b6 | ||
|
|
b57947114e | ||
|
|
b71dbc6b56 |
@ -375,7 +375,7 @@ int fd_warn_permissions(const char *path, int fd) {
|
||||
|
||||
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
int r, ret = 0;
|
||||
int r, ret;
|
||||
|
||||
assert(path);
|
||||
|
||||
@ -412,11 +412,11 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
|
||||
|
||||
timespec_store(&ts[0], stamp);
|
||||
ts[1] = ts[0];
|
||||
r = utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), ts, 0);
|
||||
r = futimens_opath(fd, ts);
|
||||
} else
|
||||
r = utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), NULL, 0);
|
||||
r = futimens_opath(fd, NULL);
|
||||
if (r < 0 && ret >= 0)
|
||||
return -errno;
|
||||
return r;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -255,10 +255,6 @@ int fd_getcrtime(int fd, usec_t *ret) {
|
||||
return fd_getcrtime_at(fd, NULL, ret, AT_EMPTY_PATH);
|
||||
}
|
||||
|
||||
int path_getcrtime(const char *p, usec_t *ret) {
|
||||
return fd_getcrtime_at(AT_FDCWD, p, ret, 0);
|
||||
}
|
||||
|
||||
int fd_setcrtime(int fd, usec_t usec) {
|
||||
le64_t le;
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ int fgetxattrat_fake_malloc(
|
||||
int fd_setcrtime(int fd, usec_t usec);
|
||||
|
||||
int fd_getcrtime(int fd, usec_t *usec);
|
||||
int path_getcrtime(const char *p, usec_t *usec);
|
||||
int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags);
|
||||
|
||||
int flistxattr_malloc(int fd, char **ret);
|
||||
|
||||
@ -380,14 +380,9 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int write_uint64(int fd, uint64_t p) {
|
||||
ssize_t k;
|
||||
|
||||
k = write(fd, &p, sizeof(p));
|
||||
if (k < 0)
|
||||
static int write_uint64(FILE *fp, uint64_t p) {
|
||||
if (fwrite(&p, sizeof(p), 1, fp) != 1)
|
||||
return -errno;
|
||||
if (k != sizeof(p))
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -843,7 +838,8 @@ int journal_file_verify(
|
||||
bool entry_seqnum_set = false, entry_monotonic_set = false, entry_realtime_set = false, found_main_entry_array = false;
|
||||
uint64_t n_weird = 0, n_objects = 0, n_entries = 0, n_data = 0, n_fields = 0, n_data_hash_tables = 0, n_field_hash_tables = 0, n_entry_arrays = 0, n_tags = 0;
|
||||
usec_t last_usec = 0;
|
||||
int data_fd = -1, entry_fd = -1, entry_array_fd = -1;
|
||||
_cleanup_close_ int data_fd = -1, entry_fd = -1, entry_array_fd = -1;
|
||||
_cleanup_fclose_ FILE *data_fp = NULL, *entry_fp = NULL, *entry_array_fp = NULL;
|
||||
MMapFileDescriptor *cache_data_fd = NULL, *cache_entry_fd = NULL, *cache_entry_array_fd = NULL;
|
||||
unsigned i;
|
||||
bool found_last = false;
|
||||
@ -910,6 +906,24 @@ int journal_file_verify(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = take_fdopen_unlocked(&data_fd, "w+", &data_fp);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to open data file stream: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = take_fdopen_unlocked(&entry_fd, "w+", &entry_fp);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to open entry file stream: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = take_fdopen_unlocked(&entry_array_fd, "w+", &entry_array_fp);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to open entry array file stream: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (le32toh(f->header->compatible_flags) & ~HEADER_COMPATIBLE_SUPPORTED) {
|
||||
log_error("Cannot verify file with unknown extensions.");
|
||||
r = -EOPNOTSUPP;
|
||||
@ -984,7 +998,7 @@ int journal_file_verify(
|
||||
switch (o->object.type) {
|
||||
|
||||
case OBJECT_DATA:
|
||||
r = write_uint64(data_fd, p);
|
||||
r = write_uint64(data_fp, p);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1002,7 +1016,7 @@ int journal_file_verify(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = write_uint64(entry_fd, p);
|
||||
r = write_uint64(entry_fp, p);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1089,7 +1103,7 @@ int journal_file_verify(
|
||||
break;
|
||||
|
||||
case OBJECT_ENTRY_ARRAY:
|
||||
r = write_uint64(entry_array_fd, p);
|
||||
r = write_uint64(entry_array_fp, p);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1279,6 +1293,21 @@ int journal_file_verify(
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fflush(data_fp) != 0) {
|
||||
r = log_error_errno(errno, "Failed to flush data file stream: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fflush(entry_fp) != 0) {
|
||||
r = log_error_errno(errno, "Failed to flush entry file stream: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fflush(entry_array_fp) != 0) {
|
||||
r = log_error_errno(errno, "Failed to flush entry array file stream: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Second iteration: we follow all objects referenced from the
|
||||
* two entry points: the object hash table and the entry
|
||||
* array. We also check that everything referenced (directly
|
||||
@ -1312,10 +1341,6 @@ int journal_file_verify(
|
||||
mmap_cache_free_fd(f->mmap, cache_entry_fd);
|
||||
mmap_cache_free_fd(f->mmap, cache_entry_array_fd);
|
||||
|
||||
safe_close(data_fd);
|
||||
safe_close(entry_fd);
|
||||
safe_close(entry_array_fd);
|
||||
|
||||
if (first_contained)
|
||||
*first_contained = le64toh(f->header->head_entry_realtime);
|
||||
if (last_validated)
|
||||
@ -1335,15 +1360,6 @@ fail:
|
||||
(unsigned long long) f->last_stat.st_size,
|
||||
100 * p / f->last_stat.st_size);
|
||||
|
||||
if (data_fd >= 0)
|
||||
safe_close(data_fd);
|
||||
|
||||
if (entry_fd >= 0)
|
||||
safe_close(entry_fd);
|
||||
|
||||
if (entry_array_fd >= 0)
|
||||
safe_close(entry_array_fd);
|
||||
|
||||
if (cache_data_fd)
|
||||
mmap_cache_free_fd(f->mmap, cache_data_fd);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user