diff options
author | Dave Chapman <dave@dchapman.com> | 2007-09-01 22:55:37 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-09-01 22:55:37 +0000 |
commit | f225f04d003167dad499e093c6de6cbd186d6b50 (patch) | |
tree | 5b9990f5c41ded4a55921aea103b6c088725ad18 /rbutil/ipodpatcher/ipodio-posix.c | |
parent | aea7790a312fcf494d017ab0dde15c719f229bd6 (diff) | |
download | rockbox-f225f04d003167dad499e093c6de6cbd186d6b50.tar.gz rockbox-f225f04d003167dad499e093c6de6cbd186d6b50.zip |
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
Diffstat (limited to 'rbutil/ipodpatcher/ipodio-posix.c')
-rw-r--r-- | rbutil/ipodpatcher/ipodio-posix.c | 24 |
1 files changed, 24 insertions, 0 deletions
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) | |||
76 | #error No sector-size detection implemented for this platform | 76 | #error No sector-size detection implemented for this platform |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #if defined(__APPLE__) && defined(__MACH__) | ||
80 | static int ipod_unmount(struct ipod_t* ipod) | ||
81 | { | ||
82 | char cmd[4096]; | ||
83 | int res; | ||
84 | |||
85 | sprintf(cmd, "/usr/sbin/diskutil unmount \"%ss2\"",ipod->diskname); | ||
86 | fprintf(stderr,"[INFO] "); | ||
87 | res = system(cmd); | ||
88 | |||
89 | if (res==0) { | ||
90 | return 0; | ||
91 | } else { | ||
92 | perror("Unmount failed"); | ||
93 | return -1; | ||
94 | } | ||
95 | } | ||
96 | #endif | ||
97 | |||
79 | void print_error(char* msg) | 98 | void print_error(char* msg) |
80 | { | 99 | { |
81 | perror(msg); | 100 | perror(msg); |
@@ -107,6 +126,11 @@ int ipod_open(struct ipod_t* ipod, int silent) | |||
107 | 126 | ||
108 | int ipod_reopen_rw(struct ipod_t* ipod) | 127 | int ipod_reopen_rw(struct ipod_t* ipod) |
109 | { | 128 | { |
129 | #if defined(__APPLE__) && defined(__MACH__) | ||
130 | if (ipod_unmount(ipod) < 0) | ||
131 | return -1; | ||
132 | #endif | ||
133 | |||
110 | close(ipod->dh); | 134 | close(ipod->dh); |
111 | ipod->dh=open(ipod->diskname,O_RDWR); | 135 | ipod->dh=open(ipod->diskname,O_RDWR); |
112 | if (ipod->dh < 0) { | 136 | if (ipod->dh < 0) { |