]> Cypherpunks repositories - gostls13.git/commit
os: fix RemoveAll on large directories on Plan 9 and NaCl
authorDavid du Colombier <0intro@gmail.com>
Mon, 6 Nov 2017 06:35:42 +0000 (07:35 +0100)
committerDavid du Colombier <0intro@gmail.com>
Mon, 6 Nov 2017 07:09:50 +0000 (07:09 +0000)
commit32f994acc621fdc47f215d8f4e1d89561345bcc7
tree58a5a770f86a18cd473569cd3f04ab2ab9d9789a
parent03ed6ac2dc62d160ea8be18927433380483c055c
os: fix RemoveAll on large directories on Plan 9 and NaCl

On Plan 9, some file servers, like ramfs, handle the read
offset when reading directories. However, the offset isn't
valid anymore after directory entries have been removed
between successive calls to read.

This issue happens when os.RemoveAll is called on a
directory that doesn't fit on a single 9P response message.

In this case, the first part of the directory is read,
then directory entries are removed and the second read
will be incomplete because the read offset won't be valid
anymore. Consequently, the content of the directory will
only be partially removed.

We change RemoveAll to call fd.Seek(0, 0) before calling
fd.Readdirnames, so the read offset will always be reset
after removing the directory entries.

After adding TestRemoveAllLarge, we noticed the same issue
appears on NaCl and the same fix applies as well.

Fixes #22572.

Change-Id: Ifc76ea7ccaf0168c34dc8ec0f400dc04db1baf8f
Reviewed-on: https://go-review.googlesource.com/75974
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/os/path.go
src/os/path_test.go