#include <errno.h>
#include <sys/sysctl.h>
+#include <sys/disk.h>
+
+#include "../file.h"
#define FIO_HAVE_POSIXAIO
#define FIO_HAVE_ODIRECT
+#define FIO_HAVE_STRSEP
+#define FIO_USE_GENERIC_RAND
+#define FIO_HAVE_CHARDEV_SIZE
+#define FIO_HAVE_CLOCK_MONOTONIC
#define OS_MAP_ANON MAP_ANON
-typedef unsigned long os_cpu_mask_t;
-typedef unsigned int os_random_state_t;
+typedef off_t off64_t;
-/*
- * FIXME
- */
-static inline int blockdev_size(int fd, unsigned long long *bytes)
+static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
{
- off_t end = lseek(fd, 0, SEEK_END);
+ off_t size;
+
+ if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
+ *bytes = size;
+ return 0;
+ }
- if (end < 0)
- return errno;
+ *bytes = 0;
+ return errno;
+}
- *bytes = end;
- return 0;
+static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
+{
+ return blockdev_size(f, bytes);
}
-static inline int blockdev_invalidate_cache(int fd)
+static inline int blockdev_invalidate_cache(struct fio_file *f)
{
return EINVAL;
}
return mem;
}
-static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
-{
- srand(seed);
-}
-
-static inline long os_random_long(os_random_state_t *rs)
-{
- long val;
-
- val = rand_r(rs);
- return val;
-}
+#ifdef MADV_FREE
+#define FIO_MADV_FREE MADV_FREE
+#endif
#endif