diff options
| author | Damien Neil <dneil@google.com> | 2025-03-19 11:15:06 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-03-20 15:12:24 -0700 |
| commit | 2ffda87f2dce71024f72ccff32cbfe29ee676bf8 (patch) | |
| tree | 5b57b951657aede28982a20aeeb85d825e19670a /src/os/root_openat.go | |
| parent | 686128a9f3f112c2e103622190673656811dee5f (diff) | |
| download | go-2ffda87f2dce71024f72ccff32cbfe29ee676bf8.tar.xz | |
os: add Root.Rename
For #67002
Change-Id: Ifb1042bc5ceaeea64296763319b24634bbcb0bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/659416
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/os/root_openat.go')
| -rw-r--r-- | src/os/root_openat.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/os/root_openat.go b/src/os/root_openat.go index 8c07784b5a..2cb867459b 100644 --- a/src/os/root_openat.go +++ b/src/os/root_openat.go @@ -138,6 +138,19 @@ func rootRemove(r *Root, name string) error { return nil } +func rootRename(r *Root, oldname, newname string) error { + _, err := doInRoot(r, oldname, func(oldparent sysfdType, oldname string) (struct{}, error) { + _, err := doInRoot(r, newname, func(newparent sysfdType, newname string) (struct{}, error) { + return struct{}{}, renameat(oldparent, oldname, newparent, newname) + }) + return struct{}{}, err + }) + if err != nil { + return &LinkError{"renameat", oldname, newname, err} + } + return err +} + // doInRoot performs an operation on a path in a Root. // // It opens the directory containing the final element of the path, |
