From: Eric Sandeen Date: Thu, 28 Feb 2002 23:28:05 +0000 (+0000) Subject: Document BLKGETSIZE64->BLKGETSIZE fallback X-Git-Tag: v2.1.0~56 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58d3fbac583c66a302edbf6f02268ec518ac6cae;p=thirdparty%2Fxfsprogs-dev.git Document BLKGETSIZE64->BLKGETSIZE fallback --- diff --git a/doc/CHANGES b/doc/CHANGES index 200f4795a..6f563171e 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,6 @@ +cvs + - Fall back to BLKGETSIZE if BLKGETSIZE64 fails + xfsprogs-2.0.0 (26 February 2002) - Major release to coincide with switch to new extended attributes system call interfaces diff --git a/libxfs/init.c b/libxfs/init.c index 0a388d82b..bf3e0a455 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -156,11 +156,19 @@ findsize(char *path) exit(1); } error = ioctl(fd, BLKGETSIZE64, &size); - /* BLKGETSIZE64 returns size in bytes */ - size = size >> 9; - if (error < 0) { - fprintf(stderr, "%s: can't determine device size\n", progname); - exit(1); + if (error >= 0) { + /* BLKGETSIZE64 returns size in bytes not 512-byte blocks */ + size = size >> 9; + } else { + /* If BLKGETSIZE64 fails, try BLKGETSIZE */ + unsigned long tmpsize; + error = ioctl(fd, BLKGETSIZE, &tmpsize); + if (error < 0) { + fprintf(stderr, "%s: can't determine device size\n", + progname); + exit(1); + } + size = (__uint64_t)tmpsize; } close(fd);