int ret;
long size;
unsigned long total_size;
+ unsigned long long bytes;
struct statvfs statBuf;
struct stat stat;
if (S_ISBLK(stat.st_mode)) {
/*Accessing block device directly*/
info->size = 0;
- if (ioctl(fd,BLKGETSIZE,&info->size)!=0) {
- DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
+ if (ioctl(fd,BLKGETSIZE64,&bytes)==0) {
+ info->size = bytes >> SECTOR_SHIFT;
+ } else if (ioctl(fd,BLKGETSIZE,&info->size)!=0) {
+ DPRINTF("ERR: BLKGETSIZE and BLKGETSIZE64 failed, couldn't stat image");
return -EINVAL;
}
{
int ret;
struct stat stat;
- uint64_t sectors;
+ uint64_t sectors, bytes;
uint32_t sector_size;
sectors = 0;
if (S_ISBLK(stat.st_mode)) {
/*Accessing block device directly*/
- if (ioctl(fd, BLKGETSIZE, §ors)) {
- DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
+ if (ioctl(fd,BLKGETSIZE64,&bytes)==0) {
+ sectors = bytes >> SECTOR_SHIFT;
+ } else if (ioctl(fd,BLKGETSIZE,§ors)!=0) {
+ DPRINTF("ERR: BLKGETSIZE and BLKGETSIZE64 failed, couldn't stat image");
return -EINVAL;
}