From bcb081f0fe0c60febc5899df6f66c40d77a6bfca Mon Sep 17 00:00:00 2001 From: threedeyes <3dEyes@gmail.com> Date: Tue, 13 Nov 2012 04:53:51 +0000 Subject: [PATCH] NTFS: Fixed an issue with seek and read calls Use B_GET_PARTITION_INFO and B_GET_GEOMETRY instead of libntfs' home-brewn device size detection. This avoids KDL in AHCI module. By the way the mentioned problem with seek a should be investigated separately - it looks like a bug in AHCI module. --- .../kernel/file_systems/ntfs/libntfs/device.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c b/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c index 274abacb42..ef7070bd15 100644 --- a/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c +++ b/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c @@ -67,6 +67,9 @@ #ifdef HAVE_LINUX_HDREG_H #include #endif +#ifdef __HAIKU__ +#include +#endif #include "types.h" #include "mst.h" @@ -589,6 +592,24 @@ s64 ntfs_device_size_get(struct ntfs_device *dev, int block_size) return blocks * sector_size / block_size; } } +#endif +#ifdef __HAIKU__ + { + off_t size = 0; + + partition_info partitionInfo; + device_geometry geometry; + + if (dev->d_ops->ioctl(dev, B_GET_PARTITION_INFO, &partitionInfo) == 0) + size = partitionInfo.size; + else if (dev->d_ops->ioctl(dev, B_GET_GEOMETRY, &geometry) == 0) { + size = (off_t)geometry.cylinder_count * geometry.sectors_per_track + * geometry.head_count * geometry.bytes_per_sector; + } + + if (size > 0) + return (s64)size / block_size; + } #endif /* * We couldn't figure it out by using a specialized ioctl,