aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat
diff options
context:
space:
mode:
Diffstat (limited to 'internal/syscallcompat')
-rw-r--r--internal/syscallcompat/helpers.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/syscallcompat/helpers.go b/internal/syscallcompat/helpers.go
new file mode 100644
index 0000000..e2a2215
--- /dev/null
+++ b/internal/syscallcompat/helpers.go
@@ -0,0 +1,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
+}