Enable FIO_HAVE_CHARDEV_SIZE on DragonFlyBSD
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 11 Jun 2015 11:24:11 +0000 (20:24 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Fri, 12 Jun 2015 14:16:26 +0000 (23:16 +0900)
commit1116dc04bec6df8f0857fceaf1cbf9032644e643
tree0d0a86f20e940b9eca4c9ec6b0615fa6f9479060
parentc08ad04c17e63c275ff477b21460ed6fa3b493f9
Enable FIO_HAVE_CHARDEV_SIZE on DragonFlyBSD

DragonFlyBSD no longer has block device just like FreeBSD got rid of
it at some point. Enable FIO_HAVE_CHARDEV_SIZE and implement get-size
functions with DragonFlyBSD's ioctl so fio can retrieve correct size
when targets are not regular files.

The following result verifies that df(1) shows the same fs size as
chardev_size() with regards to the character device (block device if
it were on Linux).

--
 # uname
 DragonFly
 # cat ./test3.c
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include "os/os-dragonfly.h"

 int main(int argc, char *argv[]) {
         struct fio_file f;
         unsigned long long bytes;

         f.fd = open(argv[1], O_RDONLY);
         if (f.fd < 0) {
                 perror("open");
                 exit(1);
         }

         if (chardev_size(&f, &bytes)) {
                 perror("ioctl");
                 exit(1);
         }
         printf("%s %llu\n", argv[1], bytes);
         close(f.fd);
         return 0;
 }
 # gcc -Wall -g ./test3.c -o test3
 # file /dev/da8
 /dev/da8: character special (30/504430663)
 # ./test3 /dev/da8
 /dev/da8 31004295168
 # newfs /dev/da8 > /dev/null
 # mount -t ufs /dev/da8 /mnt
 # df -TH /mnt
 Filesystem  Type   Size   Used  Avail Capacity  Mounted on
 /dev/da8    ufs     31G   2.0k    28G     0%    /mnt
os/os-dragonfly.h