Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions mono/io-layer/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <fnmatch.h>
#include <stdio.h>
#include <utime.h>
#ifdef __linux__
#include <sys/ioctl.h>
#include <linux/fs.h>
#endif

#include <mono/io-layer/wapi.h>
#include <mono/io-layer/wapi-private.h>
Expand Down Expand Up @@ -798,6 +802,34 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
return(INVALID_FILE_SIZE);
}

/* fstat indicates block devices as zero-length, so go a different path */
#ifdef BLKGETSIZE64
if (S_ISBLK(statbuf.st_mode)) {
guint64 bigsize;
if (ioctl(fd, BLKGETSIZE64, &bigsize) < 0) {
#ifdef DEBUG
g_message ("%s: handle %p ioctl BLKGETSIZE64 failed: %s",
__func__, handle, strerror(errno));
#endif

_wapi_set_last_error_from_errno ();
return(INVALID_FILE_SIZE);
}

size = bigsize & 0xFFFFFFFF;
if (highsize != NULL) {
*highsize = bigsize>>32;
}

#ifdef DEBUG
g_message ("%s: Returning block device size %d/%d",
__func__, size, *highsize);
#endif

return(size);
}
#endif

#ifdef HAVE_LARGE_FILE_SUPPORT
size = statbuf.st_size & 0xFFFFFFFF;
if (highsize != NULL) {
Expand Down