aboutsummaryrefslogtreecommitdiff
path: root/src/os/root_openat.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2025-03-20 12:41:21 -0700
committerGopher Robot <gobot@golang.org>2025-03-24 07:53:38 -0700
commitd2d1fd68b6299d4645298e6d70fe8e8cfd98001a (patch)
tree8108bd9125f95c6a66e5c2c30db5614a6c939ff8 /src/os/root_openat.go
parent4ae6ab2bdfe3ebe8340d0d49fd2bb73f1a3e19ff (diff)
downloadgo-d2d1fd68b6299d4645298e6d70fe8e8cfd98001a.tar.xz
os: add Root.Link
For #67002 Change-Id: I223f3f2dbc8b02726f4ce5a017c628c4a20f109a Reviewed-on: https://go-review.googlesource.com/c/go/+/659757 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/os/root_openat.go')
-rw-r--r--src/os/root_openat.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/os/root_openat.go b/src/os/root_openat.go
index 2cb867459b..6591825648 100644
--- a/src/os/root_openat.go
+++ b/src/os/root_openat.go
@@ -151,6 +151,19 @@ func rootRename(r *Root, oldname, newname string) error {
return err
}
+func rootLink(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{}{}, linkat(oldparent, oldname, newparent, newname)
+ })
+ return struct{}{}, err
+ })
+ if err != nil {
+ return &LinkError{"linkat", 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,