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.
91d0750dbf
...
00fb6caf70
@ -1648,7 +1648,7 @@ static int journal_file_append_field(
|
|||||||
r = journal_file_find_field_object_with_hash(f, field, size, hash, &o, &p);
|
r = journal_file_find_field_object_with_hash(f, field, size, hash, &o, &p);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (r > 0) {
|
else if (r > 0) {
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
*ret = o;
|
*ret = o;
|
||||||
|
|||||||
@ -2368,27 +2368,18 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
|
|||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int return_data(
|
static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **data, size_t *size) {
|
||||||
sd_journal *j,
|
|
||||||
JournalFile *f,
|
|
||||||
Object *o,
|
|
||||||
const void **ret_data,
|
|
||||||
size_t *ret_size) {
|
|
||||||
|
|
||||||
size_t t;
|
size_t t;
|
||||||
uint64_t l;
|
uint64_t l;
|
||||||
int compression;
|
int compression;
|
||||||
|
|
||||||
assert(j);
|
|
||||||
assert(f);
|
|
||||||
|
|
||||||
l = le64toh(READ_NOW(o->object.size));
|
l = le64toh(READ_NOW(o->object.size));
|
||||||
if (l < offsetof(Object, data.payload))
|
if (l < offsetof(Object, data.payload))
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
l -= offsetof(Object, data.payload);
|
l -= offsetof(Object, data.payload);
|
||||||
|
t = (size_t) l;
|
||||||
|
|
||||||
/* We can't read objects larger than 4G on a 32bit machine */
|
/* We can't read objects larger than 4G on a 32bit machine */
|
||||||
t = (size_t) l;
|
|
||||||
if ((uint64_t) t != l)
|
if ((uint64_t) t != l)
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
|
|
||||||
@ -2406,18 +2397,14 @@ static int return_data(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (ret_data)
|
*data = f->compress_buffer;
|
||||||
*ret_data = f->compress_buffer;
|
*size = (size_t) rsize;
|
||||||
if (ret_size)
|
|
||||||
*ret_size = (size_t) rsize;
|
|
||||||
#else
|
#else
|
||||||
return -EPROTONOSUPPORT;
|
return -EPROTONOSUPPORT;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (ret_data)
|
*data = o->data.payload;
|
||||||
*ret_data = o->data.payload;
|
*size = t;
|
||||||
if (ret_size)
|
|
||||||
*ret_size = t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -2796,25 +2783,20 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
|
|||||||
return first ? 0 : 1;
|
return first ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_journal_get_cutoff_monotonic_usec(
|
_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) {
|
||||||
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;
|
|
||||||
JournalFile *f;
|
JournalFile *f;
|
||||||
|
bool found = false;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert_return(j, -EINVAL);
|
assert_return(j, -EINVAL);
|
||||||
assert_return(!journal_pid_changed(j), -ECHILD);
|
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) {
|
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)
|
if (r == -ENOENT)
|
||||||
continue;
|
continue;
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -2823,20 +2805,19 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
from = MIN(ff, from);
|
if (from)
|
||||||
to = MAX(tt, to);
|
*from = MIN(fr, *from);
|
||||||
|
if (to)
|
||||||
|
*to = MAX(t, *to);
|
||||||
} else {
|
} else {
|
||||||
from = ff;
|
if (from)
|
||||||
to = tt;
|
*from = fr;
|
||||||
|
if (to)
|
||||||
|
*to = t;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret_from)
|
|
||||||
*ret_from = from;
|
|
||||||
if (ret_to)
|
|
||||||
*ret_to = to;
|
|
||||||
|
|
||||||
return found;
|
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;
|
JournalFile *f;
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
|
|
||||||
assert_return(j, -EINVAL);
|
assert_return(j, -EINVAL);
|
||||||
assert_return(!journal_pid_changed(j), -ECHILD);
|
assert_return(!journal_pid_changed(j), -ECHILD);
|
||||||
assert_return(ret, -EINVAL);
|
assert_return(bytes, -EINVAL);
|
||||||
|
|
||||||
ORDERED_HASHMAP_FOREACH(f, j->files) {
|
ORDERED_HASHMAP_FOREACH(f, j->files) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
uint64_t b;
|
|
||||||
|
|
||||||
if (fstat(f->fd, &st) < 0)
|
if (fstat(f->fd, &st) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
b = (uint64_t) st.st_blocks;
|
sum += (uint64_t) st.st_blocks * 512ULL;
|
||||||
if (b > UINT64_MAX / 512)
|
|
||||||
return -EOVERFLOW;
|
|
||||||
b *= 512;
|
|
||||||
|
|
||||||
if (sum > UINT64_MAX - b)
|
|
||||||
return -EOVERFLOW;
|
|
||||||
sum += b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret = sum;
|
*bytes = sum;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
|
_public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
|
||||||
int r;
|
char *f;
|
||||||
|
|
||||||
assert_return(j, -EINVAL);
|
assert_return(j, -EINVAL);
|
||||||
assert_return(!journal_pid_changed(j), -ECHILD);
|
assert_return(!journal_pid_changed(j), -ECHILD);
|
||||||
assert_return(!isempty(field), -EINVAL);
|
assert_return(!isempty(field), -EINVAL);
|
||||||
assert_return(field_is_valid(field), -EINVAL);
|
assert_return(field_is_valid(field), -EINVAL);
|
||||||
|
|
||||||
r = free_and_strdup(&j->unique_field, field);
|
f = strdup(field);
|
||||||
if (r < 0)
|
if (!f)
|
||||||
return r;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
free(j->unique_field);
|
||||||
|
j->unique_field = f;
|
||||||
j->unique_file = NULL;
|
j->unique_file = NULL;
|
||||||
j->unique_offset = 0;
|
j->unique_offset = 0;
|
||||||
j->unique_file_lost = false;
|
j->unique_file_lost = false;
|
||||||
@ -2904,15 +2879,13 @@ _public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_journal_enumerate_unique(
|
_public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l) {
|
||||||
sd_journal *j,
|
|
||||||
const void **ret_data,
|
|
||||||
size_t *ret_size) {
|
|
||||||
|
|
||||||
size_t k;
|
size_t k;
|
||||||
|
|
||||||
assert_return(j, -EINVAL);
|
assert_return(j, -EINVAL);
|
||||||
assert_return(!journal_pid_changed(j), -ECHILD);
|
assert_return(!journal_pid_changed(j), -ECHILD);
|
||||||
|
assert_return(data, -EINVAL);
|
||||||
|
assert_return(l, -EINVAL);
|
||||||
assert_return(j->unique_field, -EINVAL);
|
assert_return(j->unique_field, -EINVAL);
|
||||||
|
|
||||||
k = strlen(j->unique_field);
|
k = strlen(j->unique_field);
|
||||||
@ -2986,15 +2959,16 @@ _public_ int sd_journal_enumerate_unique(
|
|||||||
j->unique_file->path,
|
j->unique_file->path,
|
||||||
j->unique_offset, ol, k + 1);
|
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),
|
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||||
"%s:offset " OFSfmt ": object does not start with \"%s=\"",
|
"%s:offset " OFSfmt ": object does not start with \"%s=\"",
|
||||||
j->unique_file->path,
|
j->unique_file->path,
|
||||||
j->unique_offset,
|
j->unique_offset,
|
||||||
j->unique_field);
|
j->unique_field);
|
||||||
|
|
||||||
/* OK, now let's see if we already returned this data object by checking if it exists in the
|
/* OK, now let's see if we already returned this data
|
||||||
* earlier traversed files. */
|
* object by checking if it exists in the earlier
|
||||||
|
* traversed files. */
|
||||||
found = false;
|
found = false;
|
||||||
ORDERED_HASHMAP_FOREACH(of, j->files) {
|
ORDERED_HASHMAP_FOREACH(of, j->files) {
|
||||||
if (of == j->unique_file)
|
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)
|
if (JOURNAL_HEADER_CONTAINS(of->header, n_fields) && le64toh(of->header->n_fields) <= 0)
|
||||||
continue;
|
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);
|
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)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
@ -3022,7 +2990,7 @@ _public_ int sd_journal_enumerate_unique(
|
|||||||
if (found)
|
if (found)
|
||||||
continue;
|
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)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
|||||||
@ -514,7 +514,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
|
|||||||
"epoll_ctl\0"
|
"epoll_ctl\0"
|
||||||
"epoll_ctl_old\0"
|
"epoll_ctl_old\0"
|
||||||
"epoll_pwait\0"
|
"epoll_pwait\0"
|
||||||
"epoll_pwait2\0"
|
|
||||||
"epoll_wait\0"
|
"epoll_wait\0"
|
||||||
"epoll_wait_old\0"
|
"epoll_wait_old\0"
|
||||||
"eventfd\0"
|
"eventfd\0"
|
||||||
@ -546,7 +545,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
|
|||||||
"msgsnd\0"
|
"msgsnd\0"
|
||||||
"pipe\0"
|
"pipe\0"
|
||||||
"pipe2\0"
|
"pipe2\0"
|
||||||
"process_madvise\0"
|
|
||||||
"process_vm_readv\0"
|
"process_vm_readv\0"
|
||||||
"process_vm_writev\0"
|
"process_vm_writev\0"
|
||||||
"semctl\0"
|
"semctl\0"
|
||||||
@ -595,7 +593,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
|
|||||||
"fsopen\0"
|
"fsopen\0"
|
||||||
"fspick\0"
|
"fspick\0"
|
||||||
"mount\0"
|
"mount\0"
|
||||||
"mount_setattr\0"
|
|
||||||
"move_mount\0"
|
"move_mount\0"
|
||||||
"open_tree\0"
|
"open_tree\0"
|
||||||
"pivot_root\0"
|
"pivot_root\0"
|
||||||
@ -691,7 +688,6 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
|
|||||||
"open_by_handle_at\0"
|
"open_by_handle_at\0"
|
||||||
"pivot_root\0"
|
"pivot_root\0"
|
||||||
"quotactl\0"
|
"quotactl\0"
|
||||||
"quotactl_path\0"
|
|
||||||
"setdomainname\0"
|
"setdomainname\0"
|
||||||
"setfsuid\0"
|
"setfsuid\0"
|
||||||
"setfsuid32\0"
|
"setfsuid32\0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user