mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-16 20:55:20 +03:00
215 lines
7.1 KiB
Diff
215 lines
7.1 KiB
Diff
Author: Sean McAvoy <seanmcavoy@gmail.com>
|
|
Summary: fixes for musl, use uint instead of u_int
|
|
----
|
|
diff --git a/src/cfdump.c b/src/cfdump.c
|
|
index ff33ad6..993702a 100644
|
|
--- a/src/cfdump.c
|
|
+++ b/src/cfdump.c
|
|
@@ -19,18 +19,18 @@ dump_header(char *n, cf_header_t *h) {
|
|
}
|
|
|
|
static int crcinitdone = 0;
|
|
-static u_int32_t xcrc_tab32[CRC_TABLE_LEN];
|
|
-static inline u_int32_t
|
|
-xcrc32(u_int32_t crc, unsigned char *buf, u_int64_t size)
|
|
+static uint32_t xcrc_tab32[CRC_TABLE_LEN];
|
|
+static inline uint32_t
|
|
+xcrc32(uint32_t crc, unsigned char *buf, uint64_t size)
|
|
{
|
|
int i;
|
|
- u_int64_t s;
|
|
- u_int32_t tmp;
|
|
+ uint64_t s;
|
|
+ uint32_t tmp;
|
|
|
|
if (!crcinitdone) {
|
|
for (i=0; i<CRC_TABLE_LEN; i++) {
|
|
int j;
|
|
- u_int32_t init_crc = (u_int32_t) i;
|
|
+ uint32_t init_crc = (uint32_t) i;
|
|
for (j=0; j<CRC_UNIT_BITS; j++) {
|
|
init_crc = (init_crc & 0x00000001L) ?
|
|
(init_crc >> 1) ^ 0xEDB88320L :
|
|
@@ -40,20 +40,20 @@ xcrc32(u_int32_t crc, unsigned char *buf, u_int64_t size)
|
|
}
|
|
}
|
|
for (s=0; s<size; s++) {
|
|
- tmp = crc ^ (((u_int32_t) buf[s]) & 0x000000ffL);
|
|
+ tmp = crc ^ (((uint32_t) buf[s]) & 0x000000ffL);
|
|
crc = (crc >> 8) ^ xcrc_tab32[ tmp & 0xff ];
|
|
}
|
|
return(crc);
|
|
}
|
|
|
|
int
|
|
-verify_block(void *cf, u_int64_t offs, u_int64_t index, void *rbuffer,
|
|
- u_int64_t bsize)
|
|
+verify_block(void *cf, uint64_t offs, uint64_t index, void *rbuffer,
|
|
+ uint64_t bsize)
|
|
{
|
|
- u_int64_t nread;
|
|
+ uint64_t nread;
|
|
int error = 1;
|
|
if (!(error = (*sysdep->sys_seek)(cf, offs, SYSDEP_SEEK_ABSOLUTE,
|
|
- (u_int64_t *) NULL))) {
|
|
+ (uint64_t *) NULL))) {
|
|
if (!(error = (*sysdep->sys_read)(cf, rbuffer, bsize, &nread)) &&
|
|
(nread == bsize)) {
|
|
cf_block_trailer_t btrail;
|
|
@@ -76,10 +76,10 @@ verify_block(void *cf, u_int64_t offs, u_int64_t index, void *rbuffer,
|
|
}
|
|
|
|
void
|
|
-dump_blocks(cf_header_t *h, u_int64_t *bm, void *cf) {
|
|
- u_int64_t bi, nread;
|
|
- u_int64_t nfound = 0;
|
|
- u_int64_t bsize = 0;
|
|
+dump_blocks(cf_header_t *h, uint64_t *bm, void *cf) {
|
|
+ uint64_t bi, nread;
|
|
+ uint64_t nfound = 0;
|
|
+ uint64_t bsize = 0;
|
|
void *rbuffer = (void *) NULL;
|
|
int error;
|
|
for (bi=0; bi<h->cf_total_blocks; bi++) {
|
|
@@ -107,10 +107,10 @@ dump_blocks(cf_header_t *h, u_int64_t *bm, void *cf) {
|
|
}
|
|
printf("%s\n", (good) ? "ok" : "INVALID");
|
|
if (bsize && rbuffer) {
|
|
- u_int64_t boff;
|
|
+ uint64_t boff;
|
|
for (boff = 0; boff < bsize; boff += 16) {
|
|
- u_int64_t soff;
|
|
- printf("0x%04x: ", (u_int16_t) boff);
|
|
+ uint64_t soff;
|
|
+ printf("0x%04x: ", (uint16_t) boff);
|
|
for (soff = 0; soff < 16; soff++) {
|
|
printf("%02x ", ((unsigned char *) rbuffer)[boff+soff]);
|
|
}
|
|
@@ -141,16 +141,16 @@ main(int argc, char *argv[])
|
|
for (i=1; i<argc; i++) {
|
|
if ((error = (*sysdep->sys_open)(&cfp, argv[i], SYSDEP_OPEN_RO)) == 0) {
|
|
cf_header_t header;
|
|
- u_int64_t nread;
|
|
+ uint64_t nread;
|
|
(void) (*sysdep->sys_seek)(cfp, 0, SYSDEP_SEEK_ABSOLUTE,
|
|
- (u_int64_t *) NULL);
|
|
+ (uint64_t *) NULL);
|
|
if ((error = (*sysdep->sys_read)(cfp, &header, sizeof(header),
|
|
&nread)) == 0) {
|
|
if ((header.cf_magic == CF_MAGIC_1) &&
|
|
(header.cf_magic2 == CF_MAGIC_2)) {
|
|
- u_int64_t bmsize = header.cf_total_blocks *
|
|
- sizeof(u_int64_t);
|
|
- u_int64_t *blockmap;
|
|
+ uint64_t bmsize = header.cf_total_blocks *
|
|
+ sizeof(uint64_t);
|
|
+ uint64_t *blockmap;
|
|
|
|
if ((error = (*sysdep->sys_malloc)(&blockmap, bmsize))
|
|
== 0) {
|
|
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
|
|
(void) (*sysdep->sys_seek)(cfp,
|
|
header.cf_blockmap_offset,
|
|
SYSDEP_SEEK_ABSOLUTE,
|
|
- (u_int64_t *) NULL);
|
|
+ (uint64_t *) NULL);
|
|
if ((error = (*sysdep->sys_read)(cfp, blockmap,
|
|
bmsize, &nread))
|
|
== 0) {
|
|
diff --git a/src/changefileint.h b/src/changefileint.h
|
|
index 237b5a8..30ae1d9 100644
|
|
--- a/src/changefileint.h
|
|
+++ b/src/changefileint.h
|
|
@@ -25,29 +25,29 @@
|
|
#define CF_VERSION_1 1
|
|
#define CF_HEADER_DIRTY 1
|
|
typedef struct change_file_header {
|
|
- u_int32_t cf_magic; /* 0x00 - magic */
|
|
- u_int16_t cf_version; /* 0x04 - version */
|
|
- u_int16_t cf_flags; /* 0x06 - flags */
|
|
- u_int64_t cf_total_blocks; /* 0x08 - total blocks */
|
|
- u_int64_t cf_used_blocks; /* 0x10 - used blocks */
|
|
- u_int32_t cf_blockmap_offset; /* 0x18 - blockmap offset */
|
|
- u_int32_t cf_magic2; /* 0x1c - magic2 */
|
|
+ uint32_t cf_magic; /* 0x00 - magic */
|
|
+ uint16_t cf_version; /* 0x04 - version */
|
|
+ uint16_t cf_flags; /* 0x06 - flags */
|
|
+ uint64_t cf_total_blocks; /* 0x08 - total blocks */
|
|
+ uint64_t cf_used_blocks; /* 0x10 - used blocks */
|
|
+ uint32_t cf_blockmap_offset; /* 0x18 - blockmap offset */
|
|
+ uint32_t cf_magic2; /* 0x1c - magic2 */
|
|
} cf_header_t; /* 0x20 - total size */
|
|
|
|
typedef struct change_file_context {
|
|
cf_header_t cfc_header;
|
|
const sysdep_dispatch_t *cfc_sysdep;
|
|
void *cfc_fd;
|
|
- u_int64_t *cfc_blockmap;
|
|
- u_int64_t cfc_blocksize;
|
|
- u_int64_t cfc_blockcount;
|
|
- u_int64_t cfc_curpos;
|
|
- u_int32_t cfc_crc_tab32[CRC_TABLE_LEN];
|
|
+ uint64_t *cfc_blockmap;
|
|
+ uint64_t cfc_blocksize;
|
|
+ uint64_t cfc_blockcount;
|
|
+ uint64_t cfc_curpos;
|
|
+ uint32_t cfc_crc_tab32[CRC_TABLE_LEN];
|
|
} cf_context_t;
|
|
|
|
typedef struct change_file_block_trailer {
|
|
- u_int64_t cfb_curblock;
|
|
- u_int32_t cfb_crc;
|
|
- u_int32_t cfb_magic;
|
|
+ uint64_t cfb_curblock;
|
|
+ uint32_t cfb_crc;
|
|
+ uint32_t cfb_magic;
|
|
} cf_block_trailer_t;
|
|
#endif /* _CHANGEFILEINT_H_ */
|
|
diff --git a/src/sysdep_int.h b/src/sysdep_int.h
|
|
index f7a037c..0b9fad9 100644
|
|
--- a/src/sysdep_int.h
|
|
+++ b/src/sysdep_int.h
|
|
@@ -73,7 +73,7 @@ typedef struct sysdep_dispatch {
|
|
* error - Otherwise.
|
|
*/
|
|
int (*sys_seek)(void *rh, int64_t offset, sysdep_whence_t whence,
|
|
- u_int64_t *resoffp);
|
|
+ uint64_t *resoffp);
|
|
/*
|
|
* sys_read - Read data from the current offset.
|
|
*
|
|
@@ -88,7 +88,7 @@ typedef struct sysdep_dispatch {
|
|
* EINVAL - Invalid file handle.
|
|
* error - Otherwise.
|
|
*/
|
|
- int (*sys_read)(void *rh, void *buf, u_int64_t len, u_int64_t *nr);
|
|
+ int (*sys_read)(void *rh, void *buf, uint64_t len, uint64_t *nr);
|
|
/*
|
|
* sys_write - Write data at the current offset.
|
|
*
|
|
@@ -103,7 +103,7 @@ typedef struct sysdep_dispatch {
|
|
* EINVAL - Invalid file handle.
|
|
* error - Otherwise.
|
|
*/
|
|
- int (*sys_write)(void *rh, void *buf, u_int64_t len, u_int64_t *nw);
|
|
+ int (*sys_write)(void *rh, void *buf, uint64_t len, uint64_t *nw);
|
|
/*
|
|
* sys_malloc - Allocate dynamic memory.
|
|
*
|
|
@@ -116,7 +116,7 @@ typedef struct sysdep_dispatch {
|
|
* EINVAL - Invalid nmpp
|
|
* ENOMEM - No memory available
|
|
*/
|
|
- int (*sys_malloc)(void *nmpp, u_int64_t nbytes);
|
|
+ int (*sys_malloc)(void *nmpp, uint64_t nbytes);
|
|
/*
|
|
* sys_free - Free dynamic memory.
|
|
*
|
|
@@ -135,6 +135,6 @@ typedef struct sysdep_dispatch {
|
|
* rh - Open file handle.
|
|
* nbytes - File size.
|
|
*/
|
|
- int (*sys_file_size)(void *rh, u_int64_t *nbytes);
|
|
+ int (*sys_file_size)(void *rh, uint64_t *nbytes);
|
|
} sysdep_dispatch_t;
|
|
#endif /* _SYSDEP_INT_H_ */
|