diff options
Diffstat (limited to 'tools/ipodpatcher/ipodio-posix.c')
-rw-r--r-- | tools/ipodpatcher/ipodio-posix.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/tools/ipodpatcher/ipodio-posix.c b/tools/ipodpatcher/ipodio-posix.c index 071a540017..ed3737a5ed 100644 --- a/tools/ipodpatcher/ipodio-posix.c +++ b/tools/ipodpatcher/ipodio-posix.c | |||
@@ -47,36 +47,39 @@ void print_error(char* msg) | |||
47 | perror(msg); | 47 | perror(msg); |
48 | } | 48 | } |
49 | 49 | ||
50 | int ipod_open(HANDLE* dh, char* diskname, int* sector_size, int silent) | 50 | int ipod_open(struct ipod_t* ipod, int silent) |
51 | { | 51 | { |
52 | *dh=open(diskname,O_RDONLY); | 52 | ipod->dh=open(ipod->diskname,O_RDONLY); |
53 | if (*dh < 0) { | 53 | if (ipod->dh < 0) { |
54 | if (!silent) perror(diskname); | 54 | if (!silent) perror(ipod->diskname); |
55 | return -1; | 55 | return -1; |
56 | } | 56 | } |
57 | 57 | ||
58 | if(ioctl(*dh,IPOD_SECTORSIZE_IOCTL,sector_size) < 0) { | 58 | if(ioctl(ipod->dh,IPOD_SECTORSIZE_IOCTL,&ipod->sector_size) < 0) { |
59 | *sector_size=512; | 59 | ipod->sector_size=512; |
60 | if (!silent) fprintf(stderr,"[ERR] ioctl() call to get sector size failed, defaulting to %d\n",*sector_size); | 60 | if (!silent) { |
61 | fprintf(stderr,"[ERR] ioctl() call to get sector size failed, defaulting to %d\n" | ||
62 | ,ipod->sector_size); | ||
63 | } | ||
61 | } | 64 | } |
62 | return 0; | 65 | return 0; |
63 | } | 66 | } |
64 | 67 | ||
65 | 68 | ||
66 | int ipod_reopen_rw(HANDLE* dh, char* diskname) | 69 | int ipod_reopen_rw(struct ipod_t* ipod) |
67 | { | 70 | { |
68 | close(*dh); | 71 | close(ipod->dh); |
69 | *dh=open(diskname,O_RDWR); | 72 | ipod->dh=open(ipod->diskname,O_RDWR); |
70 | if (*dh < 0) { | 73 | if (ipod->dh < 0) { |
71 | perror(diskname); | 74 | perror(ipod->diskname); |
72 | return -1; | 75 | return -1; |
73 | } | 76 | } |
74 | return 0; | 77 | return 0; |
75 | } | 78 | } |
76 | 79 | ||
77 | int ipod_close(HANDLE dh) | 80 | int ipod_close(struct ipod_t* ipod) |
78 | { | 81 | { |
79 | close(dh); | 82 | close(ipod->dh); |
80 | return 0; | 83 | return 0; |
81 | } | 84 | } |
82 | 85 | ||
@@ -89,11 +92,11 @@ int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize) | |||
89 | return 0; | 92 | return 0; |
90 | } | 93 | } |
91 | 94 | ||
92 | int ipod_seek(HANDLE dh, unsigned long pos) | 95 | int ipod_seek(struct ipod_t* ipod, unsigned long pos) |
93 | { | 96 | { |
94 | off_t res; | 97 | off_t res; |
95 | 98 | ||
96 | res = lseek(dh, pos, SEEK_SET); | 99 | res = lseek(ipod->dh, pos, SEEK_SET); |
97 | 100 | ||
98 | if (res == -1) { | 101 | if (res == -1) { |
99 | return -1; | 102 | return -1; |
@@ -101,12 +104,12 @@ int ipod_seek(HANDLE dh, unsigned long pos) | |||
101 | return 0; | 104 | return 0; |
102 | } | 105 | } |
103 | 106 | ||
104 | int ipod_read(HANDLE dh, unsigned char* buf, int nbytes) | 107 | int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes) |
105 | { | 108 | { |
106 | return read(dh, buf, nbytes); | 109 | return read(ipod->dh, buf, nbytes); |
107 | } | 110 | } |
108 | 111 | ||
109 | int ipod_write(HANDLE dh, unsigned char* buf, int nbytes) | 112 | int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes) |
110 | { | 113 | { |
111 | return write(dh, buf, nbytes); | 114 | return write(ipod->dh, buf, nbytes); |
112 | } | 115 | } |