CL 150497 enabled TestRemoveAllDot on "noat" systems.
However, this test is failing on Plan 9 because the rmdir
system call allows to remove "." on Plan 9.
This change prevents the "noat" implementation of RemoveAll to
remove ".", so it remains consistent with the "at" implementation.
Fixes #28903.
Change-Id: Ifc8fe36bdd8053a4e416f0590663c844c97ce72a
Reviewed-on: https://go-review.googlesource.com/c/150621
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
}
return nil
}
+
+// endsWithDot reports whether the final component of path is ".".
+func endsWithDot(path string) bool {
+ if path == "." {
+ return true
+ }
+ if len(path) >= 2 && path[len(path)-1] == '.' && IsPathSeparator(path[len(path)-2]) {
+ return true
+ }
+ return false
+}
return NewFile(uintptr(fd), path), nil
}
-
-// endsWithDot returns whether the final component of path is ".".
-func endsWithDot(path string) bool {
- if path == "." {
- return true
- }
- if len(path) >= 2 && path[len(path)-1] == '.' && IsPathSeparator(path[len(path)-2]) {
- return true
- }
- return false
-}
return nil
}
+ // The rmdir system call permits removing "." on Plan 9,
+ // so we don't permit it to remain consistent with the
+ // "at" implementation of RemoveAll.
+ if endsWithDot(path) {
+ return &PathError{"RemoveAll", path, syscall.EINVAL}
+ }
+
// Simple case: if Remove works, we're done.
err := Remove(path)
if err == nil || IsNotExist(err) {