Use LOOP_GET_STATUS64 for checking loop devices

To determine whether a loop device was available, we use an ioctl call
to LOOP_GET_STATUS, but this fails on devices with large storage
partitions with errno = EOVERFLOW. Instead use LOOP_GET_STATUS64 which
succeeds.

Bug: 3412121
Change-Id: Ica3cb48885d3555f2d27073c00e31fc51a08c730
This commit is contained in:
Kenny Root 2011-02-01 15:58:25 -08:00
parent d33d417e3a
commit 7c16502dbc

View file

@ -128,7 +128,7 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
char filename[256]; char filename[256];
for (i = 0; i < LOOP_MAX; i++) { for (i = 0; i < LOOP_MAX; i++) {
struct loop_info li; struct loop_info64 li;
int rc; int rc;
sprintf(filename, "/dev/block/loop%d", i); sprintf(filename, "/dev/block/loop%d", i);
@ -151,7 +151,7 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
return -1; return -1;
} }
rc = ioctl(fd, LOOP_GET_STATUS, &li); rc = ioctl(fd, LOOP_GET_STATUS64, &li);
if (rc < 0 && errno == ENXIO) if (rc < 0 && errno == ENXIO)
break; break;