HP-UX disk query size
[fio.git] / os / os-hpux.h
index 38a1441db292627379ab2f301daea5979e92e27c..1b1c95896eec5431584fb89e4ee6b35308ea8da9 100644 (file)
@@ -8,7 +8,9 @@
 #include <sys/fadvise.h>
 #include <sys/mman.h>
 #include <sys/mpctl.h>
-#include <sys/scsi.h>
+#include <sys/diskio.h>
+#include <sys/param.h>
+#include <sys/pstat.h>
 #include <time.h>
 #include <aio.h>
 
@@ -20,6 +22,7 @@
 #define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_HAVE_PSHARED_MUTEX
 #define FIO_HAVE_FADVISE
+#define FIO_HAVE_CHARDEV_SIZE
 
 #define OS_MAP_ANON            MAP_ANONYMOUS
 #define OS_MSG_DONTWAIT                0
@@ -44,10 +47,13 @@ static inline int blockdev_invalidate_cache(struct fio_file *f)
 
 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
 {
-       struct capacity cap;
+       disk_describe_type_ext_t dext;
 
-       if (!ioctl(f->fd, SIOC_CAPACITY, &cap) == -1) {
-               *bytes = cap.lba * cap.blksz;
+       if (!ioctl(f->fd, DIOC_DESCRIBE_EXT, &dext)) {
+               unsigned long long lba;
+
+               lba = ((uint64_t) dext.maxsva_high << 32) | dext.maxsva_low;
+               *bytes = lba * dext.lgblksz;
                return 0;
        }
 
@@ -55,18 +61,24 @@ static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
        return errno;
 }
 
+static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
+{
+       return blockdev_size(f, bytes);
+}
+
 static inline unsigned long long os_phys_mem(void)
 {
-#if 0
-       long mem = sysconf(_SC_AIX_REALMEM);
+       unsigned long long ret;
+       struct pst_static pst;
+       union pstun pu;
 
-       if (mem == -1)
+       pu.pst_static = &pst;
+       if (pstat(PSTAT_STATIC, pu, sizeof(pst), 0, 0) == -1)
                return 0;
 
-       return (unsigned long long) mem * 1024;
-#else
-       return 0;
-#endif
+       ret = pst.physical_memory;
+       ret *= pst.page_size;
+       return ret;
 }
 
 #define FIO_HAVE_CPU_ONLINE_SYSCONF