summaryrefslogtreecommitdiffstats
path: root/tools/ipodpatcher
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-12-13 20:26:44 +0000
committerDave Chapman <dave@dchapman.com>2006-12-13 20:26:44 +0000
commit8280c8c0945a7fe4beb484539c3365d7177ab5e2 (patch)
tree681fb6a4f47fb828121bd7eda3875c2dddf44117 /tools/ipodpatcher
parent1936f7c460acdc4410db94a94ca82937eee2c9d6 (diff)
downloadrockbox-8280c8c0945a7fe4beb484539c3365d7177ab5e2.tar.gz
rockbox-8280c8c0945a7fe4beb484539c3365d7177ab5e2.zip
Sector-size detection on Posix platforms - tested on Linux and Mac OS X. Based on patch #6433 by Bryan Childs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11752 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/ipodpatcher')
-rw-r--r--tools/ipodpatcher/ipodio-posix.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/ipodpatcher/ipodio-posix.c b/tools/ipodpatcher/ipodio-posix.c
index cfded35390..4b55d62629 100644
--- a/tools/ipodpatcher/ipodio-posix.c
+++ b/tools/ipodpatcher/ipodio-posix.c
@@ -24,6 +24,22 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include <sys/disk.h>
+#endif
+
+#if defined(linux) || defined (__linux)
+ #define IPOD_SECTORSIZE_IOCTL BLKSSZGET
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \
+ || defined(__bsdi__) || defined(__DragonFly__)
+ #define IPOD_SECTORSIZE_IOCTL DIOCGSECTORSIZE
+#elif defined(__APPLE__) && defined(__MACH__)
+ #define IPOD_SECTORSIZE_IOCTL DKIOCGETBLOCKSIZE
+#else
+ #error No sector-size detection implemented for this platform
+#endif
#include "ipodio.h"
@@ -40,9 +56,9 @@ int ipod_open(HANDLE* dh, char* diskname, int* sector_size)
return -1;
}
- /* TODO: Detect sector size */
- *sector_size = 512;
-
+ if(ioctl(*dh,IPOD_SECTORSIZE_IOCTL,sector_size) < 0) {
+ fprintf(stderr,"[ERR] ioctl() call to get sector size failed\n");
+ }
return 0;
}