1: # include   "../ingres.h"
   2: # include   "../access.h"
   3: # include   "../unix.h"
   4: 
   5: /*
   6: **	LAST_PAGE -- computes a tid for the last page in the relation.
   7: */
   8: 
   9: last_page(dx, tidx, bufx)
  10: struct descriptor   *dx;
  11: struct tup_id       *tidx;
  12: struct accbuf       *bufx;
  13: {
  14:     register struct descriptor  *d;
  15:     register struct tup_id      *tid;
  16:     register struct accbuf      *buf;
  17:     long                lpage;
  18:     struct stat         stats;
  19: 
  20:     d = dx;
  21:     tid = tidx;
  22:     buf = bufx;
  23:     if ((buf != 0) && (abs(d->relspec) == M_HEAP) && (buf->mainpg == 0) && (buf->ovflopg == 0))
  24:         lpage = buf->thispage;
  25:     else
  26:     {
  27:         if (fstat(d->relfp, &stats) < 0)
  28:             syserr("last_page: fstat err %.14s", d->relid);
  29: #		ifdef xV6_UNIX
  30:         lpage = ((stats.st_sz1 >> 9) & 0177) + ((stats.st_sz0 & 0377) << 7) - 1;
  31: #		endif
  32: #		ifdef xB_UNIX
  33:         lpage = ((stats.st_sz1 >> 9) & 0177) + ((stats.st_sz0 & 0377) << 7) - 1;
  34: #		endif
  35: #		ifndef xV6_UNIX
  36: #		ifndef xB_UNIX
  37:         lpage = stats.st_size / PGSIZE - 1;
  38: #		endif
  39: #		endif
  40: #		ifdef xATR2
  41:         if (tTf(86, 2))
  42:             printf("fstat-lp %.12s %s\n", d->relid, locv(lpage));
  43: #		endif
  44:     }
  45:     stuff_page(tid, &lpage);
  46:     tid->line_id = 0;
  47:     return (0);
  48: }
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 577
Valid CSS Valid XHTML 1.0 Strict