Skip to content

Commit c79c2f1

Browse files
committed
proc: add more info for statx failures
This kind of error message is not super useful when debugging changes to procfs: statx(STATX_MNT_ID_...) ./: unsafe procfs detected: could not get mount id it would be nice to get the actual errno from statx(2) in these cases. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 8529a08 commit c79c2f1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

procfs_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ func getMountID(dir *os.File, path string) (uint64, error) {
333333
if stx.Mask&wantStxMask == 0 {
334334
// It's not a kernel limitation, for some reason we couldn't get a
335335
// mount ID. Assume it's some kind of attack.
336-
err = fmt.Errorf("%w: could not get mount id", errUnsafeProcfs)
336+
//
337+
// TODO: Once we bump the minimum Go version to 1.20, we can use
338+
// multiple %w verbs for this wrapping. For now we need to use a
339+
// compatibility shim for older Go versions.
340+
// err = fmt.Errorf("%w: could not get mount id: %w", errUnsafeProcfs, err)
341+
err = wrapBaseError(fmt.Errorf("could not get mount id: %w", err), errUnsafeProcfs)
337342
}
338343
if err != nil {
339344
return 0, &os.PathError{Op: "statx(STATX_MNT_ID_...)", Path: fullPath, Err: err}

0 commit comments

Comments
 (0)