Index: ipodio-posix.c
===================================================================
RCS file: /cvsroot/rockbox/tools/ipodpatcher/ipodio-posix.c,v
retrieving revision 1.1
diff -u -r1.1 ipodio-posix.c
--- ipodio-posix.c	13 Dec 2006 09:02:18 -0000	1.1
+++ ipodio-posix.c	13 Dec 2006 18:15:08 -0000
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
 
 #include "ipodio.h"
 
@@ -41,8 +43,22 @@
     }
 
     /* TODO: Detect sector size */
+#if defined(linux) || defined (__linux)
+    if(ioctl(*dh,BLKSSZGET,sector_size) < 0) {
+        fprintf(stderr,"[ERR] ioctl() call to get sector size failed\n");
+    }
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \
+   || defined(__bsdi__) || defined(__DragonFly__)
+    if(ioctl(*dh,DIOCGSECTORSIZE,sector_size) < 0) {
+        fprintf(stderr,"[ERR] ioctl() call to get sector size failed\n)");
+    }
+#elif defined(__APPLE__&__MACH__)
+    if(ioctl(*dh,DKIOCGETBLOCKSIZE,sector_size) < 0) {
+        fprintf(stderr,"[ERR] ioctl() call to get sector size failed\n)");
+    }
+#else
     *sector_size = 512;
-
+#endif
     return 0;
 }
 
