daemon: NewDaemon(): replace system.MkdirAll for os.Mkdir where possible #44317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
system.MkdirAll()
is a special version of os.Mkdir to handle creating directoriesusing Windows volume paths (
"\\?\Volume{4c1b02c1-d990-11dc-99ae-806e6f6e6963}"
).This may be important when
MkdirAll
is used, which traverses all parent paths tocreate them if missing (ultimately landing on the "volume" path).
The daemon.NewDaemon() function used
system.MkdirAll()
in various places wherea subdirectory within
daemon.Root
was created. This appeared to be mostly outof convenience (to not have to handle
os.ErrExist
errors). Thedaemon.Root
directory should already be set up in these locations, and should be set up with
correct permissions. Using
system.MkdirAll()
would potentially mask errors ifthe root directory is missing, and instead set up parent directories (possibly
with incorrect permissions).
Because of the above, this patch changes
system.MkdirAll
toos.Mkdir
. As weare changing these lines, this patch also changes the legacy octal notation
(
0700
) to the now preferred0o700
.One location continues to use
system.MkdirAll
, as the temp-directory may beconfigured to be outside of
daemon.Root
, but a redundantos.Stat(realTmp)
was removed, as
system.MkdirAll
is expected to handle this.As we are changing these lines, this patch also changes the legacy octal notation
(
0700
) to the now preferred0o700
.