Bug 37834 - GetFileAttributes does not return FileAttributes.ReadOnly for locked file on OSX
Summary: GetFileAttributes does not return FileAttributes.ReadOnly for locked file on OSX
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: 4.0.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Andi McClure
URL:
Depends on:
Blocks:
 
Reported: 2016-01-20 13:02 UTC by Lukasz
Modified: 2016-02-09 15: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 Lukasz 2016-01-20 13:02:24 UTC
Right click a file in OSX and select "Get info" and enable the "Locked" checkbox. Then call File.GetFileAttributes() on the file, it does not set the flag FileAttributes.ReadOnly.

This results in Xamarin Studio not providing any error when saving changes to a locked file and it looks like it was able to save the file, when it was in fact not.
Comment 1 Andi McClure 2016-02-08 18:39:28 UTC
GetFileAttributes drills down to is_file_writable in io.c in the iolayer. The comment explains this function "assume(s) that basic unix permission bits are authoritative. Which might not be the case under systems with extended permissions systems". "Locked" status on OS X refers to fs flag "uchg" (visible with ls -lO) and the way to check it in is_file_writable would be to check (struct stat)->st_flags for the (SF_IMMUTABLE|UF_IMMUTABLE) flags (see `man 2 chflags` or fflagstostr).
Comment 2 Andi McClure 2016-02-08 20:07:36 UTC
Fix in PR review https://github.com/mono/mono/pull/2577