diff options
Diffstat (limited to 'cmd/zed/zed_conf.c')
-rw-r--r-- | cmd/zed/zed_conf.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/cmd/zed/zed_conf.c b/cmd/zed/zed_conf.c index 59935102f123..29de27c77c34 100644 --- a/cmd/zed/zed_conf.c +++ b/cmd/zed/zed_conf.c @@ -48,6 +48,7 @@ zed_conf_init(struct zed_conf *zcp) zcp->zevent_fd = -1; /* opened in zed_event_init() */ zcp->max_jobs = 16; + zcp->max_zevent_buf_len = 1 << 20; if (!(zcp->pid_file = strdup(ZED_PID_FILE)) || !(zcp->zedlet_dir = strdup(ZED_ZEDLET_DIR)) || @@ -141,6 +142,8 @@ _zed_conf_display_help(const char *prog, boolean_t got_err) .v = ZED_STATE_FILE }, { .o = "-j JOBS", .d = "Start at most JOBS at once.", .v = "16" }, + { .o = "-b LEN", .d = "Cap kernel event buffer at LEN entries.", + .v = "1048576" }, {}, }; @@ -230,7 +233,7 @@ _zed_conf_parse_path(char **resultp, const char *path) void zed_conf_parse_opts(struct zed_conf *zcp, int argc, char **argv) { - const char * const opts = ":hLVd:p:P:s:vfFMZIj:"; + const char * const opts = ":hLVd:p:P:s:vfFMZIj:b:"; int opt; unsigned long raw; @@ -291,6 +294,17 @@ zed_conf_parse_opts(struct zed_conf *zcp, int argc, char **argv) zcp->max_jobs = raw; } break; + case 'b': + errno = 0; + raw = strtoul(optarg, NULL, 0); + if (errno == ERANGE || raw > INT32_MAX) { + zed_log_die("%lu is too large", raw); + } if (raw == 0) { + zcp->max_zevent_buf_len = INT32_MAX; + } else { + zcp->max_zevent_buf_len = raw; + } + break; case '?': default: if (optopt == '?') @@ -643,7 +657,7 @@ zed_conf_read_state(struct zed_conf *zcp, uint64_t *eidp, int64_t etime[]) } else if (n != len) { errno = EIO; zed_log_msg(LOG_WARNING, - "Failed to read state file \"%s\": Read %d of %d bytes", + "Failed to read state file \"%s\": Read %zd of %zd bytes", zcp->state_file, n, len); return (-1); } @@ -692,7 +706,7 @@ zed_conf_write_state(struct zed_conf *zcp, uint64_t eid, int64_t etime[]) if (n != len) { errno = EIO; zed_log_msg(LOG_WARNING, - "Failed to write state file \"%s\": Wrote %d of %d bytes", + "Failed to write state file \"%s\": Wrote %zd of %zd bytes", zcp->state_file, n, len); return (-1); } |