File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ static bool drop_reason_inited = false;
1818bool drop_reason_support ()
1919{
2020 return simple_exec ("cat /sys/kernel/debug/tracing/events/skb/"
21- "kfree_skb/format | grep NOT_SPECIFIED" ) == 0 ;
21+ "kfree_skb/format 2>/dev/null | "
22+ "grep NOT_SPECIFIED" ) == 0 ;
2223}
2324
2425static int parse_reason_enum ()
Original file line number Diff line number Diff line change @@ -375,19 +375,39 @@ static int trace_prepare_traces()
375375int trace_prepare ()
376376{
377377 trace_t * trace ;
378+ int err ;
378379
379- if (trace_prepare_args ())
380- return -1 ;
380+ err = trace_prepare_args ();
381+ if (err )
382+ goto err ;
381383
382- if (trace_prepare_traces ())
383- return -1 ;
384+ err = trace_prepare_traces ();
385+ if (err )
386+ goto err ;
384387
385388 if (trace_ctx .args .show_traces ) {
386389 trace_show (& root_group );
387390 exit (0 );
388391 }
389392
393+ if (geteuid () != 0 ) {
394+ pr_err ("Please run as root!\n" );
395+ err = - EPERM ;
396+ goto err ;
397+ }
398+
399+ #ifndef COMPAT_MODE
400+ if (!file_exist ("/sys/kernel/btf/vmlinux" )) {
401+ pr_err ("BTF is not support by your kernel, please compile"
402+ "this tool with \"COMPAT=1\"\n" );
403+ err = - ENOTSUP ;
404+ goto err ;
405+ }
406+ #endif
407+
390408 return 0 ;
409+ err :
410+ return err ;
391411}
392412
393413static int trace_bpf_load ()
You can’t perform that action at this time.
0 commit comments