struct fd_ops {
/// Lifetime management: constructor and destructor
- int (*create)(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t *aliased);
+ int (*create)(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t aliased[static LOG_ID_MAX]);
void (*destroy)(struct fd_info *fdi);
/// Read an entry into an internal buffer; requires `prepare_print` to have been called
* @param[in] conf The configuration
* @return 0 on success, -errno on failure
*/
-static int logger_create(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t *aliased)
+static int logger_create(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t aliased[static LOG_ID_MAX])
{
assert(fdi);
assert(conf);
log_id_t already = path_already_opened(actual_path, *used_paths);
if (already != LOG_ID_INVALID) {
- *aliased = already;
+ aliased[id] = already;
ret = -EALREADY;
goto free_fdi;
}
goto free_fdi;
}
+ aliased[id] = id;
lpd->entry = NULL;
lpd->monitor = false;
fdi->priv_data = lpd;
* @param[in] conf The configuration
* @return 0 on success, -errno on failure
*/
-static int pipe_create(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t *aliased)
+static int pipe_create(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t aliased[static LOG_ID_MAX])
{
assert(fdi);
assert(conf);
close(sock_fd);
return -ENOMEM;
}
+
+ aliased[id] = id;
+
+ ppd->enabled_buffers = 0;
ppd->data_len = 0;
ppd->sock_fd = sock_fd;
ppd->offset = 0;
ppd->eof = false;
+ for (int i = 0; i < LOG_ID_MAX; ++i)
+ if (aliased[i] == id)
+ bit_set(&ppd->enabled_buffers, i);
+
fdi->priv_data = ppd;
return 0;
}
monitor = false;
}
- int r = send_logger_request(filter_object, dump, monitor, ppd->sock_fd, compress, 1 << fdi->id);
+ int r = send_logger_request(filter_object, dump, monitor, ppd->sock_fd, compress, ppd->enabled_buffers);
if (r < 0)
return r;
struct pipe_priv_data {
size_t data_len;
size_t offset;
+ int enabled_buffers;
char buff[RECEIVE_BUFFER_SIZE];
int sock_fd;
bool eof;
return r;
}
-static int zero_copy_create(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t *aliased)
+static int zero_copy_create(struct fd_info *fdi, const struct log_config *conf, log_id_t id, list_head *used_paths, log_id_t aliased[static LOG_ID_MAX])
{
// We can't clear, so the flag is R not RW
fdi->fd = open(ZERO_COPY_DUMP_DEVICE_NAME, O_RDONLY | O_CLOEXEC);
return -ENOMEM;
}
+ aliased[id] = id;
zpd->this_read_ts = 0;
zpd->prev_read_ts = 0;
zpd->items = NULL;
if (!fdi)
return -ENOMEM;
- int r = fdi->ops->create(fdi, conf, i, &used_paths, &aliased[i]);
- if (r == 0)
- aliased[i] = i;
+ int r = fdi->ops->create(fdi, conf, i, &used_paths, aliased);
if (r < 0) {
// TODO: Inform about that again somewhere else (except if r == -EALREADY and aliased[i] != INVALID)
fdi_free(fdi);
{
struct fd_info info = {
.ops = &ops_pipe,
- .id = 123,
+ .id = LOG_ID_RADIO,
};
struct log_config conf = {};
list_head *fake_list = (list_head *)54321; // It's not used anyway :)
- assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, &(log_id_t){ LOG_ID_INVALID }) == -ENOENT);
+ log_id_t aliases[LOG_ID_MAX];
+ for (int i = 0; i < LOG_ID_MAX; ++i)
+ aliases[i] = LOG_ID_INVALID;
+ aliases[LOG_ID_RADIO] = LOG_ID_RADIO;
+ assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, aliases) == -ENOENT);
log_config_set(&conf, "radio_ctl_sock", "the_wrong_path");
- assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, &(log_id_t){ LOG_ID_INVALID }) == -ECONNREFUSED);
+ assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, aliases) == -ECONNREFUSED);
assert(last_sock == 0);
log_config_set(&conf, "radio_ctl_sock", the_right_path);
malloc_fail = true;
- assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, &(log_id_t){ LOG_ID_INVALID }) == -ENOMEM);
+ assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, aliases) == -ENOMEM);
assert(last_sock == 1 && closed[0]);
malloc_fail = false;
- assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, &(log_id_t){ LOG_ID_INVALID }) == 0);
+ assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, aliases) == 0);
struct log_filter *filter = log_filter_new();
assert(filter);
correct_sockfd = 2;
correct_request = DLOG_REQ_HANDLE_LOGUTIL;
- correct_send_data = "dlogutil filter0:V *:S";
+ correct_send_data = "dlogutil -b radio filter0:V *:S";
correct_send_datalen = strlen(correct_send_data) + 1;
send_return = -1;
assert(ops_pipe.prepare_print(&info, false, false, filter, NULL) == -1);
- correct_send_data = "dlogutil -d filter0:V *:S";
+ correct_send_data = "dlogutil -d -b radio filter0:V *:S";
correct_send_datalen = strlen(correct_send_data) + 1;
assert(ops_pipe.prepare_print(&info, true, false, filter, NULL) == -1);
log_filter_set_filterspec(filter, "filter1");
- correct_send_data = "dlogutil filter1:V filter0:V *:S";
+ correct_send_data = "dlogutil -b radio filter1:V filter0:V *:S";
correct_send_datalen = strlen(correct_send_data) + 1;
assert(ops_pipe.prepare_print(&info, false, false, filter, NULL) == -1);
log_filter_set_tid(filter, 123);
log_filter_set_pid(filter, 456);
- correct_send_data = "dlogutil --pid 456 --tid 123 filter1:V filter0:V *:S";
+ correct_send_data = "dlogutil -b radio --pid 456 --tid 123 filter1:V filter0:V *:S";
correct_send_datalen = strlen(correct_send_data) + 1;
assert(ops_pipe.prepare_print(&info, false, false, filter, NULL) == -1);
log_config_set(&conf, "kmsg_ctl_sock", the_right_path);
malloc_fail = false;
- assert(ops_pipe.create(&info, &conf, LOG_ID_KMSG, fake_list, &(log_id_t){ LOG_ID_INVALID }) == 0);
+ log_id_t aliases[LOG_ID_MAX];
+ for (int i = 0; i < NELEMS(aliases); ++i)
+ aliases[i] = LOG_ID_INVALID;
+ aliases[LOG_ID_KMSG] = LOG_ID_KMSG;
+ assert(ops_pipe.create(&info, &conf, LOG_ID_KMSG, fake_list, aliases) == 0);
struct log_filter *filter = log_filter_new();
assert(filter);
char just_big_enough_filter[MAX_LOGGER_REQUEST_LEN];
char very_big_string_for_comparison[MAX_LOGGER_REQUEST_LEN];
- int no_of_repetitions = (MAX_LOGGER_REQUEST_LEN - sizeof "dlogutil *:E plus some breathing room") / (sizeof (filter_test_word) - 1);
+ int no_of_repetitions = (MAX_LOGGER_REQUEST_LEN - sizeof "dlogutil -b kmsg *:E plus some breathing room") / (sizeof (filter_test_word) - 1);
- const char beginning[] = "dlogutil ";
+ const char beginning[] = "dlogutil -b kmsg ";
memcpy(very_big_string_for_comparison, beginning, sizeof(beginning) - 1);
size_t filter_len = 0;
size_t compar_len = sizeof(beginning) - 1;
struct log_config conf = {};
list_head *fake_list = (list_head *)54321; // It's not used anyway :)
- log_config_set(&conf, "kmsg_ctl_sock", the_right_path);
+ log_config_set(&conf, "radio_ctl_sock", the_right_path);
malloc_fail = false;
- assert(ops_pipe.create(&info, &conf, LOG_ID_KMSG, fake_list, &(log_id_t){ LOG_ID_INVALID }) == 0);
+ log_id_t aliases[LOG_ID_MAX];
+ for (int i = 0; i < NELEMS(aliases); ++i)
+ aliases[i] = LOG_ID_INVALID;
+ aliases[LOG_ID_RADIO] = LOG_ID_RADIO;
+ aliases[LOG_ID_KMSG] = LOG_ID_RADIO;
+ assert(ops_pipe.create(&info, &conf, LOG_ID_RADIO, fake_list, aliases) == 0);
assert(last_sock == 1 && !closed[0]);
struct pipe_priv_data *ppd = info.priv_data;
send_return = 0;
recv_pipe_fail = false;
- correct_send_data = "dlogutil -b radio --pid 456 --tid 123 filter1:V filter0:V *:S";
+ correct_send_data = "dlogutil -b radio -b kmsg --pid 456 --tid 123 filter1:V filter0:V *:S";
correct_send_datalen = strlen(correct_send_data) + 1;
assert(ops_pipe.prepare_print(&info, false, false, filter, NULL) == 0);
assert(info.fd == 2);