1: # include "../ingres.h" 2: # include "../access.h" 3: 4: formatpg(d, n) 5: struct descriptor *d; 6: long n; 7: { 8: struct accbuf buf; 9: register char *p; 10: long zero; 11: 12: if (Acc_head == 0) 13: acc_init(); 14: zero = 0; 15: if (lseek(d->relfp, zero, 0) < 0) 16: return (-2); 17: buf.rel_tupid = d->reltid; 18: buf.filedesc = d->relfp; 19: for (p = (char *)&buf; p <= buf.linetab; p++) 20: *p = NULL; 21: buf.nxtlino = 0; 22: buf.linetab[0] = buf.firstup - &buf; 23: buf.ovflopg = 0; 24: for (buf.mainpg = 1; buf.mainpg < n; (buf.mainpg)++) 25: { 26: if (write(buf.filedesc, &buf, PGSIZE) != PGSIZE) 27: return (-3); 28: } 29: buf.mainpg = 0; 30: if (write(buf.filedesc, &buf, PGSIZE) != PGSIZE) 31: return (-4); 32: Accuwrite += n; 33: return (0); 34: }