DRead-check-file-size-20021113
[openafs.git] / src / afs / afs_buffer.c
index dad53c5..4c8556c 100644 (file)
@@ -8,42 +8,42 @@
  */
 
 #include <afsconfig.h>
-#include "../afs/param.h"
+#include "afs/param.h"
 
 RCSID("$Header$");
 
-#include "../afs/sysincludes.h"
-#include "../afs/afsincludes.h"
+#include "afs/sysincludes.h"
+#include "afsincludes.h"
 #if !defined(UKERNEL)
-#include "../h/param.h"
-#include "../h/types.h"
-#include "../h/time.h"
+#include "h/param.h"
+#include "h/types.h"
+#include "h/time.h"
 #if    defined(AFS_AIX31_ENV) || defined(AFS_DEC_ENV)
-#include "../h/limits.h"
+#include "h/limits.h"
 #endif
 #if    !defined(AFS_AIX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV)
-#include "../h/kernel.h"    /* Doesn't needed, so it should go */
+#include "h/kernel.h"    /* Doesn't needed, so it should go */
 #endif
 #endif /* !defined(UKERNEL) */
 
-#include "../afs/afs_osi.h"
-#include "../afsint/afsint.h"
-#include "../afs/lock.h"
+#include "afs/afs_osi.h"
+#include "afsint.h"
+#include "afs/lock.h"
 
 #if !defined(UKERNEL) && !defined(AFS_LINUX20_ENV)
-#include "../h/buf.h"
+#include "h/buf.h"
 #endif /* !defined(UKERNEL) */
 
-#include "../afs/stds.h"
-#include "../afs/volerrors.h"
-#include "../afs/exporter.h"
-#include "../afs/prs_fs.h"
-#include "../afs/afs_chunkops.h"
-#include "../afs/dir.h"
+#include "afs/stds.h"
+#include "afs/volerrors.h"
+#include "afs/exporter.h"
+#include "afs/prs_fs.h"
+#include "afs/afs_chunkops.h"
+#include "afs/dir.h"
 
-#include "../afs/afs_stats.h"
-#include "../afs/longc_procs.h"
-#include "../afs/afs.h"
+#include "afs/afs_stats.h"
+#include "afs/longc_procs.h"
+#include "afs/afs.h"
 
 #ifndef        BUF_TIME_MAX
 #define        BUF_TIME_MAX    0x7fffffff
@@ -147,13 +147,12 @@ char *DRead(register afs_inode_t *fid, register int page)
 {
     /* Read a page from the disk. */
     register struct buffer *tb, *tb2;
-    void *tfile;
-    register afs_int32 code, *sizep;
+    struct osi_file *tfile;
+    int code;
 
     AFS_STATCNT(DRead);
     MObtainWriteLock(&afs_bufferLock,256);
 
-/* some new code added 1/1/92 */
 #define bufmatch(tb) (tb->page == page && dirp_Eq(tb->fid, fid))
 #define buf_Front(head,parent,p) {(parent)->hashNext = (p)->hashNext; (p)->hashNext= *(head);*(head)=(p);}
 
@@ -213,20 +212,19 @@ char *DRead(register afs_inode_t *fid, register int page)
      */
     tb = afs_newslot(fid, page, (tb ? tb : tb2));
     if (!tb) {
-      MReleaseWriteLock(&afs_bufferLock);
-      return 0;
+       MReleaseWriteLock(&afs_bufferLock);
+       return NULL;
     }
     MObtainWriteLock(&tb->lock,260);
     MReleaseWriteLock(&afs_bufferLock);
     tb->lockers++;
     tfile = afs_CFileOpen(fid[0]);
-    sizep = (afs_int32 *)tfile;
-    if (page * AFS_BUFFER_PAGESIZE >= *sizep) {
+    if (page * AFS_BUFFER_PAGESIZE >= tfile->size) {
        dirp_Zap(tb->fid);
        tb->lockers--;
        MReleaseWriteLock(&tb->lock);
        afs_CFileClose(tfile);
-       return 0;
+       return NULL;
     }
     code = afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE,
                         tb->data, AFS_BUFFER_PAGESIZE);
@@ -235,7 +233,7 @@ char *DRead(register afs_inode_t *fid, register int page)
        dirp_Zap(tb->fid);
        tb->lockers--;
        MReleaseWriteLock(&tb->lock);
-       return 0;
+       return NULL;
     }
     /* Note that findslot sets the page field in the buffer equal to
      * what it is searching for. */
@@ -273,7 +271,7 @@ static struct buffer *afs_newslot (afs_inode_t *afid, afs_int32 apage,register s
     register afs_int32 i;
     afs_int32 lt;
     register struct buffer *tp;
-    void *tfile;
+    struct osi_file *tfile;
 
     AFS_STATCNT(afs_newslot);
     /* we take a pointer here to a buffer which was at the end of an
@@ -444,7 +442,7 @@ void DFlush (void)
     /* Flush all the modified buffers. */
     register int i;
     register struct buffer *tb;
-    void *tfile;
+    struct osi_file *tfile;
 
     AFS_STATCNT(DFlush);
     tb = Buffers;