+static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
+{
+ struct partinfo pi;
+
+ if (!ioctl(f->fd, DIOCGPART, &pi)) {
+ *bytes = (unsigned long long) pi.media_size;
+ return 0;
+ }
+
+ *bytes = 0;
+ return errno;
+}
+
+static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
+{
+ return blockdev_size(f, bytes);
+}
+