iovisor/bcc

better permission denied error messages when not root/privileged

Open

#1,325 opened on 2017年8月28日

GitHub で見る
 (7 comments) (0 reactions) (0 assignees)C (22,409 stars) (4,051 forks)batch import
enhancementhelp wantedprio:low

説明

Sent to me by a coworker:

/virtual/main.c:8:1: error: could not open bpf map: Operation not permitted
is maps/hash map type enabled in your kernel?
BPF_HASH(counts, struct key_t);
^
/virtual/include/bcc/helpers.h:119:48: note: expanded from macro 'BPF_HASH'
  BPF_HASHX(__VA_ARGS__, BPF_HASH4, BPF_HASH3, BPF_HASH2, BPF_HASH1)(__VA_ARGS__)
                                               ^
/virtual/main.c:9:1: error: could not open bpf map: Operation not permitted
is maps/stacktrace map type enabled in your kernel?
BPF_STACK_TRACE(stack_traces, 1024);
^
/virtual/include/bcc/helpers.h:154:3: note: expanded from macro 'BPF_STACK_TRACE'
  BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, _max_entries);
  ^
/virtual/include/bcc/helpers.h:59:76: note: expanded from macro 'BPF_TABLE'
#define BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries) \
                                                                           ^
/virtual/include/bcc/helpers.h:55:4: note: expanded from macro '\
BPF_F_TABLE'
}; \
   ^
/virtual/main.c:16:19: error: bpf_table stack_traces failed to open
    key.stackid = stack_traces.get_stackid(ctx, BPF_F_REUSE_STACKID);
                  ^
3 errors generated.
Failed to compile BPF module

Is there a way we can improve this? Eg, if it said:

$ /usr/share/bcc/tools/stackcount __alloc_fd
Permission denied (not root or unprivileged). Use -v for verbose.

And the BPF() call could be passed a verbose flag (which would default to verbose, so tools that supported a "-v" could then overwrite it to be not verbose when -v was not used).

コントリビューターガイド