Bug 37834

Summary: GetFileAttributes does not return FileAttributes.ReadOnly for locked file on OSX
Product: [Mono] Runtime Reporter: Lukasz <lukasz>
Component: io-layerAssignee: Andi McClure <andi.mcclure>
Severity: normal CC: andi.mcclure, mono-bugs+mono, mono-bugs+runtime
Priority: ---    
Version: 4.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

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