aboutsummaryrefslogtreecommitdiff
path: root/src/os/root_unix.go
AgeCommit message (Collapse)Author
2025-07-18os: revert the use of AddCleanup to close files and rootsCarlos Amedee
This reverts commit fdaac84480b02e600660d0ca7c15339138807107. Updates #70907 Updates #74574 Updates #74642 Reason for revert: Issue #74574 Change-Id: I7b55b85736e4210d9b6f3fd7a24050ac7bdefef9 Reviewed-on: https://go-review.googlesource.com/c/go/+/688435 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-06-10os: do not follow dangling symlinks in Root when O_CREATE|O_EXCL on AIXDamien Neil
OpenFile with O_CREATE|O_EXCL should not follow dangling symlinks. On AIX it does, because AIX's openat(2) apparently returns ELOOP in this case. Most Unices return EEXIST. Ensure that we never follow symlinks in the final component of the path when opening a file with O_CREATE|O_EXCL. Fixes #73924 Change-Id: I869afb7faefccb0bb29d155553a7d7e5be80467d Reviewed-on: https://go-review.googlesource.com/c/go/+/677735 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-05-21os: add Root.MkdirAllDamien Neil
For #67002 Change-Id: Idd74b5b59e787e89bdfad82171b6a7719465f501 Reviewed-on: https://go-review.googlesource.com/c/go/+/674116 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-21os: add Root.RemoveAllDamien Neil
For #67002 Change-Id: If59dab4fd934a115d8ff383826525330de750b54 Reviewed-on: https://go-review.googlesource.com/c/go/+/661595 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-04-11all: use built-in min, max functionsMarcel Meyer
Change-Id: Ie76ebb556d635068342747f3f91dd7dc423df531 GitHub-Last-Rev: aea61fb3a054e6bd24f4684f90fb353d5682cd0b GitHub-Pull-Request: golang/go#73340 Reviewed-on: https://go-review.googlesource.com/c/go/+/664677 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2025-03-31os: avoid symlink races in RemoveAll on WindowsDamien Neil
Make the openat-using version of RemoveAll use the appropriate Windows equivalent, via new portable (but internal) functions added for os.Root. We could reimplement everything in terms of os.Root, but this is a bit simpler and keeps the existing code structure. Fixes #52745 Change-Id: I0eba0286398b351f2ee9abaa60e1675173988787 Reviewed-on: https://go-review.googlesource.com/c/go/+/661575 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-28os: add Root.SymlinkDamien Neil
For #67002 Change-Id: Ia1637b61eae49e97e1d07f058ad2390e74cd3403 Reviewed-on: https://go-review.googlesource.com/c/go/+/660635 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-03-24os: add Root.LinkDamien Neil
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>
2025-03-20os: add Root.RenameDamien Neil
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>
2025-03-19os: add Root.LchownDamien Neil
For #67002 Change-Id: I1bbf18838a1dd2281a2b6e56fc8a58ef70007adc Reviewed-on: https://go-review.googlesource.com/c/go/+/649536 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>
2025-03-18os: add Root.ChtimesDamien Neil
For #67002 Change-Id: I9b10ac30f852052c85d6d21eb1752a9de5474346 Reviewed-on: https://go-review.googlesource.com/c/go/+/649515 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-25os, syscall: use unix build tag where appropriateTobias Klauser
These newly added files may use the unix build tag instead of explitly listing all unix-like GOOS values. For #51572 Change-Id: I31c71d2b5533b39bbccd89bf616a99b8e33565d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/651996 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-13os: add Root.ChownDamien Neil
For #67002 Change-Id: I546537618cbe32217fa72264d49db2b1a1d3b6db Reviewed-on: https://go-review.googlesource.com/c/go/+/648295 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>
2025-02-13os: use AddCleanup to close filesCarlos Amedee
This changes the finalizer mechanism used to close files from runtime.SetFinalizer to runtime.AddCleanup. Updates #70907 Change-Id: I47582b81b0ed69609dd9dac158ec7bb8819c8c77 Reviewed-on: https://go-review.googlesource.com/c/go/+/638555 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-10os: add Root.ChmodDamien Neil
For #67002 Change-Id: Id6c3a2096bd10f5f5f6921a0441dc6d9e6cdeb3b Reviewed-on: https://go-review.googlesource.com/c/go/+/645718 Commit-Queue: Damien Neil <dneil@google.com> 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>
2025-02-10os: hide SetFinalizer from users of RootMichael Anthony Knyszek
Currently Root embeds a root and calls SetFinalizer on &r.root. This sets the finalizer on the outer root, which is visible to users of os.Root, and thus they can mutate the finalizer attached to it. This change modifies Root to not embed its inner root, but rather to refer to it by pointer. This allows us to set the finalizer on this independent inner object, preventing users of os.Root from changing the finalizer. This follows the same pattern as os.File's finalizer. Fixes #71617. Change-Id: Ibd199bab1b3c877d5e12ef380fd4647b4e10221f Reviewed-on: https://go-review.googlesource.com/c/go/+/647876 Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-21os: recognize EFTYPE, EINVAL as a refusal to open a symlinkDamien Neil
NetBSD returns EFTYPE when opening a symlink with O_NOFOLLOW. Dragonfly seems to return EINVAL. Only check for EINVAL on Dragonfly, since that seems like a bit of a broad net. Change-Id: I031357816f1fe4c370373001207e65996087597f Reviewed-on: https://go-review.googlesource.com/c/go/+/630396 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-20os: add Root.Stat and Root.LstatDamien Neil
For #67002 Change-Id: I0903f45dbb4c44ea0280c340c96c5f3c3c0781be Reviewed-on: https://go-review.googlesource.com/c/go/+/627475 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2024-11-20os: add Root.RemoveDamien Neil
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>
2024-11-20os: add RootDamien Neil
Add os.Root, a type which represents a directory and permits performing file operations within that directory. For #67002 Change-Id: I863f4f1bc320a89b1125ae4237761f3e9320a901 Reviewed-on: https://go-review.googlesource.com/c/go/+/612136 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>