#ifndef BPFTOOL_VERSION /* bpftool's major and minor version numbers are aligned on libbpf's. There is * an offset of 6 for the version number, because bpftool's version was higher * than libbpf's when we adopted this scheme. The patch number remains at 0 * for now. Set BPFTOOL_VERSION to override.
*/ #define BPFTOOL_MAJOR_VERSION (LIBBPF_MAJOR_VERSION + 6) #define BPFTOOL_MINOR_VERSION LIBBPF_MINOR_VERSION #define BPFTOOL_PATCH_VERSION 0 #endif
for (i = 0; commands[i].cmd; i++) { if (!strcmp(commands[i].cmd, "prog")) { /* Assume we run a bootstrap version if "bpftool prog" * is not available.
*/
bootstrap = !commands[i].func; break;
}
}
if (json_output) {
jsonw_start_object(json_wtr); /* root object */
if (argc < 1 && cmds[0].func) return cmds[0].func(argc, argv);
for (i = 0; cmds[i].cmd; i++) { if (is_prefix(*argv, cmds[i].cmd)) { if (!cmds[i].func) {
p_err("command '%s' is not supported in bootstrap mode",
cmds[i].cmd); return -1;
} return cmds[i].func(argc - 1, argv + 1);
}
}
help(argc - 1, argv + 1);
return -1;
}
bool is_prefix(constchar *pfx, constchar *str)
{ if (!pfx) returnfalse; if (strlen(str) < strlen(pfx)) returnfalse;
return !memcmp(str, pfx, strlen(pfx));
}
/* Last argument MUST be NULL pointer */ int detect_common_prefix(constchar *arg, ...)
{ unsignedint count = 0; constchar *ref; char msg[256];
va_list ap;
snprintf(msg, sizeof(msg), "ambiguous prefix: '%s' could be '", arg);
va_start(ap, arg); while ((ref = va_arg(ap, constchar *))) { if (!is_prefix(arg, ref)) continue;
count++; if (count > 1)
strncat(msg, "' or '", sizeof(msg) - strlen(msg) - 1);
strncat(msg, ref, sizeof(msg) - strlen(msg) - 1);
}
va_end(ap);
strncat(msg, "'", sizeof(msg) - strlen(msg) - 1);
/* Append continuation lines if any (coming after a line ending * with '\' in the batch file).
*/ while ((cp = strstr(buf, "\\\n")) != NULL) { if (!fgets(contline, sizeof(contline), fp) ||
strlen(contline) == 0) {
p_err("missing continuation line on command %u",
lines);
err = -1; goto err_close;
}
cp = strchr(contline, '#'); if (cp)
*cp = '\0';
if (strlen(buf) + strlen(contline) + 1 > sizeof(buf)) {
p_err("command %u is too long", lines);
err = -1; goto err_close;
}
buf[strlen(buf) - 2] = '\0';
strcat(buf, contline);
}
n_argc = make_args(buf, n_argv, BATCH_ARG_NB_MAX, lines); if (!n_argc) continue; if (n_argc < 0) {
err = n_argc; goto err_close;
}
if (json_output) {
jsonw_start_object(json_wtr);
jsonw_name(json_wtr, "command");
jsonw_start_array(json_wtr); for (i = 0; i < n_argc; i++)
jsonw_string(json_wtr, n_argv[i]);
jsonw_end_array(json_wtr);
jsonw_name(json_wtr, "output");
}
#ifdef USE_LIBCAP /* Libcap < 2.63 hooks before main() to compute the number of * capabilities of the running kernel, and doing so it calls prctl() * which may fail and set errno to non-zero. * Let's reset errno to make sure this does not interfere with the * batch mode.
*/
errno = 0; #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.