[mono-android] System.IO.File.GetAttributes returns always ReadOnly

Jonathan Pryor jonp at xamarin.com
Thu Feb 16 19:00:49 UTC 2012


On Feb 16, 2012, at 6:33 AM, tsukrov wrote:
> Samsung Nexus S Android 4.0: Attributes.ReadOnly
> Acer A500 Android 3.2: Attributes.Normal
> HTC Hero Android 2.1: *Attributes.ReadOnly*
> Emul Android 2.3.3: Attributes.ReadOnly
> 
> The files could be written by my app, the app has the write permission.

Apparently using a Xoom as a test device is a bad idea, as /mnt/sdcard is a FUSE mount, not a FAT-formatted device. I should have stuck to the N1, which does have the same ReadOnly behavior. :-/

After further investigation, the problem is:

	https://github.com/mono/mono/blob/master/mono/io-layer/io.c#L269

	if (!(buf->st_mode & S_IWUSR)) {
		attrs = FILE_ATTRIBUTE_READONLY;

Since the file has a mode of 075 (on my N1), the S_WUSR check fails, and thus we consider it readonly...which is _completely_ wrong, as we're not even the same user (files are owned by "system", and we're _not_ "system").

In short, this is a bug:

	https://bugzilla.xamarin.com/show_bug.cgi?id=3501

Sorry,
 - Jon



More information about the Monodroid mailing list