From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 09/10] memory commands: Make 64bit capable
Date: Tue, 26 Jun 2012 21:55:02 +0200 [thread overview]
Message-ID: <1340740503-7003-10-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1340740503-7003-1-git-send-email-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/mem.c | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/commands/mem.c b/commands/mem.c
index 2b85f82..b8e3bc4 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -43,7 +43,7 @@
#define PRINTF(fmt,args...)
#endif
-#define RW_BUF_SIZE (ulong)4096
+#define RW_BUF_SIZE 4096
static char *rw_buf;
static char *DEVMEM = "/dev/mem";
@@ -108,7 +108,7 @@ int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
return 0;
}
-static int open_and_lseek(const char *filename, int mode, off_t pos)
+static int open_and_lseek(const char *filename, int mode, loff_t pos)
{
int fd, ret;
@@ -240,7 +240,7 @@ static int do_mem_mw(int argc, char *argv[])
int fd;
char *filename = DEVMEM;
int mode = O_RWSIZE_4;
- ulong adr;
+ loff_t adr;
if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename) < 0)
return 1;
@@ -248,7 +248,7 @@ static int do_mem_mw(int argc, char *argv[])
if (optind + 1 >= argc)
return COMMAND_ERROR_USAGE;
- adr = strtoul_suffix(argv[optind++], NULL, 0);
+ adr = strtoull_suffix(argv[optind++], NULL, 0);
fd = open_and_lseek(filename, mode | O_WRONLY, adr);
if (fd < 0)
@@ -300,7 +300,7 @@ BAREBOX_CMD_END
static int do_mem_cmp(int argc, char *argv[])
{
- ulong addr1, addr2, count = ~0;
+ loff_t addr1, addr2, count = ~0;
int mode = O_RWSIZE_1;
char *sourcefile = DEVMEM;
char *destfile = DEVMEM;
@@ -316,8 +316,8 @@ static int do_mem_cmp(int argc, char *argv[])
if (optind + 2 > argc)
return COMMAND_ERROR_USAGE;
- addr1 = strtoul_suffix(argv[optind], NULL, 0);
- addr2 = strtoul_suffix(argv[optind + 1], NULL, 0);
+ addr1 = strtoull_suffix(argv[optind], NULL, 0);
+ addr2 = strtoull_suffix(argv[optind + 1], NULL, 0);
if (optind + 2 == argc) {
if (sourcefile == DEVMEM) {
@@ -330,7 +330,7 @@ static int do_mem_cmp(int argc, char *argv[])
}
count = statbuf.st_size - addr1;
} else {
- count = strtoul_suffix(argv[optind + 2], NULL, 0);
+ count = strtoull_suffix(argv[optind + 2], NULL, 0);
}
sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, addr1);
@@ -348,7 +348,7 @@ static int do_mem_cmp(int argc, char *argv[])
while (count > 0) {
int now, r1, r2, i;
- now = min(RW_BUF_SIZE, count);
+ now = min((loff_t)RW_BUF_SIZE, count);
r1 = read(sourcefd, rw_buf, now);
if (r1 < 0) {
@@ -409,8 +409,7 @@ BAREBOX_CMD_END
static int do_mem_cp(int argc, char *argv[])
{
- ulong count;
- ulong dest, src;
+ loff_t count, dest, src;
char *sourcefile = DEVMEM;
char *destfile = DEVMEM;
int sourcefd, destfd;
@@ -424,8 +423,8 @@ static int do_mem_cp(int argc, char *argv[])
if (optind + 2 > argc)
return COMMAND_ERROR_USAGE;
- src = strtoul_suffix(argv[optind], NULL, 0);
- dest = strtoul_suffix(argv[optind + 1], NULL, 0);
+ src = strtoull_suffix(argv[optind], NULL, 0);
+ dest = strtoull_suffix(argv[optind + 1], NULL, 0);
if (optind + 2 == argc) {
if (sourcefile == DEVMEM) {
@@ -438,7 +437,7 @@ static int do_mem_cp(int argc, char *argv[])
}
count = statbuf.st_size - src;
} else {
- count = strtoul_suffix(argv[optind + 2], NULL, 0);
+ count = strtoull_suffix(argv[optind + 2], NULL, 0);
}
sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src);
@@ -454,7 +453,7 @@ static int do_mem_cp(int argc, char *argv[])
while (count > 0) {
int now, r, w, tmp;
- now = min(RW_BUF_SIZE, count);
+ now = min((loff_t)RW_BUF_SIZE, count);
r = read(sourcefd, rw_buf, now);
if (r < 0) {
@@ -516,7 +515,7 @@ BAREBOX_CMD_END
static int do_memset(int argc, char *argv[])
{
- ulong s, c, n;
+ loff_t s, c, n;
int fd;
char *buf;
int mode = O_RWSIZE_1;
@@ -529,9 +528,9 @@ static int do_memset(int argc, char *argv[])
if (optind + 3 > argc)
return COMMAND_ERROR_USAGE;
- s = strtoul_suffix(argv[optind], NULL, 0);
- c = strtoul_suffix(argv[optind + 1], NULL, 0);
- n = strtoul_suffix(argv[optind + 2], NULL, 0);
+ s = strtoull_suffix(argv[optind], NULL, 0);
+ c = strtoull_suffix(argv[optind + 1], NULL, 0);
+ n = strtoull_suffix(argv[optind + 2], NULL, 0);
fd = open_and_lseek(file, mode | O_WRONLY, s);
if (fd < 0)
@@ -543,7 +542,7 @@ static int do_memset(int argc, char *argv[])
while (n > 0) {
int now;
- now = min(RW_BUF_SIZE, n);
+ now = min((loff_t)RW_BUF_SIZE, n);
ret = write(fd, buf, now);
if (ret < 0) {
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-06-26 19:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 19:54 [PATCH] 64bit file support Sascha Hauer
2012-06-26 19:54 ` [PATCH 01/10] mtd: fix arguments to bad block ioctls Sascha Hauer
2012-06-26 19:54 ` [PATCH 02/10] nand-bb: bb->offset may become a 64bit type Sascha Hauer
2012-06-26 19:54 ` [PATCH 03/10] use loff_t for file offsets Sascha Hauer
2012-06-26 19:54 ` [PATCH 04/10] introduce strtoull_suffix function Sascha Hauer
2012-06-26 19:54 ` [PATCH 05/10] make parse_area_spec arguments loff_t Sascha Hauer
2012-06-26 19:54 ` [PATCH 06/10] make memory display 64bit capable Sascha Hauer
2012-06-26 19:55 ` [PATCH 07/10] make st_size in struct stat 64 bit Sascha Hauer
2012-06-26 19:55 ` [PATCH 08/10] make cdev 64bit capable Sascha Hauer
2012-06-26 19:55 ` Sascha Hauer [this message]
2012-06-26 19:55 ` [PATCH 10/10] partitions: Make " Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340740503-7003-10-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox