@@ -207,8 +207,8 @@ func unsafeStringPtr(str string) (unsafe.Pointer, error) {
207207// group and name must be alphanumeric or underscore, as required by the kernel.
208208func getTraceEventID (group , name string ) (uint64 , error ) {
209209 tid , err := uint64FromFile (tracefsPath , "events" , group , name , "id" )
210- if errors .Is (err , ErrNotSupported ) {
211- return 0 , fmt .Errorf ("trace event %s/%s: %w" , group , name , ErrNotSupported )
210+ if errors .Is (err , os . ErrNotExist ) {
211+ return 0 , fmt .Errorf ("trace event %s/%s: %w" , group , name , os . ErrNotExist )
212212 }
213213 if err != nil {
214214 return 0 , fmt .Errorf ("reading trace event ID of %s/%s: %w" , group , name , err )
@@ -219,9 +219,11 @@ func getTraceEventID(group, name string) (uint64, error) {
219219
220220// getPMUEventType reads a Performance Monitoring Unit's type (numeric identifier)
221221// from /sys/bus/event_source/devices/<pmu>/type.
222+ //
223+ // Returns ErrNotSupported if the pmu type is not supported.
222224func getPMUEventType (typ probeType ) (uint64 , error ) {
223225 et , err := uint64FromFile ("/sys/bus/event_source/devices" , typ .String (), "type" )
224- if errors .Is (err , ErrNotSupported ) {
226+ if errors .Is (err , os . ErrNotExist ) {
225227 return 0 , fmt .Errorf ("pmu type %s: %w" , typ , ErrNotSupported )
226228 }
227229 if err != nil {
@@ -255,22 +257,13 @@ func openTracepointPerfEvent(tid uint64) (*internal.FD, error) {
255257// and joined onto base. Returns error if base no longer prefixes the path after
256258// joining all components.
257259func uint64FromFile (base string , path ... string ) (uint64 , error ) {
258-
259- // Resolve leaf path separately for error feedback. Makes the join onto
260- // base more readable (can't mix with variadic args).
261260 l := filepath .Join (path ... )
262-
263261 p := filepath .Join (base , l )
264262 if ! strings .HasPrefix (p , base ) {
265263 return 0 , fmt .Errorf ("path '%s' attempts to escape base path '%s': %w" , l , base , errInvalidInput )
266264 }
267265
268266 data , err := ioutil .ReadFile (p )
269- if os .IsNotExist (err ) {
270- // Only echo leaf path, the base path can be prepended at the call site
271- // if more verbosity is required.
272- return 0 , fmt .Errorf ("symbol %s: %w" , l , ErrNotSupported )
273- }
274267 if err != nil {
275268 return 0 , fmt .Errorf ("reading file %s: %w" , p , err )
276269 }
0 commit comments