From: Jonathan Pryor Date: Wed, 17 Sep 2014 16:56:44 +0000 (-0400) Subject: [runtime] Use statfs(2) on Android. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=818b81ef40c7a216f0178124969a5b8e8a866dd0;p=mono.git [runtime] Use statfs(2) on Android. Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=23077 Reverts commit 53ce92470. Commit 53ce92470 disabled use of statfs(2) on Android, for unspecified reasons. (My *suspicion* is that the Android version mono was originally ported to didn't have statfs(2), but I can neither confirm nor deny that guess.) Android has supported statfs(2) since API-4 Android v1.6 (in that statfs(2) is in the header files); what's missing is MNT_RDONLY. What IS present is MS_RDONLY, which appears to serve the same purpose. Re-enable use of statfs(2) and use MS_RDONLY when building against the Android NDK. --- diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c index 169cb07617a..03672d4197e 100644 --- a/mono/io-layer/io.c +++ b/mono/io-layer/io.c @@ -3904,7 +3904,7 @@ GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf) } #endif -#if (defined(HAVE_STATVFS) || defined(HAVE_STATFS)) && !defined(PLATFORM_ANDROID) +#if defined(HAVE_STATVFS) || defined(HAVE_STATFS) gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail, WapiULargeInteger *total_number_of_bytes, WapiULargeInteger *total_number_of_free_bytes) @@ -3943,7 +3943,11 @@ gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_ block_size = fsstat.f_frsize; #elif defined(HAVE_STATFS) ret = statfs (utf8_path_name, &fsstat); +#if defined (MNT_RDONLY) isreadonly = ((fsstat.f_flags & MNT_RDONLY) == MNT_RDONLY); +#elif defined (MS_RDONLY) + isreadonly = ((fsstat.f_flags & MS_RDONLY) == MS_RDONLY); +#endif block_size = fsstat.f_bsize; #endif } while(ret == -1 && errno == EINTR);