diff options
-rw-r--r-- | docs/CREDITS | 2 | ||||
-rw-r--r-- | tools/ipodpatcher/ipodio-posix.c | 22 |
2 files changed, 20 insertions, 4 deletions
diff --git a/docs/CREDITS b/docs/CREDITS index 5a30adce6a..d2f30058a4 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -254,4 +254,4 @@ Will Robertson Stephane Doyon Robert Carboneau Ye Wei - +Bryan Childs 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; } |