Commit 00361768 authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov

ioping: port to Debian GNU/Hurd

Signed-off-by: default avatarKonstantin Khlebnikov <koct9i@gmail.com>
parent e95689f0
...@@ -34,21 +34,27 @@ ...@@ -34,21 +34,27 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mount.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifdef __linux__ #ifdef __linux__
# include <sys/mount.h>
# define HAVE_POSIX_FADVICE # define HAVE_POSIX_FADVICE
# define HAVE_POSIX_MEMALIGN # define HAVE_POSIX_MEMALIGN
# define HAVE_DIRECT_IO # define HAVE_DIRECT_IO
#endif #endif
#ifdef __gnu_hurd__
# define HAVE_POSIX_MEMALIGN
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <sys/mount.h>
# include <sys/disk.h> # include <sys/disk.h>
# define HAVE_NOCACHE_IO # define HAVE_NOCACHE_IO
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
# include <sys/mount.h>
# include <sys/disk.h> # include <sys/disk.h>
# include <sys/uio.h> # include <sys/uio.h>
# define HAVE_NOCACHE_IO # define HAVE_NOCACHE_IO
...@@ -364,10 +370,12 @@ void parse_device(dev_t dev) ...@@ -364,10 +370,12 @@ void parse_device(dev_t dev)
#endif #endif
off_t get_device_size(int fd) off_t get_device_size(int fd, struct stat *st)
{ {
unsigned long long blksize = 0; unsigned long long blksize = 0;
int ret; int ret = 0;
(void)fd;
(void)st;
#if defined(BLKGETSIZE64) #if defined(BLKGETSIZE64)
/* linux */ /* linux */
...@@ -379,6 +387,9 @@ off_t get_device_size(int fd) ...@@ -379,6 +387,9 @@ off_t get_device_size(int fd)
/* macos */ /* macos */
ret = ioctl(fd, DKIOCGETBLOCKCOUNT, &blksize); ret = ioctl(fd, DKIOCGETBLOCKCOUNT, &blksize);
blksize <<= 9; blksize <<= 9;
#elif defined(__gnu_hurd__)
/* hurd */
blksize = st->st_size;
#else #else
# error no get disk size method # error no get disk size method
#endif #endif
...@@ -446,7 +457,7 @@ int main (int argc, char **argv) ...@@ -446,7 +457,7 @@ int main (int argc, char **argv)
if (fd < 0) if (fd < 0)
err(2, "failed to open \"%s\"", path); err(2, "failed to open \"%s\"", path);
st.st_size = get_device_size(fd); st.st_size = get_device_size(fd, &st);
fstype = "block device"; fstype = "block device";
device = malloc(32); device = malloc(32);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment