Commit 8dc8a893 authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov

ioping: fix OpenBSD port

This fixes segmentation faults in and correct labels for partition types and
mount point names. Patch from farhaven@googlemail.com, issue #14
Signed-off-by: default avatarKonstantin Khlebnikov <koct9i@gmail.com>
parent 653b12ba
...@@ -67,6 +67,8 @@ ...@@ -67,6 +67,8 @@
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include <sys/disklabel.h> # include <sys/disklabel.h>
# include <sys/dkio.h> # include <sys/dkio.h>
# include <sys/param.h>
# include <sys/mount.h>
# define HAVE_POSIX_MEMALIGN # define HAVE_POSIX_MEMALIGN
# define HAVE_ERR_INCLUDE # define HAVE_ERR_INCLUDE
#endif #endif
...@@ -524,7 +526,8 @@ out: ...@@ -524,7 +526,8 @@ out:
fclose(file); fclose(file);
} }
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #elif defined(__APPLE__) || defined(__OpenBSD__) \
|| defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
void parse_device(dev_t dev) void parse_device(dev_t dev)
{ {
...@@ -572,9 +575,13 @@ off_t get_device_size(int fd, struct stat *st) ...@@ -572,9 +575,13 @@ off_t get_device_size(int fd, struct stat *st)
ret = ioctl(fd, DIOCGPART, &pinfo); ret = ioctl(fd, DIOCGPART, &pinfo);
blksize = pinfo.media_size; blksize = pinfo.media_size;
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__)
struct partinfo pinfo; struct disklabel label;
ret = ioctl(fd, DIOCGPART, &pinfo); struct partition part;
blksize = DL_GETPSIZE(pinfo.part) * pinfo.disklab->d_secsize;
ret = ioctl(fd, DIOCGDINFO, &label);
part = label.d_partitions[DISKPART(st->st_rdev)];
blksize = DL_GETPSIZE(&part) * label.d_secsize;
#else #else
# error no get disk size method # error no get disk size method
#endif #endif
......
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