diff options
Diffstat (limited to 'rbutil/ipodpatcher/ipodpatcher.c')
-rw-r--r-- | rbutil/ipodpatcher/ipodpatcher.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c index e43fc8d156..45fb24d4fc 100644 --- a/rbutil/ipodpatcher/ipodpatcher.c +++ b/rbutil/ipodpatcher/ipodpatcher.c | |||
@@ -73,7 +73,7 @@ char* get_parttype(int pt) | |||
73 | int i; | 73 | int i; |
74 | static char unknown[]="Unknown"; | 74 | static char unknown[]="Unknown"; |
75 | 75 | ||
76 | if (pt == -1) { | 76 | if (pt == PARTTYPE_HFS) { |
77 | return "HFS/HFS+"; | 77 | return "HFS/HFS+"; |
78 | } | 78 | } |
79 | 79 | ||
@@ -104,41 +104,41 @@ off_t filesize(int fd) { | |||
104 | #define MAX_SECTOR_SIZE 2048 | 104 | #define MAX_SECTOR_SIZE 2048 |
105 | #define SECTOR_SIZE 512 | 105 | #define SECTOR_SIZE 512 |
106 | 106 | ||
107 | unsigned short static inline le2ushort(unsigned char* buf) | 107 | static inline unsigned short le2ushort(unsigned char* buf) |
108 | { | 108 | { |
109 | unsigned short res = (buf[1] << 8) | buf[0]; | 109 | unsigned short res = (buf[1] << 8) | buf[0]; |
110 | 110 | ||
111 | return res; | 111 | return res; |
112 | } | 112 | } |
113 | 113 | ||
114 | int static inline le2int(unsigned char* buf) | 114 | static inline int le2int(unsigned char* buf) |
115 | { | 115 | { |
116 | int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | 116 | int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; |
117 | 117 | ||
118 | return res; | 118 | return res; |
119 | } | 119 | } |
120 | 120 | ||
121 | int static inline be2int(unsigned char* buf) | 121 | static inline int be2int(unsigned char* buf) |
122 | { | 122 | { |
123 | int32_t res = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; | 123 | int32_t res = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; |
124 | 124 | ||
125 | return res; | 125 | return res; |
126 | } | 126 | } |
127 | 127 | ||
128 | int static inline getint16le(char* buf) | 128 | static inline int getint16le(char* buf) |
129 | { | 129 | { |
130 | int16_t res = (buf[1] << 8) | buf[0]; | 130 | int16_t res = (buf[1] << 8) | buf[0]; |
131 | 131 | ||
132 | return res; | 132 | return res; |
133 | } | 133 | } |
134 | 134 | ||
135 | void static inline short2le(unsigned short val, unsigned char* addr) | 135 | static inline void short2le(unsigned short val, unsigned char* addr) |
136 | { | 136 | { |
137 | addr[0] = val & 0xFF; | 137 | addr[0] = val & 0xFF; |
138 | addr[1] = (val >> 8) & 0xff; | 138 | addr[1] = (val >> 8) & 0xff; |
139 | } | 139 | } |
140 | 140 | ||
141 | void static inline int2le(unsigned int val, unsigned char* addr) | 141 | static inline void int2le(unsigned int val, unsigned char* addr) |
142 | { | 142 | { |
143 | addr[0] = val & 0xFF; | 143 | addr[0] = val & 0xFF; |
144 | addr[1] = (val >> 8) & 0xff; | 144 | addr[1] = (val >> 8) & 0xff; |
@@ -146,7 +146,7 @@ void static inline int2le(unsigned int val, unsigned char* addr) | |||
146 | addr[3] = (val >> 24) & 0xff; | 146 | addr[3] = (val >> 24) & 0xff; |
147 | } | 147 | } |
148 | 148 | ||
149 | void int2be(unsigned int val, unsigned char* addr) | 149 | static inline void int2be(unsigned int val, unsigned char* addr) |
150 | { | 150 | { |
151 | addr[0] = (val >> 24) & 0xff; | 151 | addr[0] = (val >> 24) & 0xff; |
152 | addr[1] = (val >> 16) & 0xff; | 152 | addr[1] = (val >> 16) & 0xff; |
@@ -245,7 +245,7 @@ int read_partinfo(struct ipod_t* ipod, int silent) | |||
245 | /* A HFS partition */ | 245 | /* A HFS partition */ |
246 | ipod->pinfo[i].start = pmPyPartStart; | 246 | ipod->pinfo[i].start = pmPyPartStart; |
247 | ipod->pinfo[i].size = pmPartBlkCnt; | 247 | ipod->pinfo[i].size = pmPartBlkCnt; |
248 | ipod->pinfo[i].type = -1; | 248 | ipod->pinfo[i].type = PARTTYPE_HFS; |
249 | i++; | 249 | i++; |
250 | } | 250 | } |
251 | 251 | ||
@@ -262,7 +262,7 @@ int read_partinfo(struct ipod_t* ipod, int silent) | |||
262 | */ | 262 | */ |
263 | if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) || | 263 | if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) || |
264 | ((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) && | 264 | ((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) && |
265 | (ipod->pinfo[1].type != -1))) { | 265 | (ipod->pinfo[1].type != PARTTYPE_HFS))) { |
266 | if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n"); | 266 | if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n"); |
267 | return -1; | 267 | return -1; |
268 | } | 268 | } |
@@ -274,7 +274,7 @@ int read_partinfo(struct ipod_t* ipod, int silent) | |||
274 | int read_partition(struct ipod_t* ipod, int outfile) | 274 | int read_partition(struct ipod_t* ipod, int outfile) |
275 | { | 275 | { |
276 | int res; | 276 | int res; |
277 | unsigned long n; | 277 | ssize_t n; |
278 | int bytesleft; | 278 | int bytesleft; |
279 | int chunksize; | 279 | int chunksize; |
280 | int count = ipod->pinfo[0].size; | 280 | int count = ipod->pinfo[0].size; |
@@ -301,7 +301,7 @@ int read_partition(struct ipod_t* ipod, int outfile) | |||
301 | 301 | ||
302 | if (n < chunksize) { | 302 | if (n < chunksize) { |
303 | fprintf(stderr, | 303 | fprintf(stderr, |
304 | "[ERR] Short read in disk_read() - requested %d, got %lu\n", | 304 | "[ERR] Short read in disk_read() - requested %d, got %d\n", |
305 | chunksize,n); | 305 | chunksize,n); |
306 | return -1; | 306 | return -1; |
307 | } | 307 | } |
@@ -317,7 +317,7 @@ int read_partition(struct ipod_t* ipod, int outfile) | |||
317 | 317 | ||
318 | if (res != n) { | 318 | if (res != n) { |
319 | fprintf(stderr, | 319 | fprintf(stderr, |
320 | "Short write - requested %lu, received %d - aborting.\n",n,res); | 320 | "Short write - requested %d, received %d - aborting.\n",n,res); |
321 | return -1; | 321 | return -1; |
322 | } | 322 | } |
323 | } | 323 | } |
@@ -328,7 +328,7 @@ int read_partition(struct ipod_t* ipod, int outfile) | |||
328 | 328 | ||
329 | int write_partition(struct ipod_t* ipod, int infile) | 329 | int write_partition(struct ipod_t* ipod, int infile) |
330 | { | 330 | { |
331 | unsigned long res; | 331 | ssize_t res; |
332 | int n; | 332 | int n; |
333 | int bytesread; | 333 | int bytesread; |
334 | int byteswritten = 0; | 334 | int byteswritten = 0; |
@@ -370,7 +370,7 @@ int write_partition(struct ipod_t* ipod, int infile) | |||
370 | } | 370 | } |
371 | 371 | ||
372 | if (res != n) { | 372 | if (res != n) { |
373 | fprintf(stderr,"[ERR] Short write - requested %d, received %lu - aborting.\n",n,res); | 373 | fprintf(stderr,"[ERR] Short write - requested %d, received %d - aborting.\n",n,res); |
374 | return -1; | 374 | return -1; |
375 | } | 375 | } |
376 | 376 | ||