提交 b8c7521c 编写于 作者: R Ryan Lucia 提交者: spatil

[IO] Remove read-only logic in mono_w32_get_disk_free_space (#17177)

This brings us in line with GetDiskFreeSpaceExW on Windows as well as .NET Core.
上级 b14ec964
......@@ -4196,7 +4196,6 @@ mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_byte
#elif defined(HAVE_STATFS)
struct statfs fsstat;
#endif
gboolean isreadonly;
gchar *utf8_path_name;
gint ret;
unsigned long block_size;
......@@ -4223,17 +4222,11 @@ mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_byte
MONO_ENTER_GC_SAFE;
ret = statvfs (utf8_path_name, &fsstat);
MONO_EXIT_GC_SAFE;
isreadonly = ((fsstat.f_flag & ST_RDONLY) == ST_RDONLY);
block_size = fsstat.f_frsize;
#elif defined(HAVE_STATFS)
MONO_ENTER_GC_SAFE;
ret = statfs (utf8_path_name, &fsstat);
MONO_EXIT_GC_SAFE;
#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);
......@@ -4247,13 +4240,9 @@ mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_byte
}
/* total number of free bytes for non-root */
if (free_bytes_avail != NULL) {
if (isreadonly) {
*free_bytes_avail = 0;
}
else {
*free_bytes_avail = block_size * (guint64)fsstat.f_bavail;
}
*free_bytes_avail = block_size * (guint64)fsstat.f_bavail;
}
/* total number of bytes available for non-root */
......@@ -4262,13 +4251,9 @@ mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_byte
}
/* total number of bytes available for root */
if (total_number_of_free_bytes != NULL) {
if (isreadonly) {
*total_number_of_free_bytes = 0;
}
else {
*total_number_of_free_bytes = block_size * (guint64)fsstat.f_bfree;
}
*total_number_of_free_bytes = block_size * (guint64)fsstat.f_bfree;
}
return(TRUE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册