tacme, sam: handle >1GB files correctly - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 219cf22d6863a21a7378fc5481bb05bbb6edd2dc
 (DIR) parent e78ed7a67bbaa37dc57dfb37219f505c48755e14
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Thu, 13 Mar 2014 18:46:28 -0400
       
       acme, sam: handle >1GB files correctly
       
       TBR=rsc
       https://codereview.appspot.com/74060043
       
       Diffstat:
         M src/cmd/acme/dat.h                  |       4 ++--
         M src/cmd/acme/disk.c                 |       3 +++
         M src/cmd/sam/disk.c                  |       3 +++
         M src/cmd/sam/sam.h                   |       4 ++--
       
       4 files changed, 10 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
       t@@ -69,7 +69,7 @@ struct Range
        
        struct Block
        {
       -        uint                addr;        /* disk address in bytes */
       +        vlong                addr;        /* disk address in bytes */
                union
                {
                        uint        n;                /* number of used runes in block */
       t@@ -80,7 +80,7 @@ struct Block
        struct Disk
        {
                int                fd;
       -        uint                addr;        /* length of temp file */
       +        vlong                addr;        /* length of temp file */
                Block        *free[Maxblock/Blockincr+1];
        };
        
 (DIR) diff --git a/src/cmd/acme/disk.c b/src/cmd/acme/disk.c
       t@@ -82,6 +82,9 @@ disknewblock(Disk *d, uint n)
                        b = blist;
                        blist = b->u.next;
                        b->addr = d->addr;
       +                if(d->addr+size < d->addr){
       +                        error("temp file overflow");
       +                }
                        d->addr += size;
                }
                b->u.n = n;
 (DIR) diff --git a/src/cmd/sam/disk.c b/src/cmd/sam/disk.c
       t@@ -75,6 +75,9 @@ disknewblock(Disk *d, uint n)
                        b = blist;
                        blist = b->u.next;
                        b->addr = d->addr;
       +                if(d->addr+size < d->addr){
       +                        panic("temp file overflow");
       +                }
                        d->addr += size;
                }
                b->u.n = n;
 (DIR) diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h
       t@@ -113,7 +113,7 @@ enum
        
        struct Block
        {
       -        uint                addr;        /* disk address in bytes */
       +        vlong                addr;        /* disk address in bytes */
                union {
                        uint        n;        /* number of used runes in block */
                        Block        *next;        /* pointer to next in free list */
       t@@ -123,7 +123,7 @@ struct Block
        struct Disk
        {
                int                fd;
       -        uint                addr;        /* length of temp file */
       +        vlong                addr;        /* length of temp file */
                Block                *free[Maxblock/Blockincr+1];
        };