Fix bug with probing block size
[fio.git] / os / os-freebsd.h
CommitLineData
ebac4655
JA
1#ifndef FIO_OS_FREEBSD_H
2#define FIO_OS_FREEBSD_H
3
690dec6e 4#include <errno.h>
5c4e1dbc 5#include <sys/sysctl.h>
aa5e69b2 6#include <sys/disk.h>
5c4e1dbc 7
ebac4655 8#define FIO_HAVE_POSIXAIO
2c0ecd28 9#define FIO_HAVE_ODIRECT
53531370 10#define FIO_USE_GENERIC_RAND
4ccdccd1 11#define FIO_HAVE_CHARDEV_SIZE
ebac4655 12
dc873b6f 13#define OS_MAP_ANON MAP_ANON
ebac4655 14
907249cf
JA
15typedef off_t off64_t;
16
aa5e69b2
JA
17static inline int blockdev_size(int fd, unsigned long long *bytes)
18{
19 off_t size;
20
21 if (!ioctl(fd, DIOCGMEDIASIZE, &size)) {
22 *bytes = size;
23 return 0;
24 }
25
2fa55e93 26 *bytes = 0;
aa5e69b2
JA
27 return errno;
28}
29
4ccdccd1
JA
30static inline int chardev_size(int fd, unsigned long long *bytes)
31{
32 return blockdev_size(fd, bytes);
33}
34
e5b401d4
JA
35static inline int blockdev_invalidate_cache(int fd)
36{
37 return EINVAL;
ebac4655
JA
38}
39
32cd46a0
JA
40static inline unsigned long long os_phys_mem(void)
41{
42 int mib[2] = { CTL_HW, HW_PHYSMEM };
43 unsigned long long mem;
44 size_t len = sizeof(mem);
45
46 sysctl(mib, 2, &mem, &len, NULL, 0);
47 return mem;
48}
49
a1c58075
JA
50#ifdef MADV_FREE
51#define FIO_MADV_FREE MADV_FREE
52#endif
53
ebac4655 54#endif