Repository: moby/moby (language: go)

Issue:
Update GoDoc for ioutils (AtomicWriteFile) to document expected behavior
### Description

- Relates to https://github.com/moby/moby/issues/47498#issuecomment-1978920171

The `ioutils` utilities have different semantics than Go stdlib file utilities; unlike stdlib, these functions do not depend on the active umask. We should update their GoDoc to document the behavior, so that consumers are aware of their semantics.

Alternatively, we can change their behavior to take `umassk` into account, but this would be a breaking change, so not sure if we want to go that direction.



Discussion / hints:

Fix patch:
diff --git a/pkg/ioutils/fswriters.go b/pkg/ioutils/fswriters.go
index 82671d8cd55c5..05da97b0e416f 100644
--- a/pkg/ioutils/fswriters.go
+++ b/pkg/ioutils/fswriters.go
@@ -9,6 +9,7 @@ import (
 // NewAtomicFileWriter returns WriteCloser so that writing to it writes to a
 // temporary file and closing it atomically changes the temporary file to
 // destination path. Writing and closing concurrently is not allowed.
+// NOTE: umask is not considered for the file's permissions.
 func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) {
 	f, err := os.CreateTemp(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
 	if err != nil {
@@ -26,7 +27,8 @@ func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, err
 	}, nil
 }
 
-// AtomicWriteFile atomically writes data to a file named by filename.
+// AtomicWriteFile atomically writes data to a file named by filename and with the specified permission bits.
+// NOTE: umask is not considered for the file's permissions.
 func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
 	f, err := NewAtomicFileWriter(filename, perm)
 	if err != nil {


Test patch: