[Stgt-devel] [PATCH] fix no blkgetsize64

Pete Wyckoff pw
Mon Jul 30 19:30:06 CEST 2007


Fix build for old machines that do not have 64-bit BLKGETSIZE.

Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
 usr/util.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/usr/util.c b/usr/util.c
index 9f54820..54bf399 100644
--- a/usr/util.c
+++ b/usr/util.c
@@ -101,11 +101,21 @@ int backed_file_open(char *path, int oflag, uint64_t *size)
 	if (S_ISREG(st.st_mode))
 		*size = st.st_size;
 	else if (S_ISBLK(st.st_mode)) {
+#ifdef BLKGETSIZE64
 		err = ioctl(fd, BLKGETSIZE64, size);
 		if (err < 0) {
 			eprintf("Cannot get size, %m\n");
 			goto close_fd;
 		}
+#else
+		unsigned long usize;
+		err = ioctl(fd, BLKGETSIZE, &usize);
+		if (err < 0) {
+			eprintf("Cannot get size (ulong), %m\n");
+			goto close_fd;
+		}
+		*size = usize;
+#endif
 	} else {
 		eprintf("Cannot use this mode %x\n", st.st_mode);
 		err = -EINVAL;
-- 
1.5.2.4




More information about the stgt mailing list