summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbutil/sansapatcher/sansaio-posix.c25
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 @@
42 42
43#include "sansaio.h" 43#include "sansaio.h"
44 44
45#if defined(__APPLE__) && defined(__MACH__)
46static int sansa_unmount(struct sansa_t* sansa)
47{
48 char cmd[4096];
49 int res;
50
51 sprintf(cmd, "/usr/sbin/diskutil unmount \"%ss1\"",sansa->diskname);
52 fprintf(stderr,"[INFO] ");
53 res = system(cmd);
54
55 if (res==0) {
56 return 0;
57 } else {
58 perror("Unmount failed");
59 return -1;
60 }
61}
62#endif
63
64
45#ifndef RBUTIL 65#ifndef RBUTIL
46void print_error(char* msg) 66void print_error(char* msg)
47{ 67{
@@ -70,6 +90,11 @@ int sansa_open(struct sansa_t* sansa, int silent)
70 90
71int sansa_reopen_rw(struct sansa_t* sansa) 91int sansa_reopen_rw(struct sansa_t* sansa)
72{ 92{
93#if defined(__APPLE__) && defined(__MACH__)
94 if (sansa_unmount(sansa) < 0)
95 return -1;
96#endif
97
73 close(sansa->dh); 98 close(sansa->dh);
74 sansa->dh=open(sansa->diskname,O_RDWR); 99 sansa->dh=open(sansa->diskname,O_RDWR);
75 if (sansa->dh < 0) { 100 if (sansa->dh < 0) {