mirror of
https://github.com/systemd/systemd
synced 2026-03-27 09:14:51 +01:00
Compare commits
No commits in common. "a4121e965f43bc323ec3c0ac212cee9d339f7be0" and "c21d094c652660f0a5e273a04988a58783ddc9e4" have entirely different histories.
a4121e965f
...
c21d094c65
@ -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) {
|
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;
|
_cleanup_close_ int fd = -1;
|
||||||
int r, ret;
|
int r, ret = 0;
|
||||||
|
|
||||||
assert(path);
|
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);
|
timespec_store(&ts[0], stamp);
|
||||||
ts[1] = ts[0];
|
ts[1] = ts[0];
|
||||||
r = futimens_opath(fd, ts);
|
r = utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), ts, 0);
|
||||||
} else
|
} else
|
||||||
r = futimens_opath(fd, NULL);
|
r = utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), NULL, 0);
|
||||||
if (r < 0 && ret >= 0)
|
if (r < 0 && ret >= 0)
|
||||||
return r;
|
return -errno;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -255,6 +255,10 @@ int fd_getcrtime(int fd, usec_t *ret) {
|
|||||||
return fd_getcrtime_at(fd, NULL, ret, AT_EMPTY_PATH);
|
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) {
|
int fd_setcrtime(int fd, usec_t usec) {
|
||||||
le64_t le;
|
le64_t le;
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ int fgetxattrat_fake_malloc(
|
|||||||
int fd_setcrtime(int fd, usec_t usec);
|
int fd_setcrtime(int fd, usec_t usec);
|
||||||
|
|
||||||
int fd_getcrtime(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 fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags);
|
||||||
|
|
||||||
int flistxattr_malloc(int fd, char **ret);
|
int flistxattr_malloc(int fd, char **ret);
|
||||||
|
|||||||
@ -380,9 +380,14 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_uint64(FILE *fp, uint64_t p) {
|
static int write_uint64(int fd, uint64_t p) {
|
||||||
if (fwrite(&p, sizeof(p), 1, fp) != 1)
|
ssize_t k;
|
||||||
|
|
||||||
|
k = write(fd, &p, sizeof(p));
|
||||||
|
if (k < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
if (k != sizeof(p))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -838,8 +843,7 @@ int journal_file_verify(
|
|||||||
bool entry_seqnum_set = false, entry_monotonic_set = false, entry_realtime_set = false, found_main_entry_array = false;
|
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;
|
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;
|
usec_t last_usec = 0;
|
||||||
_cleanup_close_ int data_fd = -1, entry_fd = -1, entry_array_fd = -1;
|
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;
|
MMapFileDescriptor *cache_data_fd = NULL, *cache_entry_fd = NULL, *cache_entry_array_fd = NULL;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
bool found_last = false;
|
bool found_last = false;
|
||||||
@ -906,24 +910,6 @@ int journal_file_verify(
|
|||||||
goto fail;
|
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) {
|
if (le32toh(f->header->compatible_flags) & ~HEADER_COMPATIBLE_SUPPORTED) {
|
||||||
log_error("Cannot verify file with unknown extensions.");
|
log_error("Cannot verify file with unknown extensions.");
|
||||||
r = -EOPNOTSUPP;
|
r = -EOPNOTSUPP;
|
||||||
@ -998,7 +984,7 @@ int journal_file_verify(
|
|||||||
switch (o->object.type) {
|
switch (o->object.type) {
|
||||||
|
|
||||||
case OBJECT_DATA:
|
case OBJECT_DATA:
|
||||||
r = write_uint64(data_fp, p);
|
r = write_uint64(data_fd, p);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -1016,7 +1002,7 @@ int journal_file_verify(
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = write_uint64(entry_fp, p);
|
r = write_uint64(entry_fd, p);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -1103,7 +1089,7 @@ int journal_file_verify(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OBJECT_ENTRY_ARRAY:
|
case OBJECT_ENTRY_ARRAY:
|
||||||
r = write_uint64(entry_array_fp, p);
|
r = write_uint64(entry_array_fd, p);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -1293,21 +1279,6 @@ int journal_file_verify(
|
|||||||
goto fail;
|
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
|
/* Second iteration: we follow all objects referenced from the
|
||||||
* two entry points: the object hash table and the entry
|
* two entry points: the object hash table and the entry
|
||||||
* array. We also check that everything referenced (directly
|
* array. We also check that everything referenced (directly
|
||||||
@ -1341,6 +1312,10 @@ int journal_file_verify(
|
|||||||
mmap_cache_free_fd(f->mmap, cache_entry_fd);
|
mmap_cache_free_fd(f->mmap, cache_entry_fd);
|
||||||
mmap_cache_free_fd(f->mmap, cache_entry_array_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)
|
if (first_contained)
|
||||||
*first_contained = le64toh(f->header->head_entry_realtime);
|
*first_contained = le64toh(f->header->head_entry_realtime);
|
||||||
if (last_validated)
|
if (last_validated)
|
||||||
@ -1360,6 +1335,15 @@ fail:
|
|||||||
(unsigned long long) f->last_stat.st_size,
|
(unsigned long long) f->last_stat.st_size,
|
||||||
100 * p / 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)
|
if (cache_data_fd)
|
||||||
mmap_cache_free_fd(f->mmap, cache_data_fd);
|
mmap_cache_free_fd(f->mmap, cache_data_fd);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user