summaryrefslogtreecommitdiffstats
path: root/rbutil/ipodpatcher/ipodpatcher.c
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-05-04 11:59:04 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-05-04 11:59:04 +0000
commit194b2ca887f44e6c3e0244e7f4733060e7aa1618 (patch)
treed74a7230e663e06fbd3b3b3830f4a7c3ceafc43e /rbutil/ipodpatcher/ipodpatcher.c
parentdaa8341a13ddc93981d2c2178b183a13b5e08950 (diff)
downloadrockbox-194b2ca887f44e6c3e0244e7f4733060e7aa1618.tar.gz
rockbox-194b2ca887f44e6c3e0244e7f4733060e7aa1618.tar.bz2
rockbox-194b2ca887f44e6c3e0244e7f4733060e7aa1618.zip
Check for permission denied error when trying to access the player and inform the user that raw disc access permissions are required.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17351 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/ipodpatcher/ipodpatcher.c')
-rw-r--r--rbutil/ipodpatcher/ipodpatcher.c19
1 files changed, 17 insertions, 2 deletions
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)
return 0;
}
+/* returns number of found ipods or -1 if no ipods found and permission
+ * for raw disc access was denied. */
int ipod_scan(struct ipod_t* ipod)
{
int i;
int n = 0;
int ipod_version;
char last_ipod[4096];
+ int denied = 0;
+ int result;
printf("[INFO] Scanning disk devices...\n");
@@ -1282,7 +1286,10 @@ int ipod_scan(struct ipod_t* ipod)
#else
#error No disk paths defined for this platform
#endif
- if (ipod_open(ipod, 1) < 0) {
+ if ((result = ipod_open(ipod, 1)) < 0) {
+ if(result == -2) {
+ denied++;
+ }
continue;
}
@@ -1319,7 +1326,15 @@ int ipod_scan(struct ipod_t* ipod)
/* Remember the disk name */
strcpy(ipod->diskname,last_ipod);
}
- return n;
+ else if(n == 0 && denied) {
+ printf("[ERR] FATAL: Permission denied on %d device(s) and no ipod detected.\n", denied);
+#ifdef __WIN32__
+ printf("[ERR] You need to run this program with administrator priviledges!\n");
+#else
+ printf("[ERR] You need permissions for raw disc access for this program to work!\n");
+#endif
+ }
+ return (n == 0 && denied) ? -1 : n;
}
static void put_int32le(uint32_t x, unsigned char* p)