From: Nathan Scott Date: Sat, 8 Oct 2005 03:47:58 +0000 (+0000) Subject: Fix read/write calls in xfs_io to allow buffers larger than 4GiB on 64 bit platforms. X-Git-Tag: v2.8.0~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c2f6d79acfb71285478ad6c302da391d21aeb89;p=thirdparty%2Fxfsprogs-dev.git Fix read/write calls in xfs_io to allow buffers larger than 4GiB on 64 bit platforms. Merge of master-melb:xfs-cmds:24039a by kenmcd. --- diff --git a/include/input.h b/include/input.h index be2bf7413..9da22c80f 100644 --- a/include/input.h +++ b/include/input.h @@ -41,8 +41,7 @@ extern char **breakline(char *input, int *count); extern void doneline(char *input, char **vec); extern char *fetchline(void); -extern long long cvtnum(unsigned int blocksize, - unsigned int sectorsize, char *s); +extern long long cvtnum(size_t blocksize, size_t sectorsize, char *s); extern void cvtstr(double value, char *str, size_t sz); extern unsigned long cvttime(char *s); diff --git a/io/fadvise.c b/io/fadvise.c index 429f4f57a..44ff1557b 100644 --- a/io/fadvise.c +++ b/io/fadvise.c @@ -97,7 +97,7 @@ fadvise_f( } } if (range) { - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; if (optind != argc - 2) return command_usage(&fadvise_cmd); diff --git a/io/init.c b/io/init.c index d1947d630..bf73a8aeb 100644 --- a/io/init.c +++ b/io/init.c @@ -53,8 +53,8 @@ usage(void) void init_cvtnum( - unsigned int *blocksize, - unsigned int *sectsize) + size_t *blocksize, + size_t *sectsize) { if (!file || (file->flags & IO_FOREIGN)) { *blocksize = 4096; diff --git a/io/init.h b/io/init.h index bc87165d2..7838acd99 100644 --- a/io/init.h +++ b/io/init.h @@ -42,4 +42,4 @@ extern struct timeval stopwatch; #define min(a,b) (((a)<(b))?(a):(b)) -extern void init_cvtnum(unsigned int *blocksize, unsigned int *sectsize); +extern void init_cvtnum(size_t *blocksize, size_t *sectsize); diff --git a/io/io.h b/io/io.h index 656fb243b..997452f9d 100644 --- a/io/io.h +++ b/io/io.h @@ -85,8 +85,8 @@ extern unsigned int recurse_all; extern unsigned int recurse_dir; extern void *buffer; -extern ssize_t buffersize; -extern int alloc_buffer(ssize_t, int, unsigned int); +extern size_t buffersize; +extern int alloc_buffer(size_t, int, unsigned int); extern int read_buffer(int, off64_t, long long, long long *, int, int); extern void dump_buffer(off64_t, ssize_t); diff --git a/io/madvise.c b/io/madvise.c index f52267810..db16675d3 100644 --- a/io/madvise.c +++ b/io/madvise.c @@ -70,7 +70,7 @@ madvise_f( size_t length; void *start; int advise = MADV_NORMAL, c; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; while ((c = getopt(argc, argv, "drsw")) != EOF) { switch (c) { diff --git a/io/mincore.c b/io/mincore.c index 24ffea64b..9bea55be9 100644 --- a/io/mincore.c +++ b/io/mincore.c @@ -46,11 +46,11 @@ mincore_f( { off64_t offset; size_t length; + size_t blocksize, sectsize; void *start; void *current, *previous; unsigned char *vec; int i; - unsigned int blocksize, sectsize; if (argc == 1) { offset = mapping->offset; diff --git a/io/mmap.c b/io/mmap.c index fd71bc73e..490ae44a2 100644 --- a/io/mmap.c +++ b/io/mmap.c @@ -171,7 +171,7 @@ mmap_f( ssize_t length; void *address; char *filename; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; int c, prot = 0; if (argc == 1) { @@ -287,7 +287,7 @@ msync_f( ssize_t length; void *start; int c, flags = 0; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; while ((c = getopt(argc, argv, "ais")) != EOF) { switch (c) { @@ -393,7 +393,7 @@ mread_f( char *bp; void *start; int dump = 0, rflag = 0, c; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; while ((c = getopt(argc, argv, "frv")) != EOF) { switch (c) { @@ -539,7 +539,7 @@ mwrite_f( int seed = 'X'; int rflag = 0; int c; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; while ((c = getopt(argc, argv, "rS:")) != EOF) { switch (c) { diff --git a/io/pread.c b/io/pread.c index 2ed1b9316..14dc3a0e3 100644 --- a/io/pread.c +++ b/io/pread.c @@ -57,12 +57,12 @@ pread_help(void) } void *buffer; -ssize_t highwater; -ssize_t buffersize; +size_t highwater; +size_t buffersize; int alloc_buffer( - ssize_t bsize, + size_t bsize, int uflag, unsigned int seed) { @@ -117,7 +117,8 @@ read_buffer( int verbose, int onlyone) { - ssize_t bytes, bytes_requested; + size_t bytes_requested; + ssize_t bytes; int ops = 0; *total = 0; @@ -148,8 +149,8 @@ pread_f( char **argv) { off64_t offset; - long long count, total; - unsigned int blocksize, sectsize; + long long count, total, tmp; + size_t blocksize, sectsize; struct timeval t1, t2; char s1[64], s2[64], ts[64]; int Cflag, uflag, vflag; @@ -160,11 +161,12 @@ pread_f( while ((c = getopt(argc, argv, "b:Cuv")) != EOF) { switch (c) { case 'b': - blocksize = cvtnum(blocksize, sectsize, optarg); - if (blocksize < 0) { + tmp = cvtnum(blocksize, sectsize, optarg); + if (tmp < 0) { printf(_("non-numeric bsize -- %s\n"), optarg); return 0; } + blocksize = tmp; break; case 'C': Cflag = 1; diff --git a/io/prealloc.c b/io/prealloc.c index 4c8dc889b..3f8bf51ce 100644 --- a/io/prealloc.c +++ b/io/prealloc.c @@ -47,7 +47,7 @@ offset_length( char *length, xfs_flock64_t *segment) { - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; init_cvtnum(&blocksize, §size); memset(segment, 0, sizeof(*segment)); diff --git a/io/pwrite.c b/io/pwrite.c index b3956f2a7..4c644c032 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -65,12 +65,13 @@ static int write_buffer( off64_t offset, long long count, - ssize_t bs, + size_t bs, int fd, off64_t skip, long long *total) { - ssize_t bytes, bytes_requested; + size_t bytes_requested; + ssize_t bytes; long long bar = min(bs, count); int ops = 0; @@ -103,10 +104,10 @@ pwrite_f( int argc, char **argv) { + size_t blocksize, sectsize; off64_t offset, skip = 0; - long long count, total; + long long count, total, tmp; unsigned int seed = 0xcdcdcdcd; - unsigned int blocksize, sectsize; struct timeval t1, t2; char s1[64], s2[64], ts[64]; char *sp, *infile = NULL; @@ -118,11 +119,12 @@ pwrite_f( while ((c = getopt(argc, argv, "b:Cdf:i:s:S:uwW")) != EOF) { switch (c) { case 'b': - blocksize = cvtnum(blocksize, sectsize, optarg); - if (blocksize < 0) { + tmp = cvtnum(blocksize, sectsize, optarg); + if (tmp < 0) { printf(_("non-numeric bsize -- %s\n"), optarg); return 0; } + blocksize = tmp; break; case 'C': Cflag = 1; diff --git a/io/sendfile.c b/io/sendfile.c index 3a5fbdcee..ddcb33fab 100644 --- a/io/sendfile.c +++ b/io/sendfile.c @@ -94,7 +94,7 @@ sendfile_f( { off64_t offset = 0; long long count, total; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; struct timeval t1, t2; char s1[64], s2[64], ts[64]; char *infile = NULL; diff --git a/io/truncate.c b/io/truncate.c index ce525dbe2..0bbc7260f 100644 --- a/io/truncate.c +++ b/io/truncate.c @@ -44,7 +44,7 @@ truncate_f( char **argv) { off64_t offset; - unsigned int blocksize, sectsize; + size_t blocksize, sectsize; init_cvtnum(&blocksize, §size); offset = cvtnum(blocksize, sectsize, argv[1]); diff --git a/libxcmd/input.c b/libxcmd/input.c index 37bd8fb05..f61e0ca13 100644 --- a/libxcmd/input.c +++ b/libxcmd/input.c @@ -155,8 +155,8 @@ doneline( long long cvtnum( - unsigned int blocksize, - unsigned int sectorsize, + size_t blocksize, + size_t sectorsize, char *s) { long long i;