Add generic bdev_size function
[fio.git] / os / os.h
diff --git a/os/os.h b/os/os.h
index 10e796fbcbe3313d1faee845bc26d751645aa011..1afb4b227521e3846b087d401b7297201d45cbbb 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -106,4 +106,17 @@ static inline int os_cache_line_size(void)
 #endif
 }
 
+#ifdef FIO_USE_GENERIC_BDEV_SIZE
+static inline int blockdev_size(int fd, unsigned long long *bytes)
+{
+       off_t end = lseek(fd, 0, SEEK_END);
+
+       if (end < 0)
+               return errno;
+
+       *bytes = end;
+       return 0;
+}
+#endif
+
 #endif