diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-05-04 11:59:04 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-05-04 11:59:04 +0000 |
commit | 194b2ca887f44e6c3e0244e7f4733060e7aa1618 (patch) | |
tree | d74a7230e663e06fbd3b3b3830f4a7c3ceafc43e /rbutil/ipodpatcher | |
parent | daa8341a13ddc93981d2c2178b183a13b5e08950 (diff) |
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')
-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 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include <errno.h> #include "ipodio.h" @@ -105,7 +106,8 @@ int ipod_open(struct ipod_t* ipod, int silent) ipod->dh=open(ipod->diskname,O_RDONLY); if (ipod->dh < 0) { if (!silent) perror(ipod->diskname); - return -1; + if(errno == EACCES) return -2; + else return -1; } /* 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) if (ipod->dh == INVALID_HANDLE_VALUE) { if (!silent) print_error(" Error opening disk: "); - return -1; + if(GetLastError() == ERROR_ACCESS_DENIED) + return -2; + else + return -1; } 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) 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) |