diff options
| author | Damien Neil <dneil@google.com> | 2024-11-12 17:16:10 +0100 |
|---|---|---|
| committer | Damien Neil <dneil@google.com> | 2024-11-20 23:21:14 +0000 |
| commit | 49d24d469eb4ecbbf5a77d905ca2bd1da0e18bbd (patch) | |
| tree | 620dfeb866b8bdc9174da763bd19e9cbd0e53b28 /src/os/root_unix.go | |
| parent | 43d90c6a14e7b3fd1b3b8085b8071a09231c4b62 (diff) | |
| download | go-49d24d469eb4ecbbf5a77d905ca2bd1da0e18bbd.tar.xz | |
os: add Root.Remove
For #67002
Change-Id: Ibbf44c0bf62f53695a7399ba0dae5b84d5efd374
Reviewed-on: https://go-review.googlesource.com/c/go/+/627076
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/os/root_unix.go')
| -rw-r--r-- | src/os/root_unix.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/os/root_unix.go b/src/os/root_unix.go index 496a11903b..6f8f9c8e3e 100644 --- a/src/os/root_unix.go +++ b/src/os/root_unix.go @@ -119,6 +119,28 @@ func mkdirat(fd int, name string, perm FileMode) error { }) } +func removeat(fd int, name string) error { + // The system call interface forces us to know whether + // we are removing a file or directory. Try both. + e := ignoringEINTR(func() error { + return unix.Unlinkat(fd, name, 0) + }) + if e == nil { + return nil + } + e1 := ignoringEINTR(func() error { + return unix.Unlinkat(fd, name, unix.AT_REMOVEDIR) + }) + if e1 == nil { + return nil + } + // Both failed. See comment in Remove for how we decide which error to return. + if e1 != syscall.ENOTDIR { + return e1 + } + return e +} + // checkSymlink resolves the symlink name in parent, // and returns errSymlink with the link contents. // |
