diff options
| author | Andy Pan <i@andypan.me> | 2024-08-16 08:04:57 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-08-16 23:34:41 +0000 |
| commit | aa5d672a00f5bf64865d0e821623ed29bc416405 (patch) | |
| tree | d6a40cbc6aaf3c593ef03e8fe434c5e2aee565ee /src/strings/example_test.go | |
| parent | 660e7d60f28ed4b2c14f6e1fcf6d0e5a7f4aa1e0 (diff) | |
| download | go-aa5d672a00f5bf64865d0e821623ed29bc416405.tar.xz | |
os: use O_EXCL instead of O_TRUNC in CopyFS to disallow rewriting existing files
On Linux, a call to creat() is equivalent to calling open() with flags
equal to O_CREAT|O_WRONLY|O_TRUNC, which applies to other platforms
as well in a similar manner. Thus, to force CopyFS's behavior to
comply with the function comment, we need to replace O_TRUNC with O_EXCL.
Fixes #68895
Change-Id: I3e2ab153609d3c8cf20ce5969d6f3ef593833cd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/606095
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/strings/example_test.go')
0 files changed, 0 insertions, 0 deletions
