Bug 57629 - [io-layer] File.Delete () throws System.UnauthorizedAccessException on non-existing files on a read-only path
Summary: [io-layer] File.Delete () throws System.UnauthorizedAccessException on non-ex...
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
Depends on:
Reported: 2017-06-20 14:33 UTC by Bernhard Urban
Modified: 2017-06-21 17:51 UTC (History)
3 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Bernhard Urban 2017-06-20 14:33:31 UTC
this used to be different in 4.8, see: https://gist.github.com/lewurm/f7170d481c1f5f14a0c1294be058020b

this was introduced by https://github.com/mono/mono/commit/c2a7bb4598c3760d439ad00e782ff449a6361c95

it surfaced on android when running the BCL test suite: android mounts the root file system as read-only and also sets CWD=/. In that particular case, it looks like the tests were buggy, but still this is a change in behaviour (see https://github.com/mono/mono/pull/5066 ).
Comment 1 Bernhard Urban 2017-06-20 19:55:38 UTC
some quotes from slack:

akoeplinger: @ludovic @kumpera ok, I confirmed the behavior is sensible on Windows with .net framework: if you set a partition to read-only, deleting a non-existing file doesn't throw. deleting an existing file throws `IOException: The media is write protected.`

akoeplinger: fwiw .NET Core on Linux throws `Unhandled Exception: System.IO.IOException: Read-only file system` when deleting the non-existing file on a RO FS
Comment 2 Alexander Köplinger [MSFT] 2017-06-20 19:58:34 UTC
I filed a bug on the corefx repo for the .NET Core issue: https://github.com/dotnet/corefx/issues/21273
Comment 3 Rodrigo Kumpera 2017-06-20 20:41:50 UTC
Working on it.
Comment 4 Rodrigo Kumpera 2017-06-20 22:02:45 UTC
PR against master: https://github.com/mono/mono/pull/5082
Comment 5 Rodrigo Kumpera 2017-06-21 17:51:41 UTC
Merged on master, PR against 2017-06: https://github.com/mono/mono/pull/5085

Note You need to log in before you can comment on or make changes to this bug.