SWDEV-232464 - Use Fstat to retrieve file size.

Change-Id: I4051645cd322c2afaf89e014452657db1a1fdc2c


[ROCm/clr commit: c97ef9f84a]
Šī revīzija ir iekļauta:
kjayapra-amd
2020-05-12 08:52:49 -04:00
revīziju iesūtīja Karthik Jayaprakash
vecāks 76fff418bf
revīzija 08036e1ffe
Parasts fails → Izpildāmais fails
+9 -12
Parādīt failu
@@ -720,24 +720,21 @@ bool Os::MemoryMapFile(const char* fname, const void** mmap_ptr, size_t* mmap_si
return false;
}
FILE* fp = fopen(fname, "r");
if (fp == nullptr) {
return false;
}
int fd = fileno(fp);
struct stat stat_buf;
int fd = open(fname, O_RDONLY);
if (fd < 0 ) {
fclose(fp);
return false;
}
fseek(fp, 0L, SEEK_END);
*mmap_size = ftell(fp);
fseek(fp, 0L, SEEK_SET);
if(fstat(fd, &stat_buf) != 0) {
close(fd);
return false;
}
*mmap_ptr = mmap(NULL, *mmap_size, PROT_READ, MAP_SHARED, fd, 0);
*mmap_size = stat_buf.st_size;
*mmap_ptr = mmap(NULL, stat_buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
fclose(fp);
close(fd);
if (*mmap_ptr == nullptr) {
return false;