change os_trim() prototype not to use int fd
[fio.git] / os / os-dragonfly.h
index c799817765675542b01e8bf93ff946c9a9a4729b..423b2369a071bd2de9096178ee2d3c118decabb2 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <sys/endian.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <sys/statvfs.h>
@@ -24,6 +25,7 @@
 #define FIO_HAVE_GETTID
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_IOPRIO
+#define FIO_HAVE_SHM_ATTACH_REMOVED
 
 #define OS_MAP_ANON            MAP_ANON
 
@@ -183,7 +185,7 @@ static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
 
 static inline int blockdev_invalidate_cache(struct fio_file *f)
 {
-       return EINVAL;
+       return ENOTSUP;
 }
 
 static inline unsigned long long os_phys_mem(void)
@@ -214,7 +216,7 @@ static inline unsigned long long get_fs_free_size(const char *path)
        return ret;
 }
 
-static inline int os_trim(int fd, unsigned long long start,
+static inline int os_trim(struct fio_file *f, unsigned long long start,
                          unsigned long long len)
 {
        off_t range[2];
@@ -222,7 +224,7 @@ static inline int os_trim(int fd, unsigned long long start,
        range[0] = start;
        range[1] = len;
 
-       if (!ioctl(fd, IOCTLTRIM, range))
+       if (!ioctl(f->fd, IOCTLTRIM, range))
                return 0;
 
        return errno;
@@ -232,4 +234,15 @@ static inline int os_trim(int fd, unsigned long long start,
 #define FIO_MADV_FREE  MADV_FREE
 #endif
 
+static inline int shm_attach_to_open_removed(void)
+{
+       int x;
+       size_t len = sizeof(x);
+
+       if (sysctlbyname("kern.ipc.shm_allow_removed", &x, &len, NULL, 0) < 0)
+               return 0;
+
+       return x > 0 ? 1 : 0;
+}
+
 #endif