summaryrefslogtreecommitdiff
path: root/internal/syscallcompat/helpers.go
blob: e2a221565bfc5c9a555bbaf9305110130ba9c943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package syscallcompat

import (
	"os"
	"syscall"
)

// IsENOSPC tries to find out if "err" is a (potentially wrapped) ENOSPC error.
func IsENOSPC(err error) bool {
	// syscallcompat.EnospcPrealloc returns the naked syscall error
	if err == syscall.ENOSPC {
		return true
	}
	// os.File.WriteAt returns &PathError
	if err2, ok := err.(*os.PathError); ok {
		if err2.Err == syscall.ENOSPC {
			return true
		}
	}
	return false
}