1
0
mirror of https://github.com/systemd/systemd synced 2026-03-18 11:04:46 +01:00

Compare commits

..

No commits in common. "91d0750dbf65e1ffa627fa880c50673a27758cf6" and "00fb6caf70c4ac742a5b4e913494e7d431abf0ec" have entirely different histories.

3 changed files with 40 additions and 76 deletions

View File

@ -1648,7 +1648,7 @@ static int journal_file_append_field(
r = journal_file_find_field_object_with_hash(f, field, size, hash, &o, &p);
if (r < 0)
return r;
if (r > 0) {
else if (r > 0) {
if (ret)
*ret = o;

View File

@ -2368,27 +2368,18 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
return -ENOENT;
}
static int return_data(
sd_journal *j,
JournalFile *f,
Object *o,
const void **ret_data,
size_t *ret_size) {
static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **data, size_t *size) {
size_t t;
uint64_t l;
int compression;
assert(j);
assert(f);
l = le64toh(READ_NOW(o->object.size));
if (l < offsetof(Object, data.payload))
return -EBADMSG;
l -= offsetof(Object, data.payload);
t = (size_t) l;
/* We can't read objects larger than 4G on a 32bit machine */
t = (size_t) l;
if ((uint64_t) t != l)
return -E2BIG;
@ -2406,18 +2397,14 @@ static int return_data(
if (r < 0)
return r;
if (ret_data)
*ret_data = f->compress_buffer;
if (ret_size)
*ret_size = (size_t) rsize;
*data = f->compress_buffer;
*size = (size_t) rsize;
#else
return -EPROTONOSUPPORT;
#endif
} else {
if (ret_data)
*ret_data = o->data.payload;
if (ret_size)
*ret_size = t;
*data = o->data.payload;
*size = t;
}
return 0;
@ -2796,25 +2783,20 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
return first ? 0 : 1;
}
_public_ int sd_journal_get_cutoff_monotonic_usec(
sd_journal *j,
sd_id128_t boot_id,
uint64_t *ret_from,
uint64_t *ret_to) {
uint64_t from = UINT64_MAX, to = UINT64_MAX;
bool found = false;
_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) {
JournalFile *f;
bool found = false;
int r;
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(ret_from != ret_to, -EINVAL);
assert_return(from || to, -EINVAL);
assert_return(from != to, -EINVAL);
ORDERED_HASHMAP_FOREACH(f, j->files) {
usec_t ff, tt;
usec_t fr, t;
r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &ff, &tt);
r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &fr, &t);
if (r == -ENOENT)
continue;
if (r < 0)
@ -2823,20 +2805,19 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(
continue;
if (found) {
from = MIN(ff, from);
to = MAX(tt, to);
if (from)
*from = MIN(fr, *from);
if (to)
*to = MAX(t, *to);
} else {
from = ff;
to = tt;
if (from)
*from = fr;
if (to)
*to = t;
found = true;
}
}
if (ret_from)
*ret_from = from;
if (ret_to)
*ret_to = to;
return found;
}
@ -2856,47 +2837,41 @@ void journal_print_header(sd_journal *j) {
}
}
_public_ int sd_journal_get_usage(sd_journal *j, uint64_t *ret) {
_public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) {
JournalFile *f;
uint64_t sum = 0;
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(ret, -EINVAL);
assert_return(bytes, -EINVAL);
ORDERED_HASHMAP_FOREACH(f, j->files) {
struct stat st;
uint64_t b;
if (fstat(f->fd, &st) < 0)
return -errno;
b = (uint64_t) st.st_blocks;
if (b > UINT64_MAX / 512)
return -EOVERFLOW;
b *= 512;
if (sum > UINT64_MAX - b)
return -EOVERFLOW;
sum += b;
sum += (uint64_t) st.st_blocks * 512ULL;
}
*ret = sum;
*bytes = sum;
return 0;
}
_public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
int r;
char *f;
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(!isempty(field), -EINVAL);
assert_return(field_is_valid(field), -EINVAL);
r = free_and_strdup(&j->unique_field, field);
if (r < 0)
return r;
f = strdup(field);
if (!f)
return -ENOMEM;
free(j->unique_field);
j->unique_field = f;
j->unique_file = NULL;
j->unique_offset = 0;
j->unique_file_lost = false;
@ -2904,15 +2879,13 @@ _public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
return 0;
}
_public_ int sd_journal_enumerate_unique(
sd_journal *j,
const void **ret_data,
size_t *ret_size) {
_public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l) {
size_t k;
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
assert_return(data, -EINVAL);
assert_return(l, -EINVAL);
assert_return(j->unique_field, -EINVAL);
k = strlen(j->unique_field);
@ -2986,15 +2959,16 @@ _public_ int sd_journal_enumerate_unique(
j->unique_file->path,
j->unique_offset, ol, k + 1);
if (memcmp(odata, j->unique_field, k) != 0 || ((const char*) odata)[k] != '=')
if (memcmp(odata, j->unique_field, k) || ((const char*) odata)[k] != '=')
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
"%s:offset " OFSfmt ": object does not start with \"%s=\"",
j->unique_file->path,
j->unique_offset,
j->unique_field);
/* OK, now let's see if we already returned this data object by checking if it exists in the
* earlier traversed files. */
/* OK, now let's see if we already returned this data
* object by checking if it exists in the earlier
* traversed files. */
found = false;
ORDERED_HASHMAP_FOREACH(of, j->files) {
if (of == j->unique_file)
@ -3004,13 +2978,7 @@ _public_ int sd_journal_enumerate_unique(
if (JOURNAL_HEADER_CONTAINS(of->header, n_fields) && le64toh(of->header->n_fields) <= 0)
continue;
/* We can reuse the hash from our current file only on old-style journal files
* without keyed hashes. On new-style files we have to calculate the hash anew, to
* take the per-file hash seed into consideration. */
if (!JOURNAL_HEADER_KEYED_HASH(j->unique_file->header) && !JOURNAL_HEADER_KEYED_HASH(of->header))
r = journal_file_find_data_object_with_hash(of, odata, ol, le64toh(o->data.hash), NULL, NULL);
else
r = journal_file_find_data_object(of, odata, ol, NULL, NULL);
if (r < 0)
return r;
if (r > 0) {
@ -3022,7 +2990,7 @@ _public_ int sd_journal_enumerate_unique(
if (found)
continue;
r = return_data(j, j->unique_file, o, ret_data, ret_size);
r = return_data(j, j->unique_file, o, data, l);
if (r < 0)
return r;

View File

@ -514,7 +514,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
"epoll_ctl\0"
"epoll_ctl_old\0"
"epoll_pwait\0"
"epoll_pwait2\0"
"epoll_wait\0"
"epoll_wait_old\0"
"eventfd\0"
@ -546,7 +545,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
"msgsnd\0"
"pipe\0"
"pipe2\0"
"process_madvise\0"
"process_vm_readv\0"
"process_vm_writev\0"
"semctl\0"
@ -595,7 +593,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
"fsopen\0"
"fspick\0"
"mount\0"
"mount_setattr\0"
"move_mount\0"
"open_tree\0"
"pivot_root\0"
@ -691,7 +688,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
"open_by_handle_at\0"
"pivot_root\0"
"quotactl\0"
"quotactl_path\0"
"setdomainname\0"
"setfsuid\0"
"setfsuid32\0"