tplan 9 import - 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 38c7eb9bd22e05ef32998858b178edaf8269cbab
 (DIR) parent 3bff492520ffc551fe1951ea6f0d806f837f05d5
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun, 21 May 2006 18:24:59 +0000
       
       plan 9 import
       
       Diffstat:
         M src/cmd/tapefs/32vfs.c              |      17 +++++++++++++----
         M src/cmd/tapefs/fs.c                 |       1 +
         M src/cmd/tapefs/tapefs.h             |       6 +++++-
         M src/cmd/tapefs/tarfs.c              |       2 +-
       
       4 files changed, 20 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/tapefs/32vfs.c b/src/cmd/tapefs/32vfs.c
       t@@ -20,9 +20,11 @@
        #define        VSUPERB        1
        #define        VROOT                2        /* root inode */
        #define        VNAMELEN        14
       -#define        BLSIZE        512
       +#define        MAXBLSIZE        1024
       +int        BLSIZE;
        #define        LINOPB        (BLSIZE/sizeof(struct v32dinode))
       -#define        LNINDIR        (BLSIZE/sizeof(unsigned long))
       +#define        LNINDIR        (BLSIZE/4)
       +#define        MAXLNINDIR        (MAXBLSIZE/4)
        
        struct v32dinode {
                unsigned char flags[2];
       t@@ -51,6 +53,13 @@ populate(char *name)
        {
                Fileinf f;
        
       +        BLSIZE = 512;        /* 32v */
       +        if(blocksize){
       +                /* 1024 for 4.1BSD */
       +                if(blocksize != 512 && blocksize != 1024)
       +                        error("bad block size");
       +                BLSIZE = blocksize;
       +        }
                replete = 0;
                tapefile = open(name, OREAD);
                if (tapefile<0)
       t@@ -106,7 +115,7 @@ docreate(Ram *r)
        char *
        doread(Ram *r, vlong off, long cnt)
        {
       -        static char buf[Maxbuf+BLSIZE];
       +        static char buf[Maxbuf+MAXBLSIZE];
                int bno, i;
        
                bno = off/BLSIZE;
       t@@ -147,7 +156,7 @@ dopermw(Ram *r)
        Fileinf
        iget(int ino)
        {
       -        char buf[BLSIZE];
       +        char buf[MAXBLSIZE];
                struct v32dinode *dp;
                long flags, i;
                Fileinf f;
 (DIR) diff --git a/src/cmd/tapefs/fs.c b/src/cmd/tapefs/fs.c
       t@@ -16,6 +16,7 @@ ulong        path;
        Idmap        *uidmap;
        Idmap        *gidmap;
        int        replete;
       +int        blocksize;                /* for 32v */
        int        verbose;
        int        newtap;                /* tap with time in sec */
        
 (DIR) diff --git a/src/cmd/tapefs/tapefs.h b/src/cmd/tapefs/tapefs.h
       t@@ -3,7 +3,10 @@
        #define        g2byte(x)        (((x)[1]<<8) + (x)[0])                /* little-endian */
        #define        g3byte(x)        (((x)[2]<<16) + ((x)[1]<<8) + (x)[0])
        #define        g4byte(x)        (((x)[3]<<24) + ((x)[2]<<16) + ((x)[1]<<8) + (x)[0])
       -#define        g8byte(x)        (((vlong)g4byte(x)<<32) | (u32int)g4byte(x+4))
       +
       +/* big endian */
       +#define        b4byte(x)        (((x)[0]<<24) + ((x)[1]<<16) + ((x)[2]<<8) + (x)[3])
       +#define        b8byte(x)        (((vlong)b4byte(x)<<32) | (u32int)b4byte((x)+4))
        
        enum
        {
       t@@ -78,6 +81,7 @@ extern        char        *user;
        extern        Idmap        *uidmap;
        extern        Idmap        *gidmap;
        extern        int        replete;
       +extern        int        blocksize;
        void        error(char*);
        void        *erealloc(void*, ulong);
        void        *emalloc(ulong);
 (DIR) diff --git a/src/cmd/tapefs/tarfs.c b/src/cmd/tapefs/tarfs.c
       t@@ -53,7 +53,7 @@ populate(char *name)
                        f.uid = strtoul(dblock.dbuf.uid, 0, 8);
                        f.gid = strtoul(dblock.dbuf.gid, 0, 8);
                        if((uchar)dblock.dbuf.size[0] == 0x80)
       -                        f.size = g8byte(dblock.dbuf.size+3);
       +                        f.size = b8byte(dblock.dbuf.size+3);
                        else
                                f.size = strtoull(dblock.dbuf.size, 0, 8);
                        f.mdate = strtoul(dblock.dbuf.mtime, 0, 8);