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...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
URL:
Depends on:
Blocks:
 
Reported: 2017-06-20 14:33 UTC by Bernhard Urban
Modified: 2017-06-21 17:51 UTC (History)
3 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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