]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Fix read/write calls in xfs_io to allow buffers larger than 4GiB on 64 bit platforms.
authorNathan Scott <nathans@sgi.com>
Sat, 8 Oct 2005 03:47:58 +0000 (03:47 +0000)
committerNathan Scott <nathans@sgi.com>
Sat, 8 Oct 2005 03:47:58 +0000 (03:47 +0000)
Merge of master-melb:xfs-cmds:24039a by kenmcd.

14 files changed:
include/input.h
io/fadvise.c
io/init.c
io/init.h
io/io.h
io/madvise.c
io/mincore.c
io/mmap.c
io/pread.c
io/prealloc.c
io/pwrite.c
io/sendfile.c
io/truncate.c
libxcmd/input.c

index be2bf74132763e2b3340d526331be8c35354e203..9da22c80f07dceb5a856836c900113ce2a161720 100644 (file)
@@ -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);
 
index 429f4f57a202866b8c0a9a78ecf56ac5954f3d76..44ff1557bfdf109988a16d03b22c54bfeb603dd9 100644 (file)
@@ -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);
index d1947d6304695953c58fb35a96eb161645509eae..bf73a8aebc35dd35be80d4d36ee9497325ebf3cc 100644 (file)
--- 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;
index bc87165d23dc3d1614c651c9f1aac9eead76ccbc..7838acd9903e69e4f4ce5114582d0341f2c76559 100644 (file)
--- 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 656fb243bc9566ca4286e9239e9fc4a77940bf6b..997452f9dd716ab68b923aa5da97eb8711c03c11 100644 (file)
--- 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);
index f5226781022ef3aa7e9ca6acd23cbfcabd1b28d5..db16675d37b060210b32361fcde2615f4e51211f 100644 (file)
@@ -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) {
index 24ffea64b6fc7d63af108173e0494fc80f7898a3..9bea55be9906ba84560f7f5fa67cbf6b91a6b5a7 100644 (file)
@@ -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;
index fd71bc73eddff33d4a54e0aece5dc73aa42e93e5..490ae44a21b032593bbe4d22c899bb1a9cbbe959 100644 (file)
--- 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) {
index 2ed1b9316a1abe7467019e91988d6eb83d49e7cc..14dc3a0e371455a59b77b9ec9256347d8975a108 100644 (file)
@@ -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;
index 4c8dc889bdbd9a3accd23fa135b73441afe5ff41..3f8bf51ce5878df5370b50c7ad1f01e94038db05 100644 (file)
@@ -47,7 +47,7 @@ offset_length(
        char            *length,
        xfs_flock64_t   *segment)
 {
-       unsigned int    blocksize, sectsize;
+       size_t          blocksize, sectsize;
 
        init_cvtnum(&blocksize, &sectsize);
        memset(segment, 0, sizeof(*segment));
index b3956f2a718d3ab1e165a61b5c42cca17c831b47..4c644c032e27a14ee6214457418a849f5337951d 100644 (file)
@@ -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;
index 3a5fbdceefd532184548b1ceb13ccddc3df9d667..ddcb33fab2ddcd6f10ae06e782c52c3f5431bac0 100644 (file)
@@ -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;
index ce525dbe2b5730ca764bbbc2a1b3fed7b6b3424b..0bbc7260f84187455f00161712fb766e80520e8e 100644 (file)
@@ -44,7 +44,7 @@ truncate_f(
        char            **argv)
 {
        off64_t         offset;
-       unsigned int    blocksize, sectsize;
+       size_t          blocksize, sectsize;
 
        init_cvtnum(&blocksize, &sectsize);
        offset = cvtnum(blocksize, sectsize, argv[1]);
index 37bd8fb05fdc7a4bea64b06e6661c4b58fd556af..f61e0ca13767f221c302dbe0a007199c59ca0a61 100644 (file)
@@ -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;