View | Details | Raw Unified | Return to bug 256198
Collapse All | Expand All

(-)sysutils/fusefs-ntfs/files/patch-libntfs-3g__device.c (-56 lines)
Removed Link Here
1
--- ./libntfs-3g/device.c.orig	Tue Jan  9 18:22:57 2007
2
+++ ./libntfs-3g/device.c	Mon Apr 30 13:40:54 2007
3
@@ -63,6 +63,9 @@
4
 #ifdef HAVE_LINUX_HDREG_H
5
 #include <linux/hdreg.h>
6
 #endif
7
+#ifdef __FreeBSD__
8
+#include <sys/disk.h>
9
+#endif
10
 
11
 #include "types.h"
12
 #include "mst.h"
13
@@ -533,6 +536,17 @@
14
 		}
15
 	}
16
 #endif
17
+#ifdef DIOCGMEDIASIZE 
18
+	{       off_t size;
19
+
20
+		if (dev->d_ops->ioctl(dev, DIOCGMEDIASIZE, &size) >= 0) {
21
+			ntfs_log_debug("DIOCGMEDIASIZE nr bytes = %llu (0x%llx)\n",
22
+					(unsigned long long)size,
23
+					(unsigned long long)size);
24
+			return (s64)size / block_size;
25
+		}
26
+	}
27
+#endif
28
 	/*
29
 	 * We couldn't figure it out by using a specialized ioctl,
30
 	 * so do binary search to find the size of the device.
31
@@ -681,7 +695,24 @@
32
 			return sect_size;
33
 		}
34
 	}
35
-#else
36
+#elif defined(DIOCGSECTORSIZE)
37
+	/*
38
+	 * XXX On FreeBSD (where we have DIOCGSECTORSIZE) the low-level I/O
39
+	 * system already knows the sector size, and doing an ioctl is needless.
40
+	 * However, I don't know how to extract that information cleanly,
41
+	 * without letting a bunch of platform specific #ifdef-s to sneak in.
42
+	 * So now I rather just re-do the ioctl...
43
+	 */
44
+	{
45
+		size_t sect_size = 0;
46
+
47
+		if (!dev->d_ops->ioctl(dev, DIOCGSECTORSIZE, &sect_size)) {
48
+			ntfs_log_debug("DIOCGSECTORSIZE sector size = %d bytes\n",
49
+				(int)sect_size);
50
+			return sect_size;
51
+		}
52
+	}
53
+#else
54
 	errno = EOPNOTSUPP;
55
 #endif
56
 	return -1;

Return to bug 256198