Commit a3a584e
os: RemoveAll: fix symlink race for unix
Since all the platforms now support O_DIRECTORY flag for open, it can be
used to (together with O_NOFOLLOW) to ensure we open a directory, thus
eliminating the need to call stat before open. This fixes the symlink race,
when a directory is replaced by a symlink in between stat and open calls.
While at it, rename openFdAt to openDirAt, because this function is (and was)
meant for directories only.
NOTE Solaris supports O_DIRECTORY since before Solaris 11 (which is the
only version Go supports since supported version now), and Illumos
always had it. The only missing piece was O_DIRECTORY flag value, which
is taken from golang.org/x/sys/unix.
Updates #52745.
Change-Id: Ic1111d688eebc8804a87d39d3261c2a6eb33f176
Reviewed-on: https://go-review.googlesource.com/c/go/+/588495
Reviewed-by: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Aleksa Sarai <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>1 parent 3dcb962 commit a3a584e
3 files changed
Lines changed: 16 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 77 | + | |
93 | 78 | | |
94 | 79 | | |
95 | 80 | | |
| |||
98 | 83 | | |
99 | 84 | | |
100 | 85 | | |
101 | | - | |
| 86 | + | |
102 | 87 | | |
103 | 88 | | |
104 | 89 | | |
105 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
106 | 95 | | |
107 | 96 | | |
108 | 97 | | |
| |||
168 | 157 | | |
169 | 158 | | |
170 | 159 | | |
171 | | - | |
172 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
173 | 165 | | |
174 | 166 | | |
175 | 167 | | |
176 | | - | |
| 168 | + | |
177 | 169 | | |
178 | 170 | | |
179 | 171 | | |
180 | | - | |
| 172 | + | |
181 | 173 | | |
182 | 174 | | |
183 | 175 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments