diff options
Diffstat (limited to 'rbutil/ipodpatcher/ipodio-posix.c')
-rw-r--r-- | rbutil/ipodpatcher/ipodio-posix.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c index 8d43de2d60..377510912a 100644 --- a/rbutil/ipodpatcher/ipodio-posix.c +++ b/rbutil/ipodpatcher/ipodio-posix.c | |||
@@ -358,10 +358,10 @@ int ipod_close(struct ipod_t* ipod) | |||
358 | return 0; | 358 | return 0; |
359 | } | 359 | } |
360 | 360 | ||
361 | int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize) | 361 | int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize) |
362 | { | 362 | { |
363 | *sectorbuf=malloc(bufsize); | 363 | ipod->sectorbuf = malloc(bufsize); |
364 | if (*sectorbuf == NULL) { | 364 | if (ipod->sectorbuf== NULL) { |
365 | return -1; | 365 | return -1; |
366 | } | 366 | } |
367 | return 0; | 367 | return 0; |
@@ -379,14 +379,20 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos) | |||
379 | return 0; | 379 | return 0; |
380 | } | 380 | } |
381 | 381 | ||
382 | ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes) | 382 | ssize_t ipod_read(struct ipod_t* ipod, int nbytes) |
383 | { | 383 | { |
384 | return read(ipod->dh, buf, nbytes); | 384 | if(ipod->sectorbuf == NULL) { |
385 | return -1; | ||
386 | } | ||
387 | return read(ipod->dh, ipod->sectorbuf, nbytes); | ||
385 | } | 388 | } |
386 | 389 | ||
387 | ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes) | 390 | ssize_t ipod_write(struct ipod_t* ipod, int nbytes) |
388 | { | 391 | { |
389 | return write(ipod->dh, buf, nbytes); | 392 | if(ipod->sectorbuf == NULL) { |
393 | return -1; | ||
394 | } | ||
395 | return write(ipod->dh, ipod->sectorbuf, nbytes); | ||
390 | } | 396 | } |
391 | 397 | ||
392 | #endif | 398 | #endif |