diff options
author | Dave Chapman <dave@dchapman.com> | 2007-09-02 19:20:59 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-09-02 19:20:59 +0000 |
commit | ad4b8868413a1a9e133dfe651f9074f35c1d7c48 (patch) | |
tree | 1663189a6124dfbe5097594e985cd12672260d46 /rbutil/sansapatcher | |
parent | c5550c96746130a6e2834e8213c3f7c8d21d275c (diff) |
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 sansapatcher version is released.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14585 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/sansapatcher')
-rw-r--r-- | rbutil/sansapatcher/sansaio-posix.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/rbutil/sansapatcher/sansaio-posix.c b/rbutil/sansapatcher/sansaio-posix.c index bf72718d64..22abc883d2 100644 --- a/rbutil/sansapatcher/sansaio-posix.c +++ b/rbutil/sansapatcher/sansaio-posix.c @@ -42,6 +42,26 @@ #include "sansaio.h" +#if defined(__APPLE__) && defined(__MACH__) +static int sansa_unmount(struct sansa_t* sansa) +{ + char cmd[4096]; + int res; + + sprintf(cmd, "/usr/sbin/diskutil unmount \"%ss1\"",sansa->diskname); + fprintf(stderr,"[INFO] "); + res = system(cmd); + + if (res==0) { + return 0; + } else { + perror("Unmount failed"); + return -1; + } +} +#endif + + #ifndef RBUTIL void print_error(char* msg) { @@ -70,6 +90,11 @@ int sansa_open(struct sansa_t* sansa, int silent) int sansa_reopen_rw(struct sansa_t* sansa) { +#if defined(__APPLE__) && defined(__MACH__) + if (sansa_unmount(sansa) < 0) + return -1; +#endif + close(sansa->dh); sansa->dh=open(sansa->diskname,O_RDWR); if (sansa->dh < 0) { |