From f225f04d003167dad499e093c6de6cbd186d6b50 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 1 Sep 2007 22:55:37 +0000 Subject: Mac OS X only - automatically unmount the FAT32 partition before attempting to open the disk device for writing. This step can be removed from the manual when the next ipodpatcher version is released. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14569 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/ipodpatcher/ipodio-posix.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'rbutil/ipodpatcher') diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c index 631a3b1b01..55f0187263 100644 --- a/rbutil/ipodpatcher/ipodio-posix.c +++ b/rbutil/ipodpatcher/ipodio-posix.c @@ -76,6 +76,25 @@ static void get_geometry(struct ipod_t* ipod) #error No sector-size detection implemented for this platform #endif +#if defined(__APPLE__) && defined(__MACH__) +static int ipod_unmount(struct ipod_t* ipod) +{ + char cmd[4096]; + int res; + + sprintf(cmd, "/usr/sbin/diskutil unmount \"%ss2\"",ipod->diskname); + fprintf(stderr,"[INFO] "); + res = system(cmd); + + if (res==0) { + return 0; + } else { + perror("Unmount failed"); + return -1; + } +} +#endif + void print_error(char* msg) { perror(msg); @@ -107,6 +126,11 @@ int ipod_open(struct ipod_t* ipod, int silent) int ipod_reopen_rw(struct ipod_t* ipod) { +#if defined(__APPLE__) && defined(__MACH__) + if (ipod_unmount(ipod) < 0) + return -1; +#endif + close(ipod->dh); ipod->dh=open(ipod->diskname,O_RDWR); if (ipod->dh < 0) { -- cgit v1.2.3