fileserver-largefile-support-20020107
authorR. Lindsay Todd <toddr@rpi.edu>
Tue, 7 Jan 2003 23:38:02 +0000 (23:38 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 7 Jan 2003 23:38:02 +0000 (23:38 +0000)
fileserver-side large file support

26 files changed:
acconfig.h
acinclude.m4
src/config/param.i386_linux24.h
src/dir/buffer.c
src/dir/test/dtest.c
src/dir/test/physio.c
src/viced/afsfileprocs.c
src/viced/physio.c
src/viced/viced.c
src/vol/ihandle.c
src/vol/ihandle.h
src/vol/namei_ops.c
src/vol/namei_ops.h
src/vol/partition.c
src/vol/partition.h
src/vol/physio.c
src/vol/viceinode.h
src/vol/vnode.h
src/vol/vol-info.c
src/vol/vol-salvage.c
src/vol/volume.c
src/vol/volume.h
src/volser/dumpstuff.c
src/volser/physio.c
src/volser/restorevol.c
src/volser/volprocs.c

index 76d8b62..bc8f4c5 100644 (file)
@@ -22,6 +22,7 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
 #endif
 
 #undef AFS_AFSDB_ENV
+#undef AFS_LARGEFILE_ENV
 #undef AFS_NAMEI_ENV
 
 #undef BITMAP_LATER
index 1360936..b49aca4 100644 (file)
@@ -23,6 +23,8 @@ AC_ARG_ENABLE( bos-restricted-mode,
 [  --enable-bos-restricted-mode        enable bosserver restricted mode which disables certain bosserver functionality],, enable_bos_restricted_mode="no")
 AC_ARG_ENABLE( bos-new-config,
 [  --enable-bos-new-config             enable bosserver pickup of BosConfig.new on restarts],, enable_bos_new_config="no")
+AC_ARG_ENABLE( largefile-fileserver,
+[  --enable-largefile-filesever         enable large file support in fileserver],, enable_largefile_fileserver="no")
 AC_ARG_ENABLE( namei-fileserver,
 [  --enable-namei-fileserver           force compilation of namei fileserver in preference to inode fileserver],, enable_namei_fileserver="no")
 AC_ARG_ENABLE( fast-restart,
@@ -584,6 +586,10 @@ if test "$enable_bos_new_config" = "yes"; then
        AC_DEFINE(BOS_NEW_CONFIG, 1, [define if you want to enable automatic renaming of BosConfig.new to BosConfig at startup])
 fi
 
+if test "$enable_largefile_fileserver" = "yes"; then
+       AC_DEFINE(AFS_LARGEFILE_ENV)
+fi
+
 if test "$enable_namei_fileserver" = "yes"; then
        AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
 fi
index a22fb79..1d3c339 100644 (file)
 #define AFS_64BIT_ENV          1
 #define AFS_64BIT_CLIENT       1
 
+#ifdef AFS_LARGEFILE_ENV
+#define _FILE_OFFSET_BITS      64
+#endif
+
+
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #include <linux/config.h>
 #ifdef CONFIG_SMP
index 0d0549e..cbb2e5e 100644 (file)
@@ -184,7 +184,7 @@ DRead(fid, page)
     ObtainWriteLock(&tb->lock);
     tb->lockers++;
     ReleaseWriteLock(&afs_bufferLock);
-    if (ReallyRead(tb->fid,tb->page,tb->data)) {
+    if (ReallyRead(tb->fid, (afs_size_t) tb->page,tb->data)) {
        tb->lockers--;
         FidZap(tb->fid);       /* disaster */
        ReleaseWriteLock(&tb->lock);
@@ -261,7 +261,7 @@ newslot (afid, apage, lp)
      * and the afs_bufferLock prevents other threads from zapping this
      * buffer while we are writing it out */
     if (lp->dirty) {
-        if (ReallyWrite(lp->fid,lp->page,lp->data)) Die("writing bogus buffer");
+        if (ReallyWrite(lp->fid, (afs_size_t) lp->page,lp->data)) Die("writing bogus buffer");
         lp->dirty = 0;
     }
 
@@ -336,7 +336,7 @@ DFlushVolume (vid)
         if (FidVolEq(tb->fid,vid)) {
            ObtainWriteLock(&tb->lock);
            if (tb->dirty) {
-               code = ReallyWrite(tb->fid, tb->page, tb->data);
+               code = ReallyWrite(tb->fid, (afs_size_t) tb->page, tb->data);
                if (code && !rcode)
                    rcode = code;
                tb->dirty = 0;
@@ -361,7 +361,7 @@ DFlushEntry (fid)
         if (FidEq(tb->fid, fid) && tb->dirty) {
            ObtainWriteLock(&tb->lock);
            if (tb->dirty) {
-               code = ReallyWrite(tb->fid, tb->page, tb->data);
+               code = ReallyWrite(tb->fid, (afs_size_t) tb->page, tb->data);
                if (code) {
                    ReleaseWriteLock(&tb->lock);
                    ReleaseReadLock(&afs_bufferLock);
@@ -392,7 +392,7 @@ DFlush ()
            (*tbp)->lockers++;
            ReleaseReadLock(&afs_bufferLock);
            if ((*tbp)->dirty) {
-               code = ReallyWrite((*tbp)->fid, (*tbp)->page, (*tbp)->data);
+               code = ReallyWrite((*tbp)->fid, (afs_size_t) (*tbp)->page, (*tbp)->data);
                if (!code)
                    (*tbp)->dirty = 0; /* Clear the dirty flag */
                if (code && !rcode) {
index 59a9bca..4cf7af8 100644 (file)
@@ -202,7 +202,7 @@ CreateDir(name, dir)
 
 ReallyRead(dir, block, data)
     dirhandle *dir;
-    int block;
+    afs_size_t block;
     char *data;
 {
     int code;
@@ -218,7 +218,7 @@ ReallyRead(dir, block, data)
 
 ReallyWrite(dir, block, data)
     dirhandle *dir;
-    int block;
+    afs_size_t block;
     char *data;
 {
     int code;
index f6cf803..b61da50 100644 (file)
@@ -45,7 +45,7 @@ RCSID("$Header$");
 
 ReallyRead(fid, block, data)
     long *fid;         /* View the fid as longs. */
-    long block;
+    afs_size_t block;
     char *data;
     {/* Do a real read. */
     char fname[100];
@@ -53,9 +53,9 @@ ReallyRead(fid, block, data)
     sprintf(fname, "F%d", *fid);
     s = open(fname,O_RDONLY,0644);
     if (s<0) Die("can't open cache file");
-    code=lseek(s,PAGESIZE*block,0);
+    code=lseek(s,(off_t)(PAGESIZE*block),0);
     if (code<0) Die("r:lseek");
-    code=read(s,data,PAGESIZE);
+    code=read(s,data,(size_t)PAGESIZE);
     if (code<0) {
        Die("read");
     }
@@ -65,7 +65,7 @@ ReallyRead(fid, block, data)
 
 ReallyWrite(fid, block, data)
     long *fid;         /* View the fid as longs. */
-    long block;
+    afs_size_t block;
     char *data;
     {/* Do a real write. */
     char fname[100];
@@ -73,9 +73,9 @@ ReallyWrite(fid, block, data)
     sprintf(fname, "F%d", *fid);
     s = open(fname,O_RDWR|O_CREAT,0644);
     if (s<0) Die("can't find cache file");
-    code = lseek(s,PAGESIZE*block,0);
+    code = lseek(s,(off_t)(PAGESIZE*block),0);
     if (code<0) Die("w:lseek");
-    code=write(s,data,PAGESIZE);
+    code=write(s,data,(size_t)PAGESIZE);
     if (code<0) Die("write");
     close(s);
     return 0;
index fff46f2..4f4c644 100644 (file)
@@ -199,12 +199,12 @@ afs_int32
 FetchData_RXStyle(Volume *volptr, 
                  Vnode *targetptr, 
                  register struct rx_call *Call,
-                 afs_int32 Pos,
-                 afs_int32 Len,
+                 afs_size_t Pos,
+                 afs_size_t Len,
                  afs_int32 Int64Mode,
 #if FS_STATS_DETAILED
-                 afs_int32 *a_bytesToFetchP,
-                 afs_int32 *a_bytesFetchedP
+                 afs_size_t *a_bytesToFetchP,
+                 afs_size_t *a_bytesFetchedP
 #endif /* FS_STATS_DETAILED */
                  );
 
@@ -214,13 +214,13 @@ StoreData_RXStyle(Volume *volptr,
                  struct AFSFid *Fid,
                  struct client *client,
                  register struct rx_call *Call,
-                 afs_uint32 Pos,
-                 afs_uint32 Length,
-                 afs_uint32 FileLength,
+                 afs_offs_t Pos,
+                 afs_offs_t Length,
+                 afs_offs_t FileLength,
                  int sync,
 #if FS_STATS_DETAILED
-                 afs_int32 *a_bytesToStoreP,
-                 afs_int32 *a_bytesStoredP
+                 afs_size_t *a_bytesToStoreP,
+                 afs_size_t *a_bytesStoredP
 #endif /* FS_STATS_DETAILED */
                  );
 
@@ -1007,7 +1007,8 @@ static int CopyOnWrite(Vnode *targetptr, Volume *volptr)
     Inode      ino, nearInode;
     int                rdlen;
     int                wrlen;
-    register int size, length;
+    register afs_size_t size;
+    register int length;
     int ifd, ofd;
     char       *buff;
     int        rc;             /* return code */
@@ -1017,7 +1018,7 @@ static int CopyOnWrite(Vnode *targetptr, Volume *volptr)
 
     if (targetptr->disk.type ==        vDirectory) DFlush();   /* just in case? */
 
-    size = targetptr->disk.length;
+    VN_GET_LEN(size, targetptr);
     buff = (char *)malloc(COPYBUFFSIZE);
     if (buff == NULL) {
        return EIO;
@@ -1233,8 +1234,13 @@ DeleteTarget(Vnode *parentptr,
            }
        }
        VN_SET_INO(*targetptr, (Inode)0);
-       VAdjustDiskUsage(&errorCode, volptr,
-                       -(int)nBlocks((*targetptr)->disk.length), 0);
+       {
+           afs_size_t  adjLength;
+           VN_GET_LEN(adjLength, *targetptr);
+           VAdjustDiskUsage(&errorCode, volptr,
+                            -nBlocks(adjLength),
+                            (afs_size_t) 0);
+       }
     }
     
     (*targetptr)->changed_newTime = 1; /* Status change of deleted file/dir */
@@ -1272,7 +1278,8 @@ Update_ParentVnodeStatus(Vnode *parentptr,
 #endif /* FS_STATS_DETAILED */
                         )
 {
-    afs_uint32 newlength;      /* Holds new directory length */
+    afs_offs_t newlength;      /* Holds new directory length */
+    afs_offs_t parentLength;
     int errorCode;
 #if FS_STATS_DETAILED
     Date currDate;             /*Current date*/
@@ -1288,11 +1295,13 @@ Update_ParentVnodeStatus(Vnode *parentptr,
      * XXX But we still don't check the error since we're dealing with dirs here and really the increase
      * of a new entry would be too tiny to worry about failures (since we have all the existing cushion)
      */
-    if (nBlocks(newlength) != nBlocks(parentptr->disk.length))
+    VN_GET_LEN(parentLength, parentptr);
+    if (nBlocks(newlength) != nBlocks(parentLength)) {
        VAdjustDiskUsage(&errorCode, volptr, 
-                        (int)(nBlocks(newlength) - nBlocks(parentptr->disk.length)),
-                        (int)(nBlocks(newlength) - nBlocks(parentptr->disk.length)));
-    parentptr->disk.length = newlength;
+                        (nBlocks(newlength) - nBlocks(parentLength)),
+                        (nBlocks(newlength) - nBlocks(parentLength)));
+    }
+    VN_SET_LEN(parentptr, newlength);
 
 #if FS_STATS_DETAILED
     /*
@@ -1351,7 +1360,7 @@ Update_TargetVnodeStatus(Vnode *targetptr,
                         AFSStoreStatus *InStatus,
                         Vnode *parentptr,
                         Volume *volptr,
-                        afs_int32 length)
+                        afs_size_t length)
 {
 #if FS_STATS_DETAILED
     Date currDate;             /*Current date*/
@@ -1361,7 +1370,7 @@ Update_TargetVnodeStatus(Vnode *targetptr,
 
     if (Caller & (TVS_CFILE|TVS_SLINK|TVS_MKDIR))      {   /* initialize new file */
        targetptr->disk.parent = parentptr->vnodeNumber;
-       targetptr->disk.length = length;
+       VN_SET_LEN(targetptr, length);
        /* targetptr->disk.group =      0;  save some cycles */
        targetptr->disk.modeBits = 0777;
        targetptr->disk.owner = client->ViceId;
@@ -1506,14 +1515,14 @@ SetCallBackStruct(afs_uint32 CallBackTime, struct AFSCallBack *CallBack)
  * enough space before consuming some.
  */
 static afs_int32
-AdjustDiskUsage(Volume *volptr, afs_int32 length, afs_int32 checkLength)
+AdjustDiskUsage(Volume *volptr, afs_size_t length, afs_size_t checkLength)
 {
     int rc;
     int nc;
 
     VAdjustDiskUsage(&rc, volptr, length, checkLength);
     if (rc) {
-       VAdjustDiskUsage(&nc, volptr, -length, 0);
+       VAdjustDiskUsage(&nc, volptr, -length, (afs_size_t) 0);
        if (rc == VOVERQUOTA) {
            ViceLog(2,("Volume %u (%s) is full\n",
                    V_id(volptr), V_name(volptr)));
@@ -1543,7 +1552,7 @@ Alloc_NewVnode(Vnode *parentptr,
               char *Name,
               struct AFSFid *OutFid,
               int FileType,
-              int BlocksPreallocatedForVnode)
+              afs_size_t BlocksPreallocatedForVnode)
 {
     int        errorCode = 0;          /* Error code returned back */
     int temp;
@@ -1559,7 +1568,8 @@ Alloc_NewVnode(Vnode *parentptr,
 
     *targetptr = VAllocVnode(&errorCode, volptr, FileType);
     if (errorCode != 0) {
-       VAdjustDiskUsage(&temp, volptr, - BlocksPreallocatedForVnode, 0);
+       VAdjustDiskUsage(&temp, volptr, - BlocksPreallocatedForVnode,
+                        (afs_size_t) 0);
        return(errorCode);
     }
     OutFid->Volume = V_id(volptr);
@@ -1581,7 +1591,8 @@ Alloc_NewVnode(Vnode *parentptr,
                          (*targetptr)->volumePtr->header->diskstuff.id,
                          (*targetptr)->vnodeNumber, 
                          errno));
-               VAdjustDiskUsage(&temp, volptr, -BlocksPreallocatedForVnode,0);
+               VAdjustDiskUsage(&temp, volptr, -BlocksPreallocatedForVnode,
+                                (afs_size_t) 0);
                (*targetptr)->delete = 1; /* delete vnode */
                return ENOSPC;
     }
@@ -1600,7 +1611,7 @@ Alloc_NewVnode(Vnode *parentptr,
                /* delete the vnode previously allocated */
                (*targetptr)->delete = 1;
                VAdjustDiskUsage(&temp, volptr,
-                                -BlocksPreallocatedForVnode, 0);
+                                -BlocksPreallocatedForVnode, (afs_size_t) 0);
                IH_REALLYCLOSE((*targetptr)->handle);
                if ( IH_DEC(V_linkHandle(volptr), inode, V_parentId(volptr)) )
                    ViceLog(0,("Alloc_NewVnode: partition %s idec %s failed\n",
@@ -1616,7 +1627,8 @@ Alloc_NewVnode(Vnode *parentptr,
     SetDirHandle(dir, parentptr);
     if ((errorCode = Create(dir,(char *)Name, OutFid))) {
        (*targetptr)->delete = 1;
-       VAdjustDiskUsage(&temp, volptr, - BlocksPreallocatedForVnode, 0);
+       VAdjustDiskUsage(&temp, volptr, - BlocksPreallocatedForVnode,
+                        (afs_size_t) 0);
        IH_REALLYCLOSE((*targetptr)->handle);
        if ( IH_DEC(V_linkHandle(volptr), inode, V_parentId(volptr)))
            ViceLog(0,("Alloc_NewVnode: partition %s idec %s failed\n",
@@ -1964,8 +1976,7 @@ void GetStatus(Vnode *targetptr,
     else
        status->FileType = Invalid;                     /*invalid type field */
     status->LinkCount = targetptr->disk.linkCount;
-    status->Length_hi = 0;
-    status->Length = targetptr->disk.length;
+    SET_STATUS_LEN(status, targetptr);
     status->DataVersion = targetptr->disk.dataVersion;
     status->Author = targetptr->disk.author;
     status->Owner = targetptr->disk.owner;
@@ -1985,8 +1996,8 @@ void GetStatus(Vnode *targetptr,
 static
 afs_int32 common_FetchData64 (struct rx_call *acall, 
                              struct AFSFid *Fid,    
-                             afs_int32 Pos,         
-                             afs_int32 Len,         
+                             afs_size_t Pos,         
+                             afs_size_t Len,         
                              struct AFSFetchStatus *OutStatus,
                              struct AFSCallBack *CallBack,
                              struct AFSVolSync *Sync,
@@ -2011,8 +2022,8 @@ afs_int32 common_FetchData64 (struct rx_call *acall,
     struct timeval xferStartTime,
                    xferStopTime;           /* Start/stop times for xfer portion*/
     struct timeval elapsedTime;                    /* Transfer time */
-    afs_int32 bytesToXfer;                         /* # bytes to xfer*/
-    afs_int32 bytesXferred;                        /* # bytes actually xferred*/
+    afs_size_t bytesToXfer;                        /* # bytes to xfer*/
+    afs_size_t bytesXferred;                       /* # bytes actually xferred*/
     int readIdx;                           /* Index of read stats array to bump*/
     static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
 
@@ -2095,10 +2106,13 @@ afs_int32 common_FetchData64 (struct rx_call *acall,
 
     /* actually do the data transfer */
 #if FS_STATS_DETAILED
-    errorCode = FetchData_RXStyle(volptr, targetptr, acall, Pos, Len, type,
+    errorCode = FetchData_RXStyle(volptr, targetptr, acall,
+                                 (afs_size_t) Pos, (afs_size_t) Len, type,
                                  &bytesToXfer, &bytesXferred);
 #else
-    if ((errorCode = FetchData_RXStyle(volptr, targetptr, acall, Pos, Len, type)))
+    if ((errorCode = FetchData_RXStyle(volptr, targetptr, acall,
+                                      (afs_size_t) Pos, (afs_size_t) Len,
+                                      type)))
        goto Bad_FetchData;
 #endif /* FS_STATS_DETAILED */
 
@@ -2217,7 +2231,7 @@ Bad_FetchData:
     osi_auditU (acall, FetchDataEvent, errorCode, AUD_FID, Fid, AUD_END);
     return(errorCode);
 
-} /*SRXAFS_FetchData*/
+} /*common_FetchData64*/
 
 afs_int32 SRXAFS_FetchData (struct rx_call *acall,   
                            struct AFSFid *Fid,      
@@ -2230,8 +2244,10 @@ afs_int32 SRXAFS_FetchData (struct rx_call *acall,
 {
     int code;
 
-    code = common_FetchData64 (acall, Fid, Pos, Len, OutStatus,
-                            CallBack, Sync, 0);
+    code = common_FetchData64 (acall, Fid,
+                              (afs_size_t) Pos, (afs_size_t) Len,
+                              OutStatus,
+                              CallBack, Sync, 0);
     return code;
 }
 
@@ -2244,11 +2260,13 @@ afs_int32 SRXAFS_FetchData64 (struct rx_call *acall,
                              struct AFSVolSync *Sync)
 {
     int code;
-    afs_int32 tPos, tLen;
+    afs_size_t tPos, tLen;
 
 #ifdef AFS_64BIT_ENV
+#ifndef AFS_LARGEFILE_ENV
     if (Pos + Len > 0x7fffffff)
         return E2BIG;
+#endif  /* !AFS_LARGEFILE_ENV */
     tPos = Pos;
     tLen = Len;
 #else /* AFS_64BIT_ENV */
@@ -2782,15 +2800,15 @@ Bad_FetchStatus:
 
 } /*SRXAFS_FetchStatus*/
 
-
-afs_int32 SRXAFS_StoreData (struct rx_call *acall,             
-                           struct AFSFid *Fid,                 
-                           struct AFSStoreStatus *InStatus,    
-                           afs_uint32 Pos,                     
-                           afs_uint32 Length,                  
-                           afs_uint32 FileLength,              
-                           struct AFSFetchStatus *OutStatus,   
-                           struct AFSVolSync *Sync)
+static
+afs_int32 common_StoreData64 (struct rx_call *acall,
+                             struct AFSFid *Fid,               
+                             struct AFSStoreStatus *InStatus,  
+                             afs_offs_t Pos,                   
+                             afs_offs_t Length,                
+                             afs_offs_t FileLength,            
+                             struct AFSFetchStatus *OutStatus, 
+                             struct AFSVolSync *Sync)
 {
     Vnode * targetptr =        0;              /* pointer to input fid */
     Vnode * parentwhentargetnotdir = 0;        /* parent of Fid to get ACL */
@@ -2811,8 +2829,8 @@ afs_int32 SRXAFS_StoreData (struct rx_call *acall,
     struct timeval xferStartTime,
                    xferStopTime;           /* Start/stop times for xfer portion*/
     struct timeval elapsedTime;                    /* Transfer time */
-    afs_int32 bytesToXfer;                         /* # bytes to xfer */
-    afs_int32 bytesXferred;                        /* # bytes actually xfer */
+    afs_size_t bytesToXfer;                        /* # bytes to xfer */
+    afs_size_t bytesXferred;                       /* # bytes actually xfer */
     static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
 
     /*
@@ -2843,6 +2861,22 @@ afs_int32 SRXAFS_StoreData (struct rx_call *acall,
     ViceLog(5, ("StoreData: Fid = %u.%d.%d, Host %s, Id %d\n",
            Fid->Volume, Fid->Vnode, Fid->Unique,
            inet_ntoa(logHostAddr), t_client->ViceId));
+#ifdef AFS_LARGEFILE_ENV
+    ViceLog(25, ("StoreData: Fid = %u.%d.%d, Host %s, Id %d, Pos (0X%x,0X%x), Len (0X%x,0X%x), FileLen (0X%x,0X%x)\n",
+               Fid->Volume, Fid->Vnode, Fid->Unique,
+               inet_ntoa(logHostAddr), t_client->ViceId,
+               (unsigned) (Pos >> 32), (unsigned) (Pos & 0xffffffff),
+               (unsigned) (Length >> 32), (unsigned) (Length & 0xffffffff),
+               (unsigned) (FileLength >> 32), (unsigned) (FileLength & 0xffffffff)));
+#else /* !AFS_LARGEFILE_ENV */
+    ViceLog(25, ("StoreData: Fid = %u.%d.%d, Host %s, Id %d, Pos 0X%x, Len 0X%x, FileLen 0X%x\n",
+               Fid->Volume, Fid->Vnode, Fid->Unique,
+               inet_ntoa(logHostAddr), t_client->ViceId,
+               Pos,
+               Length,
+               FileLength));
+#endif /* !AFS_LARGEFILE_ENV */
+               
 
     /*
      * Get associated volume/vnode for the stored file; caller's rights
@@ -2892,13 +2926,16 @@ afs_int32 SRXAFS_StoreData (struct rx_call *acall,
     /* Do the actual storing of the data */
 #if FS_STATS_DETAILED
     errorCode = StoreData_RXStyle(volptr, targetptr, Fid, client, acall,
-                                 Pos, Length, FileLength,
+                                 (afs_size_t) Pos, (afs_size_t) Length,
+                                 (afs_size_t) FileLength,
                                  (InStatus->Mask & AFS_FSYNC),
                                  &bytesToXfer, &bytesXferred);
 #else
     errorCode = StoreData_RXStyle(volptr, targetptr, Fid, client,
-                                     acall, Pos, Length, FileLength,
-                                     (InStatus->Mask & AFS_FSYNC));
+                                 acall,
+                                 (afs_size_t) Pos, (afs_size_t) Length,
+                                 (afs_size_t) FileLength,
+                                 (InStatus->Mask & AFS_FSYNC));
     if (errorCode && (!targetptr->changed_newTime))
            goto Bad_StoreData;
 #endif /* FS_STATS_DETAILED */
@@ -2979,7 +3016,7 @@ afs_int32 SRXAFS_StoreData (struct rx_call *acall,
 
     /* Update the status of the target's vnode */
     Update_TargetVnodeStatus(targetptr, TVS_SDATA, client, InStatus, targetptr,
-                            volptr, 0);
+                            volptr, (afs_size_t) 0);
 
     /* Get the updated File's status back to the caller */
     GetStatus(targetptr, OutStatus, rights, anyrights, &tparentwhentargetnotdir);
@@ -3012,6 +3049,23 @@ Bad_StoreData:
     osi_auditU (acall, StoreDataEvent, errorCode, AUD_FID, Fid, AUD_END);
     return(errorCode);
 
+} /*common_StoreData64*/
+
+afs_int32 SRXAFS_StoreData (struct rx_call *acall,             
+                           struct AFSFid *Fid,                 
+                           struct AFSStoreStatus *InStatus,    
+                           afs_uint32 Pos,                     
+                           afs_uint32 Length,                  
+                           afs_uint32 FileLength,              
+                           struct AFSFetchStatus *OutStatus,   
+                           struct AFSVolSync *Sync)
+{
+    int code;
+
+    code = common_StoreData64 (acall, Fid, InStatus, Pos, Length, FileLength,
+                             OutStatus, Sync);
+    return code;
+
 } /*SRXAFS_StoreData*/
 
 afs_int32 SRXAFS_StoreData64 (struct rx_call *acall,           
@@ -3024,13 +3078,15 @@ afs_int32 SRXAFS_StoreData64 (struct rx_call *acall,
                              struct AFSVolSync *Sync)
 {
     int code;
-    afs_int32 tPos;
-    afs_int32 tLength;
-    afs_int32 tFileLength;
+    afs_offs_t tPos;
+    afs_offs_t tLength;
+    afs_offs_t tFileLength;
 
 #ifdef AFS_64BIT_ENV
+#ifndef AFS_LARGEFILE_ENV
     if (FileLength > 0x7fffffff)
         return E2BIG;
+#endif /* !AFS_LARGEFILE_ENV */
     tPos = Pos;
     tLength = Length;
     tFileLength = FileLength;
@@ -3042,7 +3098,7 @@ afs_int32 SRXAFS_StoreData64 (struct rx_call *acall,
     tFileLength = FileLength.low;
 #endif /* AFS_64BIT_ENV */
 
-    code = SRXAFS_StoreData (acall, Fid, InStatus, tPos, tLength, tFileLength,
+    code = common_StoreData64 (acall, Fid, InStatus, tPos, tLength, tFileLength,
                              OutStatus, Sync);
     return code;
 }
@@ -3221,7 +3277,8 @@ SAFSS_StoreStatus (struct rx_call *acall,
     /* Update the status of the target's vnode */
     Update_TargetVnodeStatus(targetptr, TVS_SSTATUS, client, InStatus,
                             (parentwhentargetnotdir ?
-                             parentwhentargetnotdir : targetptr), volptr, 0);
+                             parentwhentargetnotdir : targetptr), volptr,
+                            (afs_size_t)0);
 
     /* convert the write lock to a read lock before breaking callbacks */
     VVnodeWriteToRead(&errorCode, targetptr);
@@ -3480,7 +3537,7 @@ SAFSS_CreateFile (struct rx_call *acall,
     int            errorCode = 0;              /* error code */
     DirHandle dir;                     /* Handle for dir package I/O */
     struct client * client;            /* pointer to client structure */
-    afs_int32 rights, anyrights;               /* rights for this and any user */
+    afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;            /* tmp ptr to client data */
     struct in_addr logHostAddr;                /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
@@ -3535,7 +3592,7 @@ SAFSS_CreateFile (struct rx_call *acall,
 
     /* update the status of the new file's vnode */
     Update_TargetVnodeStatus(targetptr, TVS_CFILE, client, InStatus,
-                            parentptr, volptr, 0);
+                            parentptr, volptr, (afs_size_t)0);
 
     /* set up the return status for the parent dir and the newly created file */
     GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
@@ -3901,8 +3958,10 @@ SAFSS_Rename (struct rx_call *acall,
        /* Drop the link count */
        newfileptr->disk.linkCount--;
        if (newfileptr->disk.linkCount == 0) {      /* Link count 0 - delete */
+           afs_size_t  newSize;
+           VN_GET_LEN(newSize, newfileptr);
            VAdjustDiskUsage(&errorCode, volptr,
-                            -(int)nBlocks(newfileptr->disk.length), 0);
+                            -nBlocks(newSize), (afs_size_t) 0);
            if (VN_GET_INO(newfileptr)) {
                IH_REALLYCLOSE(newfileptr->handle);
                errorCode = IH_DEC(V_linkHandle(volptr),
@@ -4196,7 +4255,7 @@ SAFSS_Symlink (struct rx_call *acall,
 
     /* update the status of the new symbolic link file vnode */
     Update_TargetVnodeStatus(targetptr, TVS_SLINK, client, InStatus, parentptr,
-                            volptr, strlen((char *)LinkContents));
+                            volptr, (afs_size_t)strlen((char *)LinkContents));
 
     /* Write the contents of the symbolic link name into the target inode */
     fdP = IH_OPEN(targetptr->handle);
@@ -4593,13 +4652,13 @@ SAFSS_MakeDir (struct rx_call *acall,
 
     /* update the status for the target vnode */
     Update_TargetVnodeStatus(targetptr, TVS_MKDIR, client, InStatus,
-                            parentptr, volptr, 0);
+                            parentptr, volptr, (afs_size_t)0);
 
     /* Actually create the New directory in the directory package */ 
     SetDirHandle(&dir, targetptr);
     assert(!(MakeDir(&dir, OutFid, DirFid)));
     DFlush();
-    targetptr->disk.length = Length(&dir);
+    VN_SET_LEN(targetptr, (afs_size_t) Length(&dir));
 
     /* set up return status */
     GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
@@ -6499,12 +6558,12 @@ afs_int32
 FetchData_RXStyle(Volume *volptr, 
                  Vnode *targetptr, 
                  register struct rx_call *Call,
-                 afs_int32 Pos,
-                 afs_int32 Len,
+                 afs_size_t Pos,
+                 afs_size_t Len,
                  afs_int32 Int64Mode,
 #if FS_STATS_DETAILED
-                 afs_int32 *a_bytesToFetchP,
-                 afs_int32 *a_bytesFetchedP
+                 afs_size_t *a_bytesToFetchP,
+                 afs_size_t *a_bytesFetchedP
 #endif /* FS_STATS_DETAILED */
                  )
 {
@@ -6519,7 +6578,7 @@ FetchData_RXStyle(Volume *volptr,
     struct iovec tiov[RX_MAXIOVECS];
     int tnio;
 #endif /* AFS_NT40_ENV */
-    afs_int32 tlen;
+    afs_size_t tlen;
     afs_int32 optSize;
     struct stat tstat;
 #ifdef AFS_AIX_ENV
@@ -6534,15 +6593,25 @@ FetchData_RXStyle(Volume *volptr,
     (*a_bytesFetchedP) = 0;
 #endif /* FS_STATS_DETAILED */
 
+#ifdef AFS_LARGEFILE_ENV
+    ViceLog(25, ("FetchData_RXStyle: Pos (0X%x,0X%x), Len (0X%x,0X%x)\n",
+                (unsigned) (Pos >> 32), (unsigned) (Pos & 0xffffffff),
+                (unsigned) (Len >> 32), (unsigned) (Len & 0xffffffff)));
+#else /* !AFS_LARGEFILE_ENV */
+    ViceLog(25, ("FetchData_RXStyle: Pos 0X%x, Len 0X%x\n",
+                (unsigned) Pos,
+                (unsigned) Len));
+#endif /* !AFS_LARGEFILE_ENV */
+
     if (!VN_GET_INO(targetptr)) {
+       afs_int32       zero = htonl(0);
        /*
         * This is used for newly created files; we simply send 0 bytes
         * back to make the cache manager happy...
         */
-       tlen = htonl(0);
         if (Int64Mode)
-            rx_Write(Call, (char *)&tlen, sizeof(afs_int32));   /* send 0-length  */
-       rx_Write(Call, (char *)&tlen, sizeof(afs_int32));       /* send 0-length  */
+            rx_Write(Call, (char *)&zero, sizeof(afs_int32));   /* send 0-length  */
+       rx_Write(Call, (char *)&zero, sizeof(afs_int32));       /* send 0-length  */
        return (0);
     }
     TM_GetTimeOfDay(&StartTime, 0);
@@ -6551,6 +6620,13 @@ FetchData_RXStyle(Volume *volptr,
     if (fdP == NULL) return EIO;
     optSize = sendBufSize;
     tlen = FDH_SIZE(fdP);
+#ifdef AFS_LARGEFILE_ENV
+    ViceLog( 25, ("FetchData_RXStyle: file size (0X%x,0X%x)\n",
+            (unsigned) (tlen >> 32), (unsigned) (tlen & 0xffffffff)));
+#else /* !AFS_LARGEFILE_ENV */
+    ViceLog( 25, ("FetchData_RXStyle: file size 0X%x\n",
+                 (unsigned) tlen));
+#endif /* !AFS_LARGEFILE_ENV */
     if (tlen < 0) {
        FDH_CLOSE(fdP);
        return EIO;
@@ -6558,12 +6634,17 @@ FetchData_RXStyle(Volume *volptr,
 
     if (Pos + Len > tlen) Len =        tlen - Pos;     /* get length we should send */
     FDH_SEEK(fdP, Pos, 0);
-    tlen = htonl(Len);
-    if (Int64Mode) {
-        afs_int32 zero = 0;
-        rx_Write(Call, (char *)&zero, sizeof(afs_int32)); /* High order bits */
+    {
+       afs_int32       high, low;
+       SplitInt64(Len, high, low);
+       assert(Int64Mode || high==0);
+       if (Int64Mode) {
+           high = htonl(high);
+           rx_Write(Call, (char *)&high, sizeof(afs_int32)); /* High order bits */
+       }
+       low = htonl(low);
+       rx_Write(Call, (char *)&low, sizeof(afs_int32));        /* send length on fetch */
     }
-    rx_Write(Call, (char *)&tlen, sizeof(afs_int32));  /* send length on fetch */
 #if FS_STATS_DETAILED
     (*a_bytesToFetchP) = Len;
 #endif /* FS_STATS_DETAILED */
@@ -6623,22 +6704,26 @@ FetchData_RXStyle(Volume *volptr,
        AFSCallStats.TotalFetchedBytes = AFSCallStats.AccumFetchTime = 0;
     AFSCallStats.AccumFetchTime += ((StopTime.tv_sec - StartTime.tv_sec) * 1000) +
       ((StopTime.tv_usec - StartTime.tv_usec) / 1000);
-    AFSCallStats.TotalFetchedBytes += targetptr->disk.length;
-    AFSCallStats.FetchSize1++;
-    if (targetptr->disk.length < SIZE2)
-       AFSCallStats.FetchSize2++;  
-    else if (targetptr->disk.length < SIZE3)
-       AFSCallStats.FetchSize3++;
-    else if (targetptr->disk.length < SIZE4)
-       AFSCallStats.FetchSize4++;  
-    else
-       AFSCallStats.FetchSize5++;
+    {
+       afs_size_t      targLen;
+       VN_GET_LEN(targLen, targetptr);
+       AFSCallStats.TotalFetchedBytes += targLen;
+       AFSCallStats.FetchSize1++;
+       if (targLen < SIZE2)
+           AFSCallStats.FetchSize2++;  
+       else if (targLen < SIZE3)
+           AFSCallStats.FetchSize3++;
+       else if (targLen < SIZE4)
+           AFSCallStats.FetchSize4++;  
+       else
+           AFSCallStats.FetchSize5++;
+    }
     FS_UNLOCK
     return (0);
 
 } /*FetchData_RXStyle*/
 
-static int GetLinkCountAndSize(Volume *vp, FdHandle_t *fdP, int *lc, int *size)
+static int GetLinkCountAndSize(Volume *vp, FdHandle_t *fdP, int *lc, afs_size_t *size)
 {
 #ifdef AFS_NAMEI_ENV
     FdHandle_t *lhp;
@@ -6693,17 +6778,17 @@ StoreData_RXStyle(Volume *volptr,
                  struct AFSFid *Fid,
                  struct client *client,
                  register struct rx_call *Call,
-                 afs_uint32 Pos,
-                 afs_uint32 Length,
-                 afs_uint32 FileLength,
+                 afs_offs_t Pos,
+                 afs_offs_t Length,
+                 afs_offs_t FileLength,
                  int sync,
 #if FS_STATS_DETAILED
-                 afs_int32 *a_bytesToStoreP,
-                 afs_int32 *a_bytesStoredP
+                 afs_size_t *a_bytesToStoreP,
+                 afs_size_t *a_bytesStoredP
 #endif /* FS_STATS_DETAILED */
                  )
 {
-    int            bytesTransfered;            /* number of bytes actually transfered */
+    afs_size_t bytesTransfered;                /* number of bytes actually transfered */
     struct timeval StartTime, StopTime;        /* Used to measure how long the store takes */
     int        errorCode = 0;                  /* Returned error code to caller */
 #ifdef AFS_NT40_ENV
@@ -6712,13 +6797,13 @@ StoreData_RXStyle(Volume *volptr,
     struct iovec tiov[RX_MAXIOVECS];    /* no data copying with iovec */
     int tnio;                          /* temp for iovec size */
 #endif /* AFS_NT40_ENV */
-    int        tlen;                           /* temp for xfr length */
+    afs_size_t tlen;                   /* temp for xfr length */
     Inode tinode;                      /* inode for I/O */
-    afs_int32 optSize;                 /* optimal transfer size */
-    int DataLength;                    /* size of inode */
-    afs_int32 TruncatedLength;         /* size after ftruncate */
-    afs_uint32 NewLength;              /* size after this store completes */
-    afs_int32 adjustSize;              /* bytes to call VAdjust... with */
+    afs_size_t optSize;                        /* optimal transfer size */
+    afs_size_t DataLength;             /* size of inode */
+    afs_size_t TruncatedLength;                /* size after ftruncate */
+    afs_offs_t NewLength;              /* size after this store completes */
+    afs_size_t adjustSize;             /* bytes to call VAdjust... with */
     int linkCount;                     /* link count on inode */
     int code;
     FdHandle_t *fdP;
@@ -6764,7 +6849,7 @@ StoreData_RXStyle(Volume *volptr,
        }
        
        if (linkCount != 1) {
-           afs_uint32 size;
+           afs_size_t size;
            ViceLog(25, ("StoreData_RXStyle : inode %s has more than onelink\n",
                         PrintInode(NULL, VN_GET_INO(targetptr))));
            /* other volumes share this data, better copy it first */
@@ -6776,7 +6861,7 @@ StoreData_RXStyle(Volume *volptr,
             * of the disk will be recorded...
             */
            FDH_CLOSE(fdP);
-           size = targetptr->disk.length;
+           VN_GET_LEN(size, targetptr);
            volptr->partition->flags &= ~PART_DONTUPDATE;
            VSetPartitionDiskUsage(volptr->partition);
            volptr->partition->flags |= PART_DONTUPDATE;
@@ -6814,7 +6899,11 @@ StoreData_RXStyle(Volume *volptr,
        NewLength = Pos+Length;   /* and write */
 
     /* adjust the disk block count by the difference in the files */
-    adjustSize = (int) (nBlocks(NewLength) - nBlocks(targetptr->disk.length));
+    {
+       afs_size_t      targSize;
+       VN_GET_LEN(targSize, targetptr);
+       adjustSize = nBlocks(NewLength) - nBlocks(targSize);
+    }
     if((errorCode = AdjustDiskUsage(volptr, adjustSize,
                                   adjustSize - SpareComp(volptr)))) {
        FDH_CLOSE(fdP);
@@ -6829,6 +6918,20 @@ StoreData_RXStyle(Volume *volptr,
 
     optSize = sendBufSize;
 
+#ifdef AFS_LARGEFILE_ENV
+    ViceLog(25, ("StoreData_RXStyle: Pos (0X%x,0X%x), DataLength (0X%x,0X%x), FileLength (0X%x,0X%x), Length (0X%x,0X%x)\n",
+                (unsigned) (Pos >> 32), (unsigned) (Pos & 0xffffffff),
+                (unsigned) (DataLength >> 32), (unsigned) (DataLength & 0xffffffff),
+                (unsigned) (FileLength >> 32), (unsigned) (FileLength & 0xffffffff),
+                (unsigned) (Length >> 32), (unsigned) (Length & 0xffffffff)));
+#else /* !AFS_LARGEFILE_ENV */
+    ViceLog(25, ("StoreData_RXStyle: Pos 0X%x, DataLength 0X%x, FileLength 0X%x, Length 0X%x\n",
+                (unsigned) Pos,
+                (unsigned) DataLength,
+                (unsigned) FileLength,
+                (unsigned) Length));
+#endif /* !AFS_LARGEFILE_ENV */
+
     /* truncate the file iff it needs it (ftruncate is slow even when its a noop) */
     if (FileLength < DataLength) FDH_TRUNC(fdP, FileLength);
     if (Pos > 0) FDH_SEEK(fdP, Pos, 0);
@@ -6896,8 +6999,9 @@ StoreData_RXStyle(Volume *volptr,
       FDH_SYNC(fdP);
     }
     if (errorCode) {
+       afs_size_t      nfSize = FDH_SIZE(fdP);
        /* something went wrong: adjust size and return */
-       targetptr->disk.length = FDH_SIZE(fdP); /* set new file size. */
+       VN_SET_LEN(targetptr, nfSize); /* set new file size. */
        /* changed_newTime is tested in StoreData to detemine if we
         * need to update the target vnode.
         */
@@ -6905,29 +7009,33 @@ StoreData_RXStyle(Volume *volptr,
        FDH_CLOSE(fdP);
        /* set disk usage to be correct */
        VAdjustDiskUsage(&errorCode, volptr,
-                        (int)(nBlocks(targetptr->disk.length)
-                              - nBlocks(NewLength)), 0);
+                        (afs_size_t)(nBlocks(nfSize) - nBlocks(NewLength)), 
+                        (afs_size_t) 0);
        return errorCode;
     }
     FDH_CLOSE(fdP);
 
     TM_GetTimeOfDay(&StopTime, 0);
 
-    targetptr->disk.length = NewLength;
+    VN_SET_LEN(targetptr, NewLength);
 
     /* Update all StoreData related stats */
     FS_LOCK
     if (AFSCallStats.TotalStoredBytes >        2000000000)     /* reset if over 2 billion */
        AFSCallStats.TotalStoredBytes = AFSCallStats.AccumStoreTime = 0;
     AFSCallStats.StoreSize1++;                 /* Piggybacked data */
-    if (targetptr->disk.length < SIZE2)
-       AFSCallStats.StoreSize2++;
-    else if (targetptr->disk.length < SIZE3)
-       AFSCallStats.StoreSize3++;
-    else if (targetptr->disk.length < SIZE4)
-       AFSCallStats.StoreSize4++;
-    else
-       AFSCallStats.StoreSize5++;
+    {
+       afs_size_t      targLen;
+       VN_GET_LEN(targLen, targetptr);
+       if (targLen < SIZE2)
+           AFSCallStats.StoreSize2++;
+       else if (targLen < SIZE3)
+           AFSCallStats.StoreSize3++;
+       else if (targLen < SIZE4)
+           AFSCallStats.StoreSize4++;
+       else
+           AFSCallStats.StoreSize5++;
+    }
     FS_UNLOCK
     return(errorCode);
 
index 6cbb523..60174d1 100644 (file)
@@ -48,7 +48,7 @@ RCSID("$Header$");
 #ifdef PAGESIZE
 #undef PAGESIZE
 #endif
-#define PAGESIZE 2048
+#define PAGESIZE (afs_size_t)2048
 
 extern int LogLevel;
 
@@ -57,7 +57,7 @@ afs_int32 lpErrno, lpCount;
 /* returns 0 on success, errno on failure */
 int ReallyRead (file, block, data)
 DirHandle     *        file;
-int            block;
+afs_size_t     block;
 char         * data;
 {
     int code;
@@ -72,7 +72,7 @@ char        * data;
                  PrintInode(NULL, file->dirh_handle->ih_ino), code));
        return code;
     }
-    if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, (afs_size_t)block * PAGESIZE, SEEK_SET) < 0) {
        code = errno;
         ViceLog (0,
                 ("ReallyRead(): lseek failed device %X inode %s errno %d\n",
@@ -102,7 +102,7 @@ char              * data;
 /* returns 0 on success, errno on failure */
 int ReallyWrite (file, block, data)
 DirHandle     *        file;
-int            block;
+afs_size_t     block;
 char         * data;
 {
     afs_int32 count;
@@ -117,7 +117,7 @@ char              * data;
        lpErrno = errno;
        return 0;
     }
-    if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, (afs_size_t) block * PAGESIZE, SEEK_SET) < 0) {
         ViceLog (0,
                 ("ReallyWrite(): lseek failed device %X inode %s errno %d\n",
                  file->dirh_handle->ih_dev,
index 5473f4f..b0b93ce 100644 (file)
@@ -973,7 +973,8 @@ static int ParseArgs(int argc, char *argv[])
 static void NewParms(int initializing)
 {
     static struct stat sbuf;
-    register int i, fd;
+    register afs_int64 i;
+    register int fd;
     char *parms;
     char *argv[MAXPARMS];
     register int argc;
index cfd7614..83e5677 100644 (file)
@@ -22,11 +22,17 @@ RCSID("$Header$");
 #ifdef AFS_NT40_ENV
 #include <fcntl.h>
 #else
+#ifdef AFS_LARGEFILE_ENV
+#include <fcntl.h>
+#else
 #include <sys/file.h>
+#endif
 #include <unistd.h>
 #include <sys/stat.h>
 #if defined(AFS_SUN5_ENV) || defined(AFS_NBSD_ENV)
+#ifndef AFS_LARGEFILE_ENV
 #include <sys/fcntl.h>
+#endif
 #include <sys/resource.h>
 #endif
 #endif
@@ -99,7 +105,7 @@ void ih_glock_init()
 #endif /* AFS_PTHREAD_ENV */
 
 /* Initialize the file descriptor cache */
-void ih_Initialize() {
+void ih_Initialize(void) {
     int i;
     assert(!ih_Inited);
     ih_Inited = 1;
@@ -144,7 +150,7 @@ void ih_Initialize() {
 
 /* Make the file descriptor cache as big as possible. Don't this call
  * if the program uses fopen or fdopen. */
-void ih_UseLargeCache() {
+void ih_UseLargeCache(void) {
     IH_LOCK
 
     if (!ih_Inited) {
@@ -156,7 +162,7 @@ void ih_UseLargeCache() {
 }
 
 /* Allocate a chunk of inode handles */
-void iHandleAllocateChunk()
+void iHandleAllocateChunk(void)
 {
     int i;
     IHandle_t *ihP;
@@ -222,7 +228,7 @@ IHandle_t *ih_copy(IHandle_t *ihP)
 }
 
 /* Allocate a chunk of file descriptor handles */
-void fdHandleAllocateChunk()
+void fdHandleAllocateChunk(void)
 {
     int i;
     FdHandle_t *fdP;
@@ -239,7 +245,7 @@ void fdHandleAllocateChunk()
 }
 
 /* Allocate a chunk of stream handles */
-void streamHandleAllocateChunk()
+void streamHandleAllocateChunk(void)
 {
     int i;
     StreamHandle_t *streamP;
@@ -488,9 +494,10 @@ StreamHandle_t *stream_open(const char *filename, const char *mode)
 }
 
 /* fread for buffered I/O handles */
-int stream_read(void *ptr, int size, int nitems, StreamHandle_t *streamP)
+afs_size_t stream_read(void *ptr, afs_size_t size, afs_size_t nitems,
+                      StreamHandle_t *streamP)
 {
-    int nbytes, bytesRead, bytesToRead;
+    afs_size_t nbytes, bytesRead, bytesToRead;
     char *p;
 
     /* Need to seek before changing direction */
@@ -537,10 +544,11 @@ int stream_read(void *ptr, int size, int nitems, StreamHandle_t *streamP)
 }
 
 /* fwrite for buffered I/O handles */
-int stream_write(void *ptr, int size, int nitems, StreamHandle_t *streamP)
+afs_size_t stream_write(void *ptr, afs_size_t size, afs_size_t nitems,
+                       StreamHandle_t *streamP)
 {
     char *p;
-    int rc, nbytes, bytesWritten, bytesToWrite;
+    afs_size_t rc, nbytes, bytesWritten, bytesToWrite;
 
     /* Need to seek before changing direction */
     if (streamP->str_direction == STREAM_DIRECTION_NONE) {
@@ -583,7 +591,7 @@ int stream_write(void *ptr, int size, int nitems, StreamHandle_t *streamP)
 }
 
 /* fseek for buffered I/O handles */
-int stream_seek(StreamHandle_t *streamP, int offset, int whence)
+int stream_seek(StreamHandle_t *streamP, afs_size_t offset, int whence)
 {
     int rc;
     int retval = 0;
@@ -839,11 +847,17 @@ Inode ih_icreate(IHandle_t *ih, int dev, char *part, Inode nI, int p1, int p2,
 
 
 #ifndef AFS_NT40_ENV
-int ih_size(int fd)
+afs_size_t ih_size(int fd)
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+    if (fstat64(fd, &status)<0)
+       return -1;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
     if (fstat(fd, &status)<0)
        return -1;
+#endif /* !AFS_LARGEFILE_ENV */
     return status.st_size;
 }
 #endif
index a14f2f7..b1ceb55 100644 (file)
@@ -249,8 +249,9 @@ extern FILE *ih_fdopen(FdHandle_t *h, char *fdperms);
 #endif /* AFS_NAMEI_ENV */
 
 /*
- * Prototypes for file descriptor cache routined
+ * Prototypes for file descriptor cache routines
  */
+extern void ih_Initialize(void);
 extern void ih_UseLargeCache(void);
 extern IHandle_t *ih_init(int dev, int vid, Inode ino);
 extern IHandle_t *ih_copy(IHandle_t *ihP);
@@ -259,11 +260,11 @@ extern int fd_close(FdHandle_t *fdP);
 extern int fd_reallyclose(FdHandle_t *fdP);
 extern StreamHandle_t *stream_fdopen(FD_t fd);
 extern StreamHandle_t *stream_open(const char *file, const char *mode);
-extern int stream_read(void *ptr, int size, int nitems,
-                      StreamHandle_t *streamP);
-extern int stream_write(void *ptr, int size, int nitems,
-                       StreamHandle_t *streamP);
-extern int stream_seek(StreamHandle_t *streamP, int offset, int whence);
+extern afs_size_t stream_read(void *ptr, afs_size_t size, afs_size_t nitems,
+                             StreamHandle_t *streamP);
+extern afs_size_t stream_write(void *ptr, afs_size_t size, afs_size_t nitems,
+                              StreamHandle_t *streamP);
+extern int stream_seek(StreamHandle_t *streamP, afs_size_t offset, int whence);
 extern int stream_flush(StreamHandle_t *streamP);
 extern int stream_close(StreamHandle_t *streamP, int reallyClose);
 extern int ih_reallyclose(IHandle_t *ihP);
@@ -339,16 +340,29 @@ extern int ih_condsync(IHandle_t *ihP);
        namei_icreate(H, P, P1, P2, P3, P4)
 
 #define OS_IOPEN(H) namei_iopen(H)
+#ifdef AFS_LARGEFILE_ENV
+#define OS_OPEN(F, M, P) open64(F, M, P)
+#else /* !AFS_LARGEFILE_ENV */
 #define OS_OPEN(F, M, P) open(F, M, P)
+#endif /* !AFS_LARGEFILE_ENV */
 #define OS_CLOSE(FD) close(FD)
 
 #define OS_READ(FD, B, S) read(FD, B, S)
 #define OS_WRITE(FD, B, S) write(FD, B, S)
+#ifdef AFS_LARGEFILE_ENV
+#define OS_SEEK(FD, O, F) lseek64(FD, (off64_t) O, F)
+#else /* !AFS_LARGEFILE_ENV */
 #define OS_SEEK(FD, O, F) lseek(FD, O, F)
+#endif /* !AFS_LARGEFILE_ENV */
 
 #define OS_SYNC(FD) fsync(FD)
+#ifdef AFS_LARGEFILE_ENV
+#define OS_TRUNC(FD, L) ftruncate64(FD, (off64_t) L)
+#else /* !AFS_LARGEFILE_ENV */
 #define OS_TRUNC(FD, L) ftruncate(FD, L)
+#endif /* !AFS_LARGEFILE_ENV */
 #define OS_SIZE(FD) ih_size(FD)
+extern afs_size_t ih_size(int fd);
 
 #define IH_INC(H, I, P) namei_inc(H, I, P)
 #define IH_DEC(H, I, P) namei_dec(H, I, P)
@@ -378,6 +392,7 @@ extern Inode ih_icreate(IHandle_t *ih, int dev, char *part, Inode nI, int p1,\
 #define OS_SYNC(FD) fsync(FD)
 #define OS_TRUNC(FD, L) ftruncate(FD, L)
 #define OS_SIZE(FD) ih_size(FD)
+extern afs_size_t ih_size(int fd);
 
 #ifdef AFS_LINUX22_ENV
 #define IH_INC(H, I, P) -1
index df6371e..350c476 100644 (file)
@@ -45,9 +45,10 @@ RCSID("$Header$");
 
 extern char *volutil_PartitionName_r(int volid, char *buf, int buflen);
 
-int namei_iread(IHandle_t *h, int offset, char *buf, int size)
+afs_size_t namei_iread(IHandle_t *h, afs_size_t offset,
+                      char *buf, afs_size_t size)
 {
-    int nBytes;
+    afs_size_t nBytes;
     FdHandle_t *fdP;
 
     fdP = IH_OPEN(h);
@@ -64,9 +65,10 @@ int namei_iread(IHandle_t *h, int offset, char *buf, int size)
     return nBytes;
 }
 
-int namei_iwrite(IHandle_t *h, int offset, char *buf, int size)
+afs_size_t namei_iwrite(IHandle_t *h, afs_size_t offset,
+                       char *buf, afs_size_t size)
 {
-    int nBytes;
+    afs_size_t nBytes;
     FdHandle_t *fdP;
 
     fdP = IH_OPEN(h);
@@ -282,7 +284,11 @@ delTree(char *root, char *tree, int *errp)
   char *cp;
   DIR *ds;
   struct dirent *dirp;
+#ifdef AFS_LARGEFILE_ENV
+  struct stat64 st;
+#else
   struct stat st;
+#endif
 
   if (*tree) {
     /* delete the children first */
@@ -306,7 +312,13 @@ delTree(char *root, char *tree, int *errp)
         */
        strcat(root, "/");
        strcat(root, dirp->d_name);
-       if (  stat(root, &st) == 0 && S_ISDIR(st.st_mode)) {
+       if (
+#ifdef AFS_LARGEFILE_ENV
+           stat64(root, &st) == 0
+#else /* !AFS_LARGEFILE_ENV */
+           stat(root, &st) == 0
+#endif /* !AFS_LARGEFILE_ENV */
+             && S_ISDIR(st.st_mode)) {
          /* delete this subtree */
          delTree(root, cp+1, errp); 
        } else
@@ -424,7 +436,11 @@ static int SetOGM(int fd, int parm, int tag)
 }
 
 /* GetOGM - get parm and tag from owner, group and mode bits. */
+#ifdef AFS_LARGEFILE_ENV
+static void GetOGMFromStat(struct stat64 *status, int *parm, int *tag)
+#else /* ! AFS_LARGEFILE_ENV */
 static void GetOGMFromStat(struct stat *status, int *parm, int *tag)
+#endif /* !AFS_LARGEFILE_ENV */
 {
     *parm = status->st_uid | (status->st_gid << 15);
     *parm |= (status->st_mode & 0x18) << 27;
@@ -433,9 +449,15 @@ static void GetOGMFromStat(struct stat *status, int *parm, int *tag)
 
 static int GetOGM(int fd, int *parm, int *tag)
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+    if (fstat64(fd, &status)<0) 
+       return -1;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
     if (fstat(fd, &status)<0) 
        return -1;
+#endif /* !AFS_LARGEFILE_ENV */
 
     GetOGMFromStat(&status, parm, tag);
     return 0;
@@ -510,12 +532,20 @@ Inode namei_icreate(IHandle_t *lh, char *part, int p1, int p2, int p3, int p4)
     }
 
     namei_HandleToName(&name, &tmp);
+#ifdef AFS_LARGEFILE_ENV
+    fd = open64(name.n_path, O_CREAT|O_EXCL|O_TRUNC|O_RDWR, 0);
+#else /* !AFS_LARGEFILE_ENV */
     fd = open(name.n_path, O_CREAT|O_EXCL|O_TRUNC|O_RDWR, 0);
+#endif /* !AFS_LARGEFILE_ENV */
     if (fd < 0) {
        if (errno == ENOTDIR || errno == ENOENT) {
            if (namei_CreateDataDirectories(&name, &created_dir)<0)
                goto bad;
+#ifdef AFS_LARGEFILE_ENV
+           fd = open64(name.n_path, O_CREAT|O_EXCL|O_TRUNC|O_RDWR, 0);
+#else /* !AFS_LARGEFILE_ENV */
            fd = open(name.n_path, O_CREAT|O_EXCL|O_TRUNC|O_RDWR, 0);
+#endif /* !AFS_LARGEFILE_ENV */
            if (fd < 0)
                goto bad;
        }
@@ -561,7 +591,11 @@ int namei_iopen(IHandle_t *h)
 
     /* Convert handle to file name. */
     namei_HandleToName(&name, h);
+#ifdef AFS_LARGEFILE_ENV
+    fd = open64(name.n_path, O_RDWR, 0666);
+#else /* !AFS_LARGEFILE_ENV */
     fd = open(name.n_path, O_RDWR, 0666);
+#endif /* !AFS_LARGEFILE_ENV */
     return fd;
 }
 
@@ -784,7 +818,7 @@ int namei_inc(IHandle_t *h, Inode ino, int p1)
 #define LINKTABLE_WIDTH 2
 #define LINKTABLE_SHIFT 1 /* log 2 = 1 */
 
-static void namei_GetLCOffsetAndIndexFromIno(Inode ino, int *offset, int *index)
+static void namei_GetLCOffsetAndIndexFromIno(Inode ino, afs_size_t *offset, int *index)
 {
     int toff = (int) (ino & NAMEI_VNODEMASK);
     int tindex = (int)((ino>>NAMEI_TAGSHIFT) & NAMEI_TAGMASK);
@@ -801,7 +835,8 @@ static void namei_GetLCOffsetAndIndexFromIno(Inode ino, int *offset, int *index)
 int namei_GetLinkCount(FdHandle_t *h, Inode ino, int lockit)
 {
     unsigned short row = 0;
-    int offset, index;
+    afs_size_t offset;
+    int index;
 
     namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
 
@@ -814,8 +849,13 @@ int namei_GetLinkCount(FdHandle_t *h, Inode ino, int lockit)
            return -1;
     }
 
-    if (lseek(h->fd_fd, offset, SEEK_SET) == -1)
+#ifdef AFS_LARGEFILE_ENV
+    if (lseek64(h->fd_fd, (off64_t) offset, SEEK_SET) == -1)
        goto bad_getLinkByte;
+#else /* !AFS_LARGEFILE_ENV */
+    if (lseek(h->fd_fd, (off_t) offset, SEEK_SET) == -1)
+       goto bad_getLinkByte;
+#endif /* !AFS_LARGEFILE_ENV */
     
     if (read(h->fd_fd, (char*)&row, sizeof(row))!=sizeof(row)) {
        goto bad_getLinkByte;
@@ -837,7 +877,7 @@ int namei_GetLinkCount(FdHandle_t *h, Inode ino, int lockit)
 static int GetFreeTag(IHandle_t *ih, int vno)
 {
     FdHandle_t *fdP;
-    int offset;
+    afs_size_t offset;
     int col;
     int coldata;
     short row;
@@ -859,9 +899,15 @@ static int GetFreeTag(IHandle_t *ih, int vno)
     }
     
     offset = (vno <<  LINKTABLE_SHIFT) + 8; /* * 2 + sizeof stamp */
-    if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+#ifdef AFS_LARGEFILE_ENV
+    if (lseek64(fdP->fd_fd, (off64_t) offset, SEEK_SET) == -1) {
        goto badGetFreeTag;
     }
+#else /* !AFS_LARGEFILE_ENV */
+    if (lseek(fdP->fd_fd, (off_t) offset, SEEK_SET) == -1) {
+       goto badGetFreeTag;
+    }
+#endif /* !AFS_LARGEFILE_ENV */
        
     code = read(fdP->fd_fd, (char*)&row, sizeof(row));
     if (code != sizeof(row)) {
@@ -882,9 +928,15 @@ static int GetFreeTag(IHandle_t *ih, int vno)
     coldata = 1 << (col * 3);
     row |= coldata;
 
-    if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+#ifdef AFS_LARGEFILE_ENV
+    if (lseek64(fdP->fd_fd, (off64_t) offset, SEEK_SET) == -1) {
+       goto badGetFreeTag;
+    }
+#else /* !AFS_LARGEFILE_ENV */
+    if (lseek(fdP->fd_fd, (off_t) offset, SEEK_SET) == -1) {
        goto badGetFreeTag;
     }
+#endif /* !AFS_LARGEFILE_ENV */
     if (write(fdP->fd_fd, (char*)&row, sizeof(row))!=sizeof(row)) {
        goto badGetFreeTag;
     }
@@ -915,7 +967,8 @@ static int GetFreeTag(IHandle_t *ih, int vno)
  */
 int namei_SetLinkCount(FdHandle_t *fdP, Inode ino, int count, int locked)
 {
-    int offset, index;
+    afs_size_t offset;
+    int index;
     unsigned short row;
     int junk;
     int code = -1;
@@ -931,10 +984,17 @@ int namei_SetLinkCount(FdHandle_t *fdP, Inode ino, int count, int locked)
            return -1;
        }
     }
-    if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+#ifdef AFS_LARGEFILE_ENV
+    if (lseek64(fdP->fd_fd, (off64_t) offset, SEEK_SET) == -1) {
        errno = EBADF;
        goto bad_SetLinkCount;
     }
+#else /* !AFS_LARGEFILE_ENV */
+    if (lseek(fdP->fd_fd, (off_t) offset, SEEK_SET) == -1) {
+       errno = EBADF;
+       goto bad_SetLinkCount;
+    }
+#endif /* !AFS_LARGEFILE_ENV */
 
     
     code = read(fdP->fd_fd, (char*)&row, sizeof(row));
@@ -951,10 +1011,17 @@ int namei_SetLinkCount(FdHandle_t *fdP, Inode ino, int count, int locked)
     row &= (unsigned short)~junk;
     row |= (unsigned short)count;
 
-    if (lseek(fdP->fd_fd, offset, SEEK_SET) == -1) {
+#ifdef AFS_LARGEFILE_ENV
+    if (lseek64(fdP->fd_fd, (off64_t) offset, SEEK_SET) == -1) {
+       errno =  EBADF;
+       goto bad_SetLinkCount;
+    }
+#else /* !AFS_LARGEFILE_ENV */
+    if (lseek(fdP->fd_fd, (off_t) offset, SEEK_SET) == -1) {
        errno =  EBADF;
        goto bad_SetLinkCount;
     }
+#endif /* !AFS_LARGEFILE_ENV */
 
     if (write(fdP->fd_fd, (char*)&row, sizeof(short)) != sizeof(short)) {
        errno = EBADF;
@@ -1009,9 +1076,19 @@ static int WriteInodeInfo(FILE *fp, struct ViceInodeInfo *info, char *dir,
 int mode_errors; /* Number of errors found in mode bits on directories. */
 void VerifyDirPerms(char *path)
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
-
-    if (stat(path, &status)<0) {
+#endif /* !AFS_LARGEFILE_ENV */
+
+    if (
+#ifdef AFS_LARGEFILE_ENV
+       stat64(path, &status)
+#else /* ! AFS_LARGEFILE_ENV */
+       stat(path, &status)
+#endif /* ! AFS_LARGEFILE_ENV */
+       <0) {
        Log("Unable to stat %s. Please manually verify mode bits for this"
            " directory\n", path);
     }
@@ -1041,7 +1118,11 @@ int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
 {
     FILE *fp = (FILE*)-1;
     int ninodes;
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
 
     if (resultFile) {
        fp = fopen(resultFile, "w");
@@ -1084,7 +1165,13 @@ int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
     /*
      * Paranoia:  check that the file is really the right size
      */
-    if (stat(resultFile, &status) == -1) {
+    if (
+#ifdef AFS_LARGEFILE_ENV
+       stat64(resultFile, &status)
+#else /* !AFS_LARGEFILE_ENV */
+       stat(resultFile, &status)
+#endif /* !AFS_LARGEFILE_ENV */
+       == -1) {
        Log("Unable to successfully stat inode file for %s\n", mountedOn);
        return -2;
     }
@@ -1217,7 +1304,11 @@ static int namei_ListAFSSubDirs(IHandle_t *dirIH,
            else {
                /* Open this handle */
                (void) sprintf(path2, "%s/%s", path1, dp1->d_name);
+#ifdef AFS_LARGEFILE_ENV
+               linkHandle.fd_fd = open64(path2, O_RDONLY, 0666);
+#else /* !AFS_LARGEFILE_ENV */
                linkHandle.fd_fd = open(path2, O_RDONLY, 0666);
+#endif /* !AFS_LARGEFILE_ENV */
                info.linkCount = namei_GetLinkCount(&linkHandle, (Inode)0, 0);
            }
            if (judgeFun && !(*judgeFun)(&info, singleVolumeNumber))
@@ -1329,16 +1420,26 @@ static int DecodeInode(char *dpath, char *name, struct ViceInodeInfo *info,
                       int volid)
 {
     char fpath[512];
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
     int parm, tag;
 
     (void) strcpy(fpath, dpath);
     (void) strcat(fpath, "/");
     (void) strcat(fpath, name);
 
+#ifdef AFS_LARGEFILE_ENV
+    if (stat64(fpath, &status)<0) {
+       return -1;
+    }
+#else /* !AFS_LARGEFILE_ENV */
     if (stat(fpath, &status)<0) {
        return -1;
     }
+#endif /* !AFS_LARGEFILE_ENV */
 
     info->byteCount = status.st_size;
     info->inodeNumber = flipbase64_to_int64(name);
index df55e01..831cd83 100644 (file)
@@ -34,8 +34,10 @@ extern Inode namei_MakeSpecIno(int volid, int type);
 extern Inode namei_icreate(IHandle_t *h, char *p, int p1, int p2, int p3, int p4);
 extern FD_t namei_iopen(IHandle_t *h);
 extern int namei_irelease(IHandle_t *h);
-int namei_iread(IHandle_t *h, int offset, char *buf, int size);
-int namei_iwrite(IHandle_t *h, int offset, char *buf, int size);
+afs_size_t namei_iread(IHandle_t *h, afs_size_t offset,
+                      char *buf, afs_size_t size);
+afs_size_t namei_iwrite(IHandle_t *h, afs_size_t offset,
+                       char *buf, afs_size_t size);
 extern int namei_dec(IHandle_t *h, Inode ino, int p1);
 extern int namei_inc(IHandle_t *h, Inode ino, int p1);
 extern int namei_GetLinkCount(FdHandle_t *h, Inode ino, int lockit);
index 11c163e..6edd46b 100644 (file)
@@ -255,7 +255,11 @@ int VCheckPartition(part, devname)
      char *part;
      char *devname;
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV)
     char AFSIDatPath[MAXPATHLEN];
 #endif
@@ -265,20 +269,34 @@ int VCheckPartition(part, devname)
     if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
        return 0;
     }
+#ifdef AFS_LARGEFILE_ENV
+    if (stat64(part, &status) < 0) {
+       Log("VInitVnodes: Couldn't find file system %s; ignored\n", part);
+       return 0;
+    }
+#else /* !AFS_LARGEFILE_ENV */
     if (stat(part, &status) < 0) {
        Log("VInitVnodes: Couldn't find file system %s; ignored\n", part);
        return 0;
     }
+#endif /* AFS_LARGEFILE_ENV */
     
 #ifndef AFS_AIX32_ENV
     if (programType == fileServer) {
        char salvpath[MAXPATHLEN];
        strcpy(salvpath, part);
        strcat(salvpath, "/FORCESALVAGE");
+#ifdef AFS_LARGEFILE_ENV
+       if (stat64(salvpath, &status) == 0) {
+           Log("VInitVnodes: Found %s; aborting\n", salvpath);
+           return -1;
+       }
+#else /* !AFS_LARGEFILE_ENV */
        if (stat(salvpath, &status) == 0) {
            Log("VInitVnodes: Found %s; aborting\n", salvpath);
            return -1;
        }
+#endif /* !AFS_LARGEFILE_ENV */
     }
 #endif
 
@@ -286,7 +304,13 @@ int VCheckPartition(part, devname)
     strcpy(AFSIDatPath, part);
     strcat(AFSIDatPath, "/AFSIDat");
 #ifdef AFS_NAMEI_ENV
-    if (stat(AFSIDatPath, &status) < 0) {
+    if (
+#ifdef AFS_LARGEFILE_ENV
+       stat64(AFSIDatPath, &status)
+#else /* !AFS_LARGEFILE_ENV */
+       stat(AFSIDatPath, &status)
+#endif /* !AFS_LARGEFILE_ENV */
+       < 0) {
        DIR *dirp;
        struct dirent *dp;
 
@@ -904,7 +928,7 @@ void VResetDiskUsage(void)
     VOL_UNLOCK
 }
 
-void VAdjustDiskUsage_r(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 checkBlocks)
+void VAdjustDiskUsage_r(Error *ec, Volume *vp, afs_size_t blocks, afs_size_t checkBlocks)
 {
     *ec = 0;
     /* why blocks instead of checkBlocks in the check below?  Otherwise, any check
@@ -928,14 +952,14 @@ void VAdjustDiskUsage_r(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 check
     V_diskused(vp) += blocks;
 }
 
-void VAdjustDiskUsage(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 checkBlocks)
+void VAdjustDiskUsage(Error *ec, Volume *vp, afs_size_t blocks, afs_size_t checkBlocks)
 {
     VOL_LOCK
     VAdjustDiskUsage_r(ec, vp, blocks, checkBlocks);
     VOL_UNLOCK
 }
 
-int VDiskUsage_r(Volume *vp, afs_int32 blocks)
+int VDiskUsage_r(Volume *vp, afs_size_t blocks)
 {
     if (blocks > 0) {
 #ifdef AFS_AIX32_ENV
@@ -952,7 +976,7 @@ int VDiskUsage_r(Volume *vp, afs_int32 blocks)
     return 0;
 }
 
-int VDiskUsage(Volume *vp, afs_int32 blocks)
+int VDiskUsage(Volume *vp, afs_size_t blocks)
 {
     int retVal;
     VOL_LOCK
index e471dea..0ddb25b 100644 (file)
@@ -102,7 +102,7 @@ extern void VResetDiskUsage_r(void);
 extern void VSetPartitionDiskUsage(register struct DiskPartition *dp);
 extern void VSetPartitionDiskUsage_r(register struct DiskPartition *dp);
 extern char *VPartitionPath(struct DiskPartition *p);
-/*extern void VAdjustDiskUsage(Error *ec, Volume *vp, afs_int32 blocks,
-                            afs_int32 checkBlocks); */
+/*extern void VAdjustDiskUsage(Error *ec, Volume *vp, afs_size_t blocks,
+                             afs_size_t checkBlocks); */
 extern void VPrintDiskStats(void);
 
index 109e088..8fbe594 100644 (file)
@@ -51,7 +51,7 @@ RCSID("$Header$");
 /* returns 0 on success, errno on failure */
 int ReallyRead (file, block, data)
 DirHandle     *        file;
-int            block;
+afs_size_t     block;
 char         * data;
 {
     FdHandle_t *fdP;
@@ -62,12 +62,12 @@ char              * data;
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, (afs_size_t)(block*AFS_PAGESIZE), SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_READ(fdP, data, AFS_PAGESIZE);
+    code = FDH_READ(fdP, data, (afs_size_t) AFS_PAGESIZE);
     if (code != AFS_PAGESIZE) {
        if (code < 0)
            code = errno;
@@ -83,7 +83,7 @@ char        * data;
 /* returns 0 on success, errno on failure */
 int ReallyWrite (file, block, data)
 DirHandle     *        file;
-int            block;
+afs_size_t     block;
 char         * data;
 {
     FdHandle_t *fdP;
@@ -97,12 +97,12 @@ char              * data;
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, (afs_size_t)(block*AFS_PAGESIZE), SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_WRITE(fdP, data, AFS_PAGESIZE);
+    code = FDH_WRITE(fdP, data, (afs_size_t) AFS_PAGESIZE);
     if (code != AFS_PAGESIZE) {
        if (code < 0)
            code = errno;
index 015d673..1828651 100644 (file)
@@ -46,7 +46,7 @@ struct SpecialInodeParams {
  */
 struct ViceInodeInfo {
     Inode      inodeNumber;
-    int                byteCount;
+    afs_offs_t byteCount;
     int                linkCount;
     union {
         bit32                    param[4];
index 2901eb0..3d22354 100644 (file)
@@ -154,6 +154,33 @@ typedef struct Vnode {
        (sizeof(struct Vnode) - sizeof(VnodeDiskObject) + SIZEOF_LARGEDISKVNODE)
 #define SIZEOF_SMALLVNODE      (sizeof (struct Vnode))
 
+#ifdef AFS_LARGEFILE_ENV
+
+#ifndef AFS_NAMEI_ENV
+#define AFS_NAMEI_ENV
+#endif
+
+#define VN_GET_INO(V) ((Inode)((V)->disk.vn_ino_lo | \
+                       (((Inode)(V)->disk.uniquifier)<<32)))
+
+#define VN_SET_INO(V, I) ((V)->disk.vn_ino_lo = (int)((I)&0xffffffff))
+
+#define VNDISK_GET_INO(V) ((Inode)((V)->vn_ino_lo | \
+                           (((Inode)(V)->uniquifier)<<32)))
+
+#define VNDISK_SET_INO(V, I) ((V)->vn_ino_lo = (int)((I)&0xffffffff))
+
+#define VN_GET_LEN(N, V)  FillInt64(N, (V)->disk.vn_ino_hi, (V)->disk.length)
+#define VNDISK_GET_LEN(N, V)  FillInt64(N, (V)->vn_ino_hi, (V)->length)
+
+#define VN_SET_LEN(V, N)  SplitInt64(N, (V)->disk.vn_ino_hi, (V)->disk.length)
+#define VNDISK_SET_LEN(V, N) SplitInt64(N, (V)->vn_ino_hi, (V)->length)
+
+#define SET_STATUS_LEN(S, V) (((S)->Length_hi=(afs_uint32)(V)->disk.vn_ino_hi), \
+                              ((S)->Length=(afs_uint32)(V)->disk.length))
+
+#else /*AFS_LARGEFILE_ENV*/
+
 #ifdef AFS_64BIT_IOPS_ENV
 #define VN_GET_INO(V) ((Inode)((V)->disk.vn_ino_lo | \
                               ((V)->disk.vn_ino_hi ? \
@@ -177,6 +204,17 @@ typedef struct Vnode {
 #define VNDISK_SET_INO(V, I) ((V)->vn_ino_lo = (I))
 #endif
 
+#define VN_GET_LEN(N, V)  (N) = (V)->disk.length;
+#define VNDISK_GET_LEN(N, V)  (N) = (V)->length;
+#define VN_SET_LEN(V, N)  (V)->disk.length = Int64ToInt32(N);
+#define VNDISK_SET_LEN(V, N) (V)->length = Int64ToInt32(N);
+
+#define SET_STATUS_LEN(S, V) (((S)->Length_hi = 0), \
+                              ((S)->Length = (afs_uint32)(V)->disk.length))
+
+#endif /*AFS_LARGEFILE_ENV*/
+
+
 #define VVnodeDiskACL(v)     /* Only call this with large (dir) vnode!! */ \
        ((AL_AccessList *) (((byte *)(v))+SIZEOF_SMALLDISKVNODE))
 #define  VVnodeACL(vnp) (VVnodeDiskACL(&(vnp)->disk))
index 641961e..48f784a 100644 (file)
@@ -815,11 +815,22 @@ void PrintVnode(int offset, VnodeDiskObject *vnode, int vnodeNumber, Inode ino)
     char filename[MAX_PATH];
 #endif
 #endif
-    Vvnodesize += vnode->length;
+    afs_size_t fileLength;
+
+    VNDISK_GET_LEN(fileLength, vnode);
+    Vvnodesize += fileLength;
     if (dsizeOnly) return;
-    if (orphaned && (vnode->length ==0 || vnode->parent || !offset)) return;
+    if (orphaned && (fileLength ==0 || vnode->parent || !offset)) return;
+#ifdef AFS_LARGEFILE_ENV
+    printf("%10d Vnode %u.%u.%u cloned: %d, length: (0X%x,0X%x) linkCount: %d parent: %d",
+        offset, vnodeNumber, vnode->uniquifier, vnode->dataVersion, vnode->cloned,
+          (unsigned) (fileLength >> 32),
+          (unsigned) (fileLength & 0xffffffff),
+          vnode->linkCount, vnode->parent);
+#else
     printf("%10d Vnode %u.%u.%u cloned: %d, length: %d linkCount: %d parent: %d",
-        offset, vnodeNumber, vnode->uniquifier, vnode->dataVersion, vnode->cloned, vnode->length, vnode->linkCount, vnode->parent);
+        offset, vnodeNumber, vnode->uniquifier, vnode->dataVersion, vnode->cloned, fileLength, vnode->linkCount, vnode->parent);
+#endif
     if (DumpInodeNumber)
        printf(" inode: %s", PrintInode(NULL, ino));
     if (DumpDate)
index 25d79d7..ba4cafe 100644 (file)
@@ -322,7 +322,7 @@ struct VnodeInfo {
                              0 after scanning all directories */
         unsigned salvaged:1;/* Set if this directory vnode has already been salvaged. */       
         unsigned todelete:1;/* Set if this vnode is to be deleted (should not be claimed) */
-       afs_uint32 blockCount;
+       afs_offs_t blockCount;
                            /* Number of blocks (1K) used by this vnode,
                               approximately */
        VnodeId parent;     /* parent in vnode */
@@ -1437,7 +1437,11 @@ int OnlyOneVolume(inodeinfo, singleVolumeNumber)
  */
 int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
 {
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
     int forceSal, err;
     struct ViceInodeInfo *ip;
     struct InodeSummary summary;
@@ -1468,7 +1472,13 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
        ForceSalvage = 1;
     }
     inodeFd = open(path, O_RDWR);
-    if (inodeFd == -1 || fstat(inodeFd, &status) == -1) {
+    if (inodeFd == -1 ||
+#ifdef AFS_LARGEFILE_ENV
+       fstat64(inodeFd, &status)
+#else /* !AFS_LARGEFILE_ENV */
+       fstat(inodeFd, &status)
+#endif /* !AFS_LARGEFILE_ENV */
+       == -1) {
        unlink(path);
        Abort("No inode description file for \"%s\"; not salvaged\n", dev);
     }
@@ -1511,8 +1521,13 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
            Abort("Unable to read inode table; %s not salvaged\n", dev);
        }
        qsort(ip, nInodes, sizeof(struct ViceInodeInfo), CompareInodes);
-       if (lseek(inodeFd, 0, SEEK_SET) == -1 ||
-           write(inodeFd, ip, status.st_size) != status.st_size) {
+       if (
+#ifdef AFS_LARGEFILE_ENV
+           lseek64(inodeFd, (off64_t) 0, SEEK_SET) == -1
+#else /* !AFS_LARGEFILE_ENV */
+           lseek(inodeFd, (off_t) 0, SEEK_SET) == -1
+#endif /* !AFS_LARGEFILE_ENV */
+           || write(inodeFd, ip, status.st_size) != status.st_size) {
            fclose(summaryFile); close(inodeFd);
            unlink(path);
            unlink(summaryFileName);
@@ -1549,13 +1564,21 @@ int GetInodeSummary(char *path, VolumeId singleVolumeNumber)
            Exit(1);    /* salvage of this partition aborted */
        }
     }
+#ifdef AFS_LARGEFILE_ENV
+    assert(fstat64(fileno(summaryFile), &status) != -1);
+#else /* !AFS_LARGEFILE_ENV */
     assert(fstat(fileno(summaryFile), &status) != -1);
+#endif /* !AFS_LARGEFILE_ENV */
     if ( status.st_size != 0 ) {
        int ret;
        inodeSummary = (struct InodeSummary *) malloc(status.st_size);
        assert(inodeSummary != NULL);
        /* For GNU we need to do lseek to get the file pointer moved. */
-       assert(lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
+#ifdef AFS_LARGEFILE_ENV
+       assert(lseek64(fileno(summaryFile), (off64_t) 0, SEEK_SET) == 0);
+#else /* !AFS_LARGEFILE_ENV */
+       assert(lseek(fileno(summaryFile), (off_t) 0, SEEK_SET) == 0);
+#endif /* !AFS_LARGEFILE_ENV */
        ret = read(fileno(summaryFile), inodeSummary, status.st_size);
        assert(ret == status.st_size);
     }
@@ -1809,7 +1832,11 @@ void DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
     allInodes = inodes - isp->index; /* this would the base of all the inodes
                                        for the partition, if all the inodes
                                        had been read into memory */
-    assert(lseek(inodeFd,isp->index*sizeof(struct ViceInodeInfo),SEEK_SET) != -1)
+#ifdef AFS_LARGEFILE_ENV
+    assert(lseek64(inodeFd,(off64_t)(isp->index*sizeof(struct ViceInodeInfo)),SEEK_SET) != -1)
+#else /* !AFS_LARGEFILE_ENV */
+    assert(lseek(inodeFd,(off_t)(isp->index*sizeof(struct ViceInodeInfo)),SEEK_SET) != -1)
+#endif /* !AFS_LARGEFILE_ENV */
     assert(read(inodeFd,inodes,size) == size)
 
     /* Don't try to salvage a read write volume if there isn't one on this
@@ -1896,10 +1923,19 @@ void DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
 #endif
            if (ip->linkCount != 0 && TraceBadLinkCounts) {
                TraceBadLinkCounts--; /* Limit reports, per volume */
+#ifdef AFS_LARGEFILE_ENV
+               Log("#### DEBUG #### Link count incorrect by %d; inode %s, size (0X%x,0x%x), p=(%u,%u,%u,%u)\n",
+                   ip->linkCount, PrintInode(NULL, ip->inodeNumber),
+                   (unsigned) ((ip->byteCount) >> 32),
+                   (unsigned) ((ip->byteCount) & 0xffffffff),
+                   ip->u.param[0], ip->u.param[1],
+                   ip->u.param[2], ip->u.param[3]);
+#else
                Log("#### DEBUG #### Link count incorrect by %d; inode %s, size %u, p=(%u,%u,%u,%u)\n",
                    ip->linkCount, PrintInode(NULL, ip->inodeNumber),
                    ip->byteCount, ip->u.param[0], ip->u.param[1],
                    ip->u.param[2], ip->u.param[3]);
+#endif /* !AFS_LARGEFILE_ENV */
            }
            while (ip->linkCount > 0) {
                /* below used to assert, not break */
@@ -2308,7 +2344,7 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
     int err = 0;
     StreamHandle_t *file;
     struct VnodeClassInfo *vcp;
-    int size;
+    afs_size_t size, vnodeSize;
     int vnodeIndex, nVnodes;
     afs_ino_str_t stmp1, stmp2;
     IHandle_t *handle;
@@ -2464,36 +2500,75 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
                    if (ip->inodeNumber != VNDISK_GET_INO(vnode)) {
                        if (check) {
                            if (!Showmode) {
+#ifdef AFS_LARGEFILE_ENV
+                               Log("Vnode %d:  inode number incorrect (is %s should be %s). FileSize=(0X%x,0X%x)\n",
+                                   vnodeNumber,
+                                   PrintInode(stmp1, VNDISK_GET_INO(vnode)),
+                                   PrintInode(stmp2, ip->inodeNumber),
+                                   (unsigned) (ip->byteCount >> 32),
+                                   (unsigned) (ip->byteCount & 0xffffffff));
+#else
                                Log("Vnode %d:  inode number incorrect (is %s should be %s). FileSize=%d\n",
                                    vnodeNumber,
                                    PrintInode(stmp1, VNDISK_GET_INO(vnode)),
                                    PrintInode(stmp2, ip->inodeNumber),
                                    ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
                            }
                            VNDISK_SET_INO(vnode, ip->inodeNumber);
                            err = -1;
                            goto zooks;
                        }
                        if (!Showmode) {
+#ifdef AFS_LARGEFILE_ENV
+                           Log("Vnode %d: inode number incorrect; changed from %s to %s. FileSize=(0X%x,0X%x)\n",
+                               vnodeNumber,
+                               PrintInode(stmp1, VNDISK_GET_INO(vnode)),
+                               PrintInode(stmp2, ip->inodeNumber),
+                               (unsigned) (ip->byteCount >> 32),
+                               (unsigned) (ip->byteCount & 0xffffffff));
+#else
                            Log("Vnode %d: inode number incorrect; changed from %s to %s. FileSize=%d\n",
                                vnodeNumber,
                                PrintInode(stmp1, VNDISK_GET_INO(vnode)),
                                PrintInode(stmp2, ip->inodeNumber),
                                ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
                        }
                        VNDISK_SET_INO(vnode, ip->inodeNumber);
                        vnodeChanged = 1;
                    }
-                   if (ip->byteCount != vnode->length) {
+                   VNDISK_GET_LEN(vnodeSize, vnode);
+                   if (ip->byteCount != vnodeSize) {
                        if (check) {
-                           if (!Showmode) Log("Vnode %d: length incorrect; (is %d should be %d)\n",
-                                              vnodeNumber, vnode->length, ip->byteCount);
+                           if (!Showmode)
+#ifdef AFS_LARGEFILE_ENV
+                               Log("Vnode %d: length incorrect; (is (0X%x,0X%x) should be (0X%x,0X%x))\n",
+                                   vnodeNumber,
+                                   (unsigned) (vnodeSize >> 32),
+                                   (unsigned) (vnodeSize & 0xffffffff),
+                                   (unsigned) (ip->byteCount >> 32),
+                                   (unsigned) (ip->byteCount & 0xffffffff));
+#else
+                               Log("Vnode %d: length incorrect; (is %d should be %d)\n",
+                                   vnodeNumber, vnodeSize, ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
                            err = -1;
                            goto zooks;
                        }
-                       if (!Showmode) Log("Vnode %d: length incorrect; changed from %d to %d\n",
-                                          vnodeNumber, vnode->length, ip->byteCount);
-                       vnode->length = ip->byteCount;
+                       if (!Showmode)
+#ifdef AFS_LARGEFILE_ENV
+                           Log("Vnode %d: length incorrect; changed from (0X%x,0X%x) to (0X%x,0X%x)\n",
+                               vnodeNumber,
+                               (unsigned) (vnodeSize >> 32),
+                               (unsigned) (vnodeSize & 0xffffffff),
+                               (unsigned) (ip->byteCount >> 32),
+                               (unsigned) (ip->byteCount & 0xffffffff));
+#else
+                           Log("Vnode %d: length incorrect; changed from %d to %d\n",
+                               vnodeNumber, vnodeSize, ip->byteCount);
+#endif /* !AFS_LARGEFILE_ENV */
+                       VNDISK_SET_LEN(vnode, ip->byteCount);
                        vnodeChanged = 1;
                    }
                    if (!check)
@@ -2677,7 +2752,7 @@ void CopyAndSalvage(register struct DirSummary *dir)
     }
     vnode.cloned = 0;
     VNDISK_SET_INO(&vnode, newinode);
-    vnode.length = Length(&newdir);
+    VNDISK_SET_LEN(&vnode, (afs_size_t) Length(&newdir));
     code = IH_IWRITE(vnodeInfo[vLarge].handle,
                    vnodeIndexOffset(vcp, dir->vnodeNumber),
                    (char*)&vnode, sizeof (vnode));
@@ -2973,9 +3048,11 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
       nVnodes--, vnodeIndex++) {
        if (vnode->type != vNull) {
            register struct VnodeEssence *vep = &vip->vnodes[vnodeIndex];
+           afs_size_t  vnodeLength;
            vip->nAllocatedVnodes++;
            vep->count = vnode->linkCount;
-           vep->blockCount = nBlocks(vnode->length);
+           VNDISK_GET_LEN(vnodeLength, vnode);
+           vep->blockCount = nBlocks(vnodeLength);
            vip->volumeBlockCount += vep->blockCount;
            vep->parent = vnode->parent;
            vep->unique = vnode->uniquifier;
@@ -3480,18 +3557,34 @@ void PrintInodeList(void)
 {
     register struct ViceInodeInfo *ip;
     struct ViceInodeInfo *buf;
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
     register nInodes;
 
+#ifdef AFS_LARGEFILE_ENV
+    assert(fstat64(inodeFd, &status) == 0);
+#else /* !AFS_LARGEFILE_ENV */
     assert(fstat(inodeFd, &status) == 0);
+#endif /* !AFS_LARGEFILE_ENV */
     buf = (struct ViceInodeInfo *) malloc(status.st_size);
     assert(buf != NULL);
     nInodes = status.st_size / sizeof(struct ViceInodeInfo);
     assert(read(inodeFd, buf, status.st_size) == status.st_size);
     for(ip = buf; nInodes--; ip++) {
+#ifdef AFS_LARGEFILE_ENV
+       Log("Inode:%s, linkCount=%d, size=(0X%x,0X%x), p=(%u,%u,%u,%u)\n",
+           PrintInode(NULL, ip->inodeNumber), ip->linkCount,
+           (unsigned) (ip->byteCount >> 32),
+           (unsigned) (ip->byteCount & 0xffffffff),
+           ip->u.param[0], ip->u.param[1], ip->u.param[2], ip->u.param[3]);
+#else
        Log("Inode:%s, linkCount=%d, size=%u, p=(%u,%u,%u,%u)\n",
            PrintInode(NULL, ip->inodeNumber), ip->linkCount, ip->byteCount,
            ip->u.param[0], ip->u.param[1], ip->u.param[2], ip->u.param[3]);
+#endif
     }
     free(buf);
 }
index 2341b63..db5da58 100644 (file)
@@ -536,7 +536,11 @@ VAttachVolumeByName_r(ec, partition, name, mode)
 {
     register Volume *vp;
     int fd,n;
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
     struct stat status;
+#endif /* !AFS_LARGEFILE_ENV */
     struct VolumeDiskHeader diskHeader;
     struct VolumeHeader iheader;
     struct DiskPartition *partp;
@@ -572,7 +576,13 @@ VAttachVolumeByName_r(ec, partition, name, mode)
     strcat(path, "/");
     strcat(path, name);
     VOL_UNLOCK
-    if ((fd = open(path, O_RDONLY)) == -1 || fstat(fd,&status) == -1) {
+    if ((fd = open(path, O_RDONLY)) == -1
+#ifdef AFS_LARGEFILE_ENV
+       || fstat64(fd,&status) == -1
+#else /* !AFS_LARGEFILE_ENV */
+       || fstat(fd,&status) == -1
+#endif /* !AFS_LARGEFILE_ENV */
+       ) {
        close(fd);
        VOL_LOCK
        *ec = VNOVOL;
@@ -1506,10 +1516,19 @@ static void GetVolumePath(Error *ec, VolId volumeId, char **partitionp,
     name[0] = '/';
     sprintf(&name[1],VFORMAT,volumeId);
     for (dp = DiskPartitionList; dp; dp = dp->next) {
+#ifdef AFS_LARGEFILE_ENV
+       struct stat64 status;
+#else /* !AFS_LARGEFILE_ENV */
        struct stat status;
+#endif
         strcpy(path, VPartitionPath(dp));
        strcat(path, name);
-       if (stat(path,&status) == 0) {
+#ifdef AFS_LARGEFILE_ENV
+       if (stat64(path,&status) == 0)
+#else /* !AFS_LARGEFILE_ENV */
+       if (stat(path,&status) == 0)
+#endif /* !AFS_LARGEFILE_ENV */
+       {
            strcpy(partition, dp->name);
            found = 1;
            break;
index 2750b10..f1dcc49 100644 (file)
@@ -448,7 +448,7 @@ extern void VolumeHeaderToDisk(VolumeDiskHeader_t *dh, VolumeHeader_t *h);
 /* Note:  we charge 1 block for 0 length files so the user can't store
    an inifite number of them; for most files, we give him the inode, vnode,
    and indirect block overhead, for FREE! */
-#define nBlocks(bytes) ((bytes) == 0? 1: ((bytes)+1023)/1024)
+#define nBlocks(bytes) ((afs_size_t)((bytes) == 0? 1: (((afs_size_t)bytes)+1023)/1024))
 
 /* Client process id -- file server sends a Check volumes signal back to the client at this pid */
 #define CLIENTPID      "/vice/vol/clientpid"
index c95c4fe..50576a3 100644 (file)
@@ -87,8 +87,9 @@ static int ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp);
 static int ReadVnodes(register struct iod *iodp, Volume *vp,
                      int incremental, afs_int32 *Lbuf, afs_int32 s1,
                      afs_int32 *Sbuf, afs_int32 s2, afs_int32 delo);
-static bit32 volser_WriteFile(int vn, struct iod *iodp, FdHandle_t *handleP,
-                             Error *status);
+static afs_offs_t volser_WriteFile(int vn, struct iod *iodp,
+                                  FdHandle_t *handleP,
+                                  int tag, Error *status);
 
 
 static void iod_Init(register struct iod *iodp, register struct rx_call *call)
@@ -420,14 +421,18 @@ static int DumpByteString(register struct iod *iodp, char tag,
     return 0;
 }
     
-static int DumpFile(struct iod *iodp, char tag, int vnode, FdHandle_t *handleP)
+static int DumpFile(struct iod *iodp, int vnode, FdHandle_t *handleP)
 {
     int   code = 0, lcode = 0, error = 0;
     afs_int32 pad = 0, offset;
-    int   n, nbytes, howMany, howBig;
+    afs_size_t   n, nbytes, howMany, howBig;
     byte  *p;
+#ifdef AFS_LARGEFILE_ENV
+    struct stat64 status;
+#else
     struct stat status;
-    int size;
+#endif
+    afs_size_t size;
 #ifdef AFS_AIX_ENV
 #include <sys/statfs.h>
     struct statfs tstatfs;
@@ -438,7 +443,11 @@ static int DumpFile(struct iod *iodp, char tag, int vnode, FdHandle_t *handleP)
     howMany = 4096;
 
 #else
+#ifdef AFS_LARGEFILE_ENV
+    fstat64(handleP->fd_fd, &status);
+#else /* !AFS_LARGEFILE_ENV */
     fstat(handleP->fd_fd, &status);
+#endif /* !AFS_LARGEFILE_ENV */
     howBig = status.st_size;
 
 #ifdef AFS_AIX_ENV
@@ -454,7 +463,19 @@ static int DumpFile(struct iod *iodp, char tag, int vnode, FdHandle_t *handleP)
 
 
     size = FDH_SIZE(handleP);
-    code = DumpInt32(iodp, tag, size);
+#ifdef AFS_LARGEFILE_ENV
+    {
+       afs_uint32      hi,lo;
+       SplitInt64(size, hi, lo);
+       if (hi == 0L) {
+           code = DumpInt32(iodp, 'f', lo);
+       } else {
+           code = DumpDouble(iodp, 'h', hi, lo);
+       }
+    }
+#else /* !AFS_LARGEFILE_ENV */
+    code = DumpInt32(iodp, 'f', size);
+#endif /* !AFS_LARGEFILE_ENV */
     if (code) {
        return VOLSERDUMPERROR;
     }
@@ -727,7 +748,7 @@ static int DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v,
            IH_RELEASE(ihP);
            return VOLSERREAD_DUMPERROR;
        }
-       code = DumpFile(iodp, 'f', vnodeNumber, fdP);
+       code = DumpFile(iodp, vnodeNumber, fdP);
        FDH_CLOSE(fdP);
        IH_RELEASE(ihP);
     }
@@ -765,9 +786,19 @@ int ProcessIndex(Volume *vp, VnodeClass class, afs_int32 **Bufp, int *sizep,
                    if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
                        cnt1++;
                        if (DoLogging) {
+#ifdef AFS_LARGEFILE_ENV
+                          afs_offs_t fileLen;
+                          VNDISK_GET_LEN(fileLen, vnode);
+                          Log("RestoreVolume %d Cleanup: Removing old vnode=%d inode=%d size=(0X%x,0X%x)\n", 
+                              V_id(vp), bitNumberToVnodeNumber(i,class),
+                              VNDISK_GET_INO(vnode),
+                              (unsigned) (fileLen >> 32),
+                              (unsigned) (fileLen & 0xffffffff));
+#else /* !AFS_LARGEFILE_ENV */
                           Log("RestoreVolume %d Cleanup: Removing old vnode=%d inode=%d size=%d\n", 
                               V_id(vp), bitNumberToVnodeNumber(i,class),
                               VNDISK_GET_INO(vnode), vnode->length);
+#endif /* !AFS_LARGEFILE_ENV */
                        }
                        IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(vnode),
                             V_parentId(vp));
@@ -977,9 +1008,13 @@ static int ReadVnodes(register struct iod *iodp, Volume *vp,
                                   VAclDiskSize(vnode));
                    acl_NtohACL(VVnodeDiskACL(vnode));
                    break;
+#ifdef AFS_LARGEFILE_ENV
+               case 'h':
+#endif
                case 'f': {
                    Inode ino;
                    Error error;
+                   afs_offs_t fileLen;
 
                    ino = IH_CREATE(V_linkHandle(vp),
                                    V_device(vp),
@@ -1000,8 +1035,10 @@ static int ReadVnodes(register struct iod *iodp, Volume *vp,
                        IH_RELEASE(tmpH);
                        return VOLSERREAD_DUMPERROR;
                    }
-                   vnode->length = volser_WriteFile(vnodeNumber, iodp, fdP,
-                                                    &error);
+                   
+                   fileLen = volser_WriteFile(vnodeNumber, iodp, fdP,
+                                                    tag, &error);
+                   VNDISK_SET_LEN(vnode, fileLen);
                    FDH_REALLYCLOSE(fdP);
                    IH_RELEASE(tmpH);
                    if (error) {
@@ -1069,22 +1106,41 @@ static int ReadVnodes(register struct iod *iodp, Volume *vp,
  * needing to read an ungetc'd character, since the ReadInt32 will have read
  * it instead.
  */
-static bit32 volser_WriteFile(int vn, struct iod *iodp, FdHandle_t *handleP,
-                             Error *status)
+static afs_offs_t volser_WriteFile(int vn, struct iod *iodp, FdHandle_t *handleP,
+                             int tag, Error *status)
 {
     afs_int32 code;
-    afs_uint32 filesize;
-    bit32 written=0;
+    afs_offs_t filesize;
+    afs_offs_t written=0;
     register afs_uint32 size = 8192;
-    register afs_uint32 nbytes;
+    register afs_offs_t nbytes;
     unsigned char *p;
 
 
     *status = 0;
+#ifdef AFS_LARGEFILE_ENV
+    {
+       afs_uint32 filesize_high, filesize_low;
+       if (tag == 'h') {
+           if (!ReadInt32(iodp, &filesize_high) ) {
+               *status = 1;
+               return(0);
+           }
+       } else {
+           filesize_high = 0L;
+       }
+       if (!ReadInt32(iodp, &filesize_low)) {
+           *status = 1;
+           return(0);
+       }
+       FillInt64(filesize, filesize_high, filesize_low);
+    }
+#else /* !AFS_LARGEFILE_ENV */
     if (!ReadInt32(iodp, &filesize)) {
         *status = 1;
        return(0);
     }
+#endif /* !AFS_LARGEFILE_ENV */
     p = (unsigned char *) malloc(size);
     if (p == NULL) {
         *status = 2;
@@ -1095,7 +1151,14 @@ static bit32 volser_WriteFile(int vn, struct iod *iodp, FdHandle_t *handleP,
            size = nbytes;
        
        if ((code = iod_Read(iodp, p, size)) != size) {
+#ifdef AFS_LARGEFILE_ENV
+           Log("1 Volser: WriteFile: Error reading dump file %d size=(0X%x,0X%x) nbytes=%d (%d of %d); restore aborted\n", vn,
+               (unsigned) (filesize >> 32),
+               (unsigned) (filesize & 0xffffffff),
+               nbytes, code, size);
+#else /* !AFS_LARGEFILE_ENV */
            Log("1 Volser: WriteFile: Error reading dump file %d size=%d nbytes=%d (%d of %d); restore aborted\n", vn, filesize, nbytes, code, size);
+#endif /* !AFS_LARGEFILE_ENV */
            *status = 3;
            break;
        }
index c778eab..281861b 100644 (file)
@@ -44,7 +44,7 @@ RCSID("$Header$");
 /* returns 0 on success, errno on failure */
 int ReallyRead (file, block, data)
 DirHandle     *        file;
-int            block;
+afs_size_t     block;
 char         * data;
 {
     FdHandle_t *fdP;
@@ -55,12 +55,12 @@ char              * data;
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, (afs_size_t)(block*AFS_PAGESIZE), SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_READ(fdP, data, AFS_PAGESIZE);
+    code = FDH_READ(fdP, data, (afs_size_t) AFS_PAGESIZE);
     if (code != AFS_PAGESIZE) {
        if (code < 0)
            code = errno;
@@ -76,7 +76,7 @@ char        * data;
 /* returns 0 on success, errno on failure */
 int ReallyWrite (file, block, data)
 DirHandle     *        file;
-int            block;
+afs_size_t     block;
 char         * data;
 {
     FdHandle_t *fdP;
@@ -90,12 +90,12 @@ char              * data;
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block*AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, (afs_size_t)(block*AFS_PAGESIZE), SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_WRITE(fdP, data, AFS_PAGESIZE);
+    code = FDH_WRITE(fdP, data, (afs_size_t) AFS_PAGESIZE);
     if (code != AFS_PAGESIZE) {
        if (code < 0)
            code = errno;
index b928144..fcb8326 100644 (file)
@@ -122,7 +122,7 @@ char buf[BUFSIZE];
 
 char readdata(buffer, size)
   char  *buffer;
-  afs_int32 size;
+  afs_size_t size;
 {
   int   code;
   afs_int32 s;
@@ -384,7 +384,7 @@ struct vNode
     } entries[100];
   } acl;
 #endif
-  afs_int32 dataSize;
+  afs_size_t dataSize;
 };
 
 #define MAXNAMELEN 256
@@ -456,12 +456,24 @@ afs_int32 ReadVNode(count)
              break;
 
           case 'A':
-             readdata(vn.acl, 192);             /* Skip ACL data */
+             readdata(vn.acl, (afs_size_t) 192);  /* Skip ACL data */
              break;
 
+#ifdef AFS_LARGEFILE_ENV
+          case 'h':
+         {
+             afs_uint32 hi, lo;
+             hi = ntohl(readvalue(4));
+             lo = ntohl(readvalue(4));
+             FillInt64(vn.dataSize, hi, lo);
+         }
+         goto common_vnode;
+#endif /* AFS_LARGEFILE_ENV */
+
           case 'f':
-             vn.dataSize = ntohl(readvalue(4));
+             vn.dataSize = (afs_size_t) ntohl(readvalue(4));
 
+      common_vnode:
              /* parentdir is the name of this dir's vnode-file-link
               * or this file's parent vnode-file-link.
               * "./AFSDir-<#>". It's a symbolic link to its real dir.
@@ -637,7 +649,8 @@ afs_int32 ReadVNode(count)
                   */
                  int fid;
                  int lfile;
-                 afs_int32 size, s;
+                 afs_size_t size;
+                 afs_int32 s;
 
                  /* Check if its vnode-file-link exists. If not,
                   * then the file will be an orphaned file.
@@ -661,7 +674,7 @@ afs_int32 ReadVNode(count)
                  fid = open(filename, (O_CREAT | O_WRONLY | O_TRUNC), mode);
                  size = vn.dataSize;
                  while (size > 0) {
-                    s = ((size > BUFSIZE) ? BUFSIZE : size);
+                    s = (afs_int32) ((size > BUFSIZE) ? BUFSIZE : size);
                     code = fread(buf, 1, s, dumpfile);
                     if (code > 0) {
                        write(fid, buf, code);
@@ -671,8 +684,16 @@ afs_int32 ReadVNode(count)
                        if (code < 0)
                           fprintf (stderr, "Code = %d; Errno = %d\n", code, errno);
                        else 
+#ifdef AFS_LARGEFILE_ENV
+                          fprintf (stderr, "Read (0X%x,0X%x) bytes out of (0X%x,0X%x)\n", 
+                                   (unsigned) ((vn.dataSize - size) >> 32),
+                                   (unsigned) ((vn.dataSize - size) & 0xffffffff),
+                                   (unsigned) (vn.dataSize >> 32),
+                                   (unsigned) (vn.dataSize & 0xffffffff));
+#else /* !AFS_LARGEFILE_ENV */
                           fprintf (stderr, "Read %d bytes out of %d\n", 
                                    (vn.dataSize - size), vn.dataSize);
+#endif /* !AFS_LARGEFILE_ENV */
                        break;
                     }
                  }
index d58615b..7266bf5 100644 (file)
@@ -197,7 +197,7 @@ Volume      * vp;
     IHandle_t *h;
     FdHandle_t *fdP;
     int code;
-    int length;
+    afs_offs_t length;
 
     memset(vnode, 0, SIZEOF_LARGEDISKVNODE);    
 
@@ -236,7 +236,7 @@ Volume      * vp;
     vnode->cloned = 0;
     vnode->modeBits = 0777;
     vnode->linkCount = 2;
-    vnode->length = length;
+    VNDISK_SET_LEN(vnode, length);
     vnode->uniquifier = 1;
     V_uniquifier(vp) = vnode->uniquifier+1;
     vnode->dataVersion = 1;
@@ -257,7 +257,8 @@ Volume      * vp;
     assert(code == SIZEOF_LARGEDISKVNODE);
     FDH_REALLYCLOSE(fdP);
     IH_RELEASE(h);
-    V_diskused(vp) = nBlocks(vnode->length);
+    VNDISK_GET_LEN(length, vnode);
+    V_diskused(vp) = nBlocks(length);
 
     return 1;
 }