summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flash_erase.c16
-rw-r--r--flash_otp_write.c5
-rw-r--r--ftl_check.c6
-rw-r--r--ftl_format.c2
-rw-r--r--lib/libmtd.c12
-rw-r--r--mkfs.ubifs/mkfs.ubifs.c11
-rw-r--r--mtd_debug.c14
-rw-r--r--tests/fs-tests/integrity/integck.c4
-rw-r--r--tests/ubi-tests/integ.c38
9 files changed, 55 insertions, 53 deletions
diff --git a/flash_erase.c b/flash_erase.c
index fe2eaca..326a299 100644
--- a/flash_erase.c
+++ b/flash_erase.c
@@ -49,10 +49,10 @@ static int unlock; /* unlock sectors before erasing */
static struct jffs2_unknown_node cleanmarker;
int target_endian = __BYTE_ORDER;
-static void show_progress(struct mtd_dev_info *mtd, uint64_t start, int eb,
+static void show_progress(struct mtd_dev_info *mtd, off_t start, int eb,
int eb_start, int eb_cnt)
{
- bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIx64" -- %2i %% complete ",
+ bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
mtd->eb_size / 1024, start, ((eb - eb_start) * 100) / eb_cnt);
fflush(stdout);
}
@@ -97,7 +97,7 @@ int main(int argc, char *argv[])
unsigned int eb, eb_start, eb_cnt;
int isNAND;
int error = 0;
- uint64_t offset = 0;
+ off_t offset = 0;
/*
* Process user arguments
@@ -235,12 +235,12 @@ int main(int argc, char *argv[])
eb_cnt = (mtd.size / mtd.eb_size) - eb_start;
for (eb = eb_start; eb < eb_start + eb_cnt; eb++) {
- offset = (uint64_t)eb * mtd.eb_size;
+ offset = (off_t)eb * mtd.eb_size;
if (!noskipbad) {
int ret = mtd_is_bad(&mtd, fd, eb);
if (ret > 0) {
- verbose(!quiet, "Skipping bad block at %08"PRIx64, offset);
+ verbose(!quiet, "Skipping bad block at %08"PRIxoff_t, offset);
continue;
} else if (ret < 0) {
if (errno == EOPNOTSUPP) {
@@ -272,12 +272,12 @@ int main(int argc, char *argv[])
/* write cleanmarker */
if (isNAND) {
- if (mtd_write_oob(mtd_desc, &mtd, fd, offset + clmpos, clmlen, &cleanmarker) != 0) {
+ if (mtd_write_oob(mtd_desc, &mtd, fd, (uint64_t)offset + clmpos, clmlen, &cleanmarker) != 0) {
sys_errmsg("%s: MTD writeoob failure", mtd_device);
continue;
}
} else {
- if (lseek(fd, (loff_t)offset, SEEK_SET) < 0) {
+ if (lseek(fd, offset, SEEK_SET) < 0) {
sys_errmsg("%s: MTD lseek failure", mtd_device);
continue;
}
@@ -286,7 +286,7 @@ int main(int argc, char *argv[])
continue;
}
}
- verbose(!quiet, " Cleanmarker written at %"PRIx64, offset);
+ verbose(!quiet, " Cleanmarker written at %"PRIxoff_t, offset);
}
show_progress(&mtd, offset, eb, eb_start, eb_cnt);
bareverbose(!quiet, "\n");
diff --git a/flash_otp_write.c b/flash_otp_write.c
index d407ebb..56769ec 100644
--- a/flash_otp_write.c
+++ b/flash_otp_write.c
@@ -13,6 +13,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <common.h>
#include <mtd/mtd-user.h>
int main(int argc,char *argv[])
@@ -47,7 +48,7 @@ int main(int argc,char *argv[])
return errno;
}
- offset = strtoul(argv[3], &p, 0);
+ offset = (off_t)strtoull(argv[3], &p, 0);
if (argv[3][0] == 0 || *p != 0) {
fprintf(stderr, "%s: bad offset value\n", PROGRAM_NAME);
return ERANGE;
@@ -58,7 +59,7 @@ int main(int argc,char *argv[])
return errno;
}
- printf("Writing OTP user data on %s at offset 0x%lx\n", argv[2], offset);
+ printf("Writing OTP user data on %s at offset 0x%"PRIxoff_t"\n", argv[2], offset);
if (mtdInfo.type == MTD_NANDFLASH)
len = mtdInfo.writesize;
diff --git a/ftl_check.c b/ftl_check.c
index 5e75e6a..6d84785 100644
--- a/ftl_check.c
+++ b/ftl_check.c
@@ -53,6 +53,7 @@
#include <byteswap.h>
#include <endian.h>
+#include "common.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define TO_LE32(x) (x)
@@ -85,7 +86,8 @@ static void check_partition(int fd)
{
mtd_info_t mtd;
erase_unit_header_t hdr, hdr2;
- u_int i, j, nbam, *bam;
+ off_t i;
+ u_int j, nbam, *bam;
int control, data, free, deleted;
/* Get partition size, block size */
@@ -142,7 +144,7 @@ static void check_partition(int fd)
perror("read failed");
break;
}
- printf("\nErase unit %d:\n", i);
+ printf("\nErase unit %"PRIdoff_t":\n", i);
if ((hdr2.FormattedSize != hdr.FormattedSize) ||
(hdr2.NumEraseUnits != hdr.NumEraseUnits) ||
(hdr2.SerialNumber != hdr.SerialNumber))
diff --git a/ftl_format.c b/ftl_format.c
index bd4203b..0ce601b 100644
--- a/ftl_format.c
+++ b/ftl_format.c
@@ -240,7 +240,7 @@ static int format_partition(int fd, int quiet, int interrogate,
/* Distribute transfer units over the entire region */
step = (spare) ? (FROM_LE16(hdr.NumEraseUnits)/spare) : (FROM_LE16(hdr.NumEraseUnits)+1);
for (i = 0; i < FROM_LE16(hdr.NumEraseUnits); i++) {
- u_int ofs = (i + FROM_LE16(hdr.FirstPhysicalEUN)) << hdr.EraseUnitSize;
+ off_t ofs = (off_t) (i + FROM_LE16(hdr.FirstPhysicalEUN)) << hdr.EraseUnitSize;
if (lseek(fd, ofs, SEEK_SET) == -1) {
perror("seek failed");
break;
diff --git a/lib/libmtd.c b/lib/libmtd.c
index c4836df..654490e 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -1063,8 +1063,8 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
/* Seek to the beginning of the eraseblock */
seek = (off_t)eb * mtd->eb_size + offs;
if (lseek(fd, seek, SEEK_SET) != seek)
- return sys_errmsg("cannot seek mtd%d to offset %llu",
- mtd->mtd_num, (unsigned long long)seek);
+ return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
+ mtd->mtd_num, seek);
while (rd < len) {
ret = read(fd, buf, len);
@@ -1171,8 +1171,8 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
if (data) {
/* Seek to the beginning of the eraseblock */
if (lseek(fd, seek, SEEK_SET) != seek)
- return sys_errmsg("cannot seek mtd%d to offset %llu",
- mtd->mtd_num, (unsigned long long)seek);
+ return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
+ mtd->mtd_num, seek);
ret = write(fd, data, len);
if (ret != len)
return sys_errmsg("cannot write %d bytes to mtd%d "
@@ -1329,8 +1329,8 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
/* Seek to the beginning of the eraseblock */
seek = (off_t)eb * mtd->eb_size + offs;
if (lseek(fd, seek, SEEK_SET) != seek) {
- sys_errmsg("cannot seek mtd%d to offset %llu",
- mtd->mtd_num, (unsigned long long)seek);
+ sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
+ mtd->mtd_num, seek);
goto out_close;
}
diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c
index 149806b..46f12ad 100644
--- a/mkfs.ubifs/mkfs.ubifs.c
+++ b/mkfs.ubifs/mkfs.ubifs.c
@@ -777,7 +777,7 @@ static void prepare_node(void *node, int len)
*/
int write_leb(int lnum, int len, void *buf)
{
- off64_t pos = (off64_t)lnum * c->leb_size;
+ off_t pos = (off_t)lnum * c->leb_size;
dbg_msg(3, "LEB %d len %d", lnum, len);
memset(buf + len, 0xff, c->leb_size - len);
@@ -785,13 +785,12 @@ int write_leb(int lnum, int len, void *buf)
if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size))
return sys_err_msg("ubi_leb_change_start failed");
- if (lseek64(out_fd, pos, SEEK_SET) != pos)
- return sys_err_msg("lseek64 failed seeking %lld",
- (long long)pos);
+ if (lseek(out_fd, pos, SEEK_SET) != pos)
+ return sys_err_msg("lseek failed seeking %"PRIdoff_t, pos);
if (write(out_fd, buf, c->leb_size) != c->leb_size)
- return sys_err_msg("write failed writing %d bytes at pos %lld",
- c->leb_size, (long long)pos);
+ return sys_err_msg("write failed writing %d bytes at pos %"PRIdoff_t,
+ c->leb_size, pos);
return 0;
}
diff --git a/mtd_debug.c b/mtd_debug.c
index 2d307a9..9110e9b 100644
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -103,7 +103,7 @@ void printsize(u_int32_t x)
printf("(%u%c)", x, flags[i]);
}
-int flash_to_file(int fd, u_int32_t offset, size_t len, const char *filename)
+int flash_to_file(int fd, off_t offset, size_t len, const char *filename)
{
u_int8_t *buf = NULL;
int outfd, err;
@@ -157,7 +157,7 @@ retry:
if (buf != NULL)
free(buf);
close(outfd);
- printf("Copied %zu bytes from address 0x%.8x in flash to %s\n", len, offset, filename);
+ printf("Copied %zu bytes from address 0x%.8"PRIxoff_t" in flash to %s\n", len, offset, filename);
return 0;
err2:
@@ -169,7 +169,7 @@ err0:
return 1;
}
-int file_to_flash(int fd, u_int32_t offset, u_int32_t len, const char *filename)
+int file_to_flash(int fd, off_t offset, u_int32_t len, const char *filename)
{
u_int8_t *buf = NULL;
FILE *fp;
@@ -221,7 +221,7 @@ retry:
if (buf != NULL)
free(buf);
fclose(fp);
- printf("Copied %d bytes from %s to address 0x%.8x in flash\n", len, filename, offset);
+ printf("Copied %d bytes from %s to address 0x%.8"PRIxoff_t" in flash\n", len, filename, offset);
return 0;
}
@@ -376,13 +376,13 @@ int main(int argc, char *argv[])
showinfo(fd);
break;
case OPT_READ:
- err = flash_to_file(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0), argv[5]);
+ err = flash_to_file(fd, strtoll(argv[3], NULL, 0), strtoul(argv[4], NULL, 0), argv[5]);
break;
case OPT_WRITE:
- err = file_to_flash(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0), argv[5]);
+ err = file_to_flash(fd, strtoll(argv[3], NULL, 0), strtoul(argv[4], NULL, 0), argv[5]);
break;
case OPT_ERASE:
- err = erase_flash(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0));
+ err = erase_flash(fd, strtoul(argv[3], NULL, 0), strtoul(argv[4], NULL, 0));
break;
}
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index f12dfac..087a18b 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -899,8 +899,8 @@ static ssize_t file_write_data(struct file_info *file, int fd, off_t offset,
remains = size;
actual = 0;
written = IO_BUFFER_SIZE;
- v("write %zd bytes, offset %llu, file %s",
- size, (unsigned long long)offset, get_file_name(file));
+ v("write %zd bytes, offset %"PRIdoff_t", file %s",
+ size, offset, get_file_name(file));
while (remains) {
/* Fill up buffer with random data */
if (written < IO_BUFFER_SIZE) {
diff --git a/tests/ubi-tests/integ.c b/tests/ubi-tests/integ.c
index 4e13b73..e48f533 100644
--- a/tests/ubi-tests/integ.c
+++ b/tests/ubi-tests/integ.c
@@ -25,7 +25,7 @@ struct write_info
struct write_info *next;
struct erase_block_info *erase_block;
int offset_within_block; /* Offset within erase block */
- off64_t offset; /* Offset within volume */
+ off_t offset; /* Offset within volume */
int size;
int random_seed;
};
@@ -34,8 +34,8 @@ struct erase_block_info
{
struct volume_info *volume;
int block_number;
- off64_t offset; /* Offset within volume */
- off64_t top_of_data;
+ off_t offset; /* Offset within volume */
+ off_t top_of_data;
int touched; /* Have we done anything at all with this erase block */
int erased; /* This erased block is currently erased */
struct write_info *writes;
@@ -220,7 +220,7 @@ static void set_random_data(unsigned seed, unsigned char *buf, int size)
static void check_erase_block(struct erase_block_info *erase_block, int fd)
{
struct write_info *w;
- off64_t gap_end;
+ off_t gap_end;
int leb_size = erase_block->volume->info.leb_size;
ssize_t bytes_read;
@@ -229,10 +229,10 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
while (w) {
if (w->offset + w->size < gap_end) {
/* There is a gap. Check all 0xff */
- off64_t gap_start = w->offset + w->size;
+ off_t gap_start = w->offset + w->size;
ssize_t size = gap_end - gap_start;
- if (lseek64(fd, gap_start, SEEK_SET) != gap_start)
- error_exit("lseek64 failed");
+ if (lseek(fd, gap_start, SEEK_SET) != gap_start)
+ error_exit("lseek failed");
memset(read_buffer, 0 , size);
errno = 0;
bytes_read = read(fd, read_buffer, size);
@@ -241,18 +241,18 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
while (size)
if (read_buffer[--size] != 0xff) {
fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
- fprintf(stderr, "offset = %lld\n" , (long long) gap_start);
+ fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
fprintf(stderr, "size = %ld\n" , (long) bytes_read);
error_exit("verify 0xff failed");
}
}
- if (lseek64(fd, w->offset, SEEK_SET) != w->offset)
- error_exit("lseek64 failed");
+ if (lseek(fd, w->offset, SEEK_SET) != w->offset)
+ error_exit("lseek failed");
memset(read_buffer, 0 , w->size);
errno = 0;
bytes_read = read(fd, read_buffer, w->size);
if (bytes_read != w->size) {
- fprintf(stderr, "offset = %lld\n" , (long long) w->offset);
+ fprintf(stderr, "offset = %"PRIdoff_t"\n" , w->offset);
fprintf(stderr, "size = %ld\n" , (long) w->size);
fprintf(stderr, "bytes_read = %ld\n" , (long) bytes_read);
error_exit("read failed");
@@ -265,10 +265,10 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
}
if (gap_end > erase_block->offset) {
/* Check all 0xff */
- off64_t gap_start = erase_block->offset;
+ off_t gap_start = erase_block->offset;
ssize_t size = gap_end - gap_start;
- if (lseek64(fd, gap_start, SEEK_SET) != gap_start)
- error_exit("lseek64 failed");
+ if (lseek(fd, gap_start, SEEK_SET) != gap_start)
+ error_exit("lseek failed");
memset(read_buffer, 0 , size);
errno = 0;
bytes_read = read(fd, read_buffer, size);
@@ -277,7 +277,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
while (size)
if (read_buffer[--size] != 0xff) {
fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
- fprintf(stderr, "offset = %lld\n" , (long long) gap_start);
+ fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
fprintf(stderr, "size = %ld\n" , (long) bytes_read);
error_exit("verify 0xff failed!");
}
@@ -290,7 +290,7 @@ static int write_to_erase_block(struct erase_block_info *erase_block, int fd)
int leb_size = erase_block->volume->info.leb_size;
int next_offset = 0;
int space, size;
- off64_t offset;
+ off_t offset;
unsigned seed;
struct write_info *w;
@@ -327,8 +327,8 @@ static int write_to_erase_block(struct erase_block_info *erase_block, int fd)
offset = erase_block->offset + next_offset;
if (offset < erase_block->top_of_data)
error_exit("internal error!");
- if (lseek64(fd, offset, SEEK_SET) != offset)
- error_exit("lseek64 failed");
+ if (lseek(fd, offset, SEEK_SET) != offset)
+ error_exit("lseek failed");
/* Do write */
seed = get_next_seed();
if (!seed)
@@ -480,7 +480,7 @@ static void operate_on_ubi_device(struct ubi_device_info *ubi_device)
for (i = 0; i < n; ++i) {
s->erase_blocks[i].volume = s;
s->erase_blocks[i].block_number = i;
- s->erase_blocks[i].offset = i * (off64_t) s->info.leb_size;
+ s->erase_blocks[i].offset = i * (off_t) s->info.leb_size;
s->erase_blocks[i].top_of_data = s->erase_blocks[i].offset;
}
/* FIXME: Correctly get device file name */