From 58d3fbac583c66a302edbf6f02268ec518ac6cae Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Thu, 28 Feb 2002 23:28:05 +0000 Subject: [PATCH] Document BLKGETSIZE64->BLKGETSIZE fallback --- doc/CHANGES | 3 +++ libxfs/init.c | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) 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); -- 2.47.2