diff options
Diffstat (limited to 'rbutil/ipodpatcher')
-rw-r--r-- | rbutil/ipodpatcher/ipodio-posix.c | 4 | ||||
-rw-r--r-- | rbutil/ipodpatcher/ipodio-win32.c | 5 | ||||
-rw-r--r-- | rbutil/ipodpatcher/ipodpatcher.c | 19 |
3 files changed, 24 insertions, 4 deletions
diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c index 55f0187263..c62e0c8275 100644 --- a/rbutil/ipodpatcher/ipodio-posix.c +++ b/rbutil/ipodpatcher/ipodio-posix.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | #include <sys/stat.h> | 26 | #include <sys/stat.h> |
27 | #include <sys/ioctl.h> | 27 | #include <sys/ioctl.h> |
28 | #include <errno.h> | ||
28 | 29 | ||
29 | #include "ipodio.h" | 30 | #include "ipodio.h" |
30 | 31 | ||
@@ -105,7 +106,8 @@ int ipod_open(struct ipod_t* ipod, int silent) | |||
105 | ipod->dh=open(ipod->diskname,O_RDONLY); | 106 | ipod->dh=open(ipod->diskname,O_RDONLY); |
106 | if (ipod->dh < 0) { | 107 | if (ipod->dh < 0) { |
107 | if (!silent) perror(ipod->diskname); | 108 | if (!silent) perror(ipod->diskname); |
108 | return -1; | 109 | if(errno == EACCES) return -2; |
110 | else return -1; | ||
109 | } | 111 | } |
110 | 112 | ||
111 | /* Read information about the disk */ | 113 | /* Read information about the disk */ |
diff --git a/rbutil/ipodpatcher/ipodio-win32.c b/rbutil/ipodpatcher/ipodio-win32.c index 2f75153c3a..985ec4ec4b 100644 --- a/rbutil/ipodpatcher/ipodio-win32.c +++ b/rbutil/ipodpatcher/ipodio-win32.c | |||
@@ -78,7 +78,10 @@ int ipod_open(struct ipod_t* ipod, int silent) | |||
78 | 78 | ||
79 | if (ipod->dh == INVALID_HANDLE_VALUE) { | 79 | if (ipod->dh == INVALID_HANDLE_VALUE) { |
80 | if (!silent) print_error(" Error opening disk: "); | 80 | if (!silent) print_error(" Error opening disk: "); |
81 | return -1; | 81 | if(GetLastError() == ERROR_ACCESS_DENIED) |
82 | return -2; | ||
83 | else | ||
84 | return -1; | ||
82 | } | 85 | } |
83 | 86 | ||
84 | if (!lock_volume(ipod->dh)) { | 87 | if (!lock_volume(ipod->dh)) { |
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c index 08ba9263d2..d9048f24cc 100644 --- a/rbutil/ipodpatcher/ipodpatcher.c +++ b/rbutil/ipodpatcher/ipodpatcher.c | |||
@@ -1260,12 +1260,16 @@ int getmodel(struct ipod_t* ipod, int ipod_version) | |||
1260 | return 0; | 1260 | return 0; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | /* returns number of found ipods or -1 if no ipods found and permission | ||
1264 | * for raw disc access was denied. */ | ||
1263 | int ipod_scan(struct ipod_t* ipod) | 1265 | int ipod_scan(struct ipod_t* ipod) |
1264 | { | 1266 | { |
1265 | int i; | 1267 | int i; |
1266 | int n = 0; | 1268 | int n = 0; |
1267 | int ipod_version; | 1269 | int ipod_version; |
1268 | char last_ipod[4096]; | 1270 | char last_ipod[4096]; |
1271 | int denied = 0; | ||
1272 | int result; | ||
1269 | 1273 | ||
1270 | printf("[INFO] Scanning disk devices...\n"); | 1274 | printf("[INFO] Scanning disk devices...\n"); |
1271 | 1275 | ||
@@ -1282,7 +1286,10 @@ int ipod_scan(struct ipod_t* ipod) | |||
1282 | #else | 1286 | #else |
1283 | #error No disk paths defined for this platform | 1287 | #error No disk paths defined for this platform |
1284 | #endif | 1288 | #endif |
1285 | if (ipod_open(ipod, 1) < 0) { | 1289 | if ((result = ipod_open(ipod, 1)) < 0) { |
1290 | if(result == -2) { | ||
1291 | denied++; | ||
1292 | } | ||
1286 | continue; | 1293 | continue; |
1287 | } | 1294 | } |
1288 | 1295 | ||
@@ -1319,7 +1326,15 @@ int ipod_scan(struct ipod_t* ipod) | |||
1319 | /* Remember the disk name */ | 1326 | /* Remember the disk name */ |
1320 | strcpy(ipod->diskname,last_ipod); | 1327 | strcpy(ipod->diskname,last_ipod); |
1321 | } | 1328 | } |
1322 | return n; | 1329 | else if(n == 0 && denied) { |
1330 | printf("[ERR] FATAL: Permission denied on %d device(s) and no ipod detected.\n", denied); | ||
1331 | #ifdef __WIN32__ | ||
1332 | printf("[ERR] You need to run this program with administrator priviledges!\n"); | ||
1333 | #else | ||
1334 | printf("[ERR] You need permissions for raw disc access for this program to work!\n"); | ||
1335 | #endif | ||
1336 | } | ||
1337 | return (n == 0 && denied) ? -1 : n; | ||
1323 | } | 1338 | } |
1324 | 1339 | ||
1325 | static void put_int32le(uint32_t x, unsigned char* p) | 1340 | static void put_int32le(uint32_t x, unsigned char* p) |