[runtime] Use getrlimit () to obtain the size of the fd table instead of getdtablesiz...
[mono.git] / mono / io-layer / io.c
old mode 100755 (executable)
new mode 100644 (file)
index b67a9ca..03672d4
@@ -705,7 +705,7 @@ static gboolean file_setendoffile(gpointer handle)
        }
        
 #ifdef FTRUNCATE_DOESNT_EXTEND
-       /* I haven't bothered to write the configure.in stuff for this
+       /* I haven't bothered to write the configure.ac stuff for this
         * because I don't know if any platform needs it.  I'm leaving
         * this code just in case though
         */
@@ -2179,8 +2179,6 @@ gpointer GetStdHandle(WapiStdHandle stdhandle)
 
        handle = GINT_TO_POINTER (fd);
 
-       pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup,
-                             (void *)&stdhandle_mutex);
        thr_ret = mono_mutex_lock (&stdhandle_mutex);
        g_assert (thr_ret == 0);
 
@@ -2202,7 +2200,6 @@ gpointer GetStdHandle(WapiStdHandle stdhandle)
   done:
        thr_ret = mono_mutex_unlock (&stdhandle_mutex);
        g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
        
        return(handle);
 }
@@ -2795,8 +2792,6 @@ gboolean FindNextFile (gpointer handle, WapiFindData *find_data)
                return(FALSE);
        }
 
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
@@ -2906,7 +2901,6 @@ retry:
 cleanup:
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
        
        return(ret);
 }
@@ -2939,8 +2933,6 @@ gboolean FindClose (gpointer handle)
                return(FALSE);
        }
 
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
@@ -2949,7 +2941,6 @@ gboolean FindClose (gpointer handle)
 
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
        
        _wapi_handle_unref (handle);
        
@@ -3247,9 +3238,9 @@ extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs)
         * catch that case here.
         */
        if (attrs & FILE_ATTRIBUTE_READONLY) {
-               result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWRITE | S_IWOTH | S_IWGRP));
+               result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWUSR | S_IWOTH | S_IWGRP));
        } else {
-               result = _wapi_chmod (utf8_name, buf.st_mode | S_IWRITE);
+               result = _wapi_chmod (utf8_name, buf.st_mode | S_IWUSR);
        }
 
        /* Ignore the other attributes for now */
@@ -3792,7 +3783,9 @@ add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
                        ignore_entry = TRUE;
                else
                        ignore_entry = FALSE;
-       } else
+       } else if (state->fstype_index == 3 && memcmp ("nfs", state->fstype, state->fstype_index) == 0)
+               ignore_entry = FALSE;
+       else
                ignore_entry = TRUE;
 
        if (!ignore_entry) {
@@ -3911,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)
@@ -3950,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);
@@ -4267,6 +4264,7 @@ guint32 GetDriveType(const gunichar2 *root_path_name)
        return (drive_type);
 }
 
+#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__)
 static gchar*
 get_fstypename (gchar *utfpath)
 {
@@ -4294,7 +4292,6 @@ get_fstypename (gchar *utfpath)
 }
 
 /* Linux has struct statfs which has a different layout */
-#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__)
 gboolean
 GetVolumeInformation (const gunichar2 *path, gunichar2 *volumename, int volumesize, int *outserial, int *maxcomp, int *fsflags, gunichar2 *fsbuffer, int fsbuffersize)
 {