--- ray/src/hd/holofile.c 2003/05/15 05:13:35 3.45 +++ ray/src/hd/holofile.c 2003/05/29 16:26:21 3.46 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: holofile.c,v 3.45 2003/05/15 05:13:35 greg Exp $"; +static const char RCSid[] = "$Id: holofile.c,v 3.46 2003/05/29 16:26:21 greg Exp $"; #endif /* * Routines for managing holodeck files @@ -52,7 +52,7 @@ static struct fraglist { short writable; /* 0 read-only, <0 write error encountered */ int nfrags; /* number of known fragments */ BEAMI *fi; /* fragments, descending file position */ - long flen; /* last known file length */ + off_t flen; /* last known file length */ } *hdfragl; /* fragment lists, indexed by file descriptor */ static int nhdfragls; /* size of hdfragl array */ @@ -154,8 +154,8 @@ hdinit(fd, hproto) /* initialize a holodeck section in int fd; /* corresponding file descriptor */ HDGRID *hproto; /* holodeck section grid */ { - long rtrunc; - long fpos; + off_t rtrunc; + off_t fpos; int writable; register HOLO *hp; register int n; @@ -186,7 +186,7 @@ HDGRID *hproto; /* holodeck section grid */ if (fd < nhdfragls && hdfragl[fd].nlinks) writable = hdfragl[fd].writable; else - writable = lseek(fd, (off_t)fpos, 0) == fpos && + writable = lseek(fd, fpos, 0) == fpos && write(fd, (char *)hp, sizeof(HDGRID)) == sizeof(HDGRID); } else { /* else assume we're creating it */ @@ -242,7 +242,7 @@ int i; register int j; if (!hp->dirty++) { /* write smudge first time */ - if (lseek(hp->fd, (off_t)(biglob(hp)->fo+(i-1)*sizeof(BEAMI)), 0) < 0 + if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), 0) < 0 || write(hp->fd, (char *)&smudge, sizeof(BEAMI)) != sizeof(BEAMI)) error(SYSTEM, "seek/write error in hdmarkdirty"); @@ -305,8 +305,8 @@ int all; return(0); errno = 0; /* write dirty segments */ for (j = 0; j < hp->dirty; j++) { - if (lseek(hp->fd, (off_t)(biglob(hp)->fo + - (hp->dirseg[j].s-1)*sizeof(BEAMI)), 0) < 0) + if (lseek(hp->fd, biglob(hp)->fo + + (hp->dirseg[j].s-1)*sizeof(BEAMI), 0) < 0) error(SYSTEM, "cannot seek on holodeck file"); n = hp->dirseg[j].n * sizeof(BEAMI); if (write(hp->fd, (char *)(hp->bi+hp->dirseg[j].s), n) != n) @@ -346,11 +346,11 @@ int all; /* include overhead (painful) */ } -long +off_t hdfilen(fd) /* return file length for fd */ int fd; { - long fpos, flen; + off_t fpos, flen; if (fd < 0) return(-1); @@ -358,19 +358,19 @@ int fd; if ((fpos = lseek(fd, (off_t)0L, 1)) < 0) return(-1); flen = lseek(fd, (off_t)0L, 2); - lseek(fd, (off_t)fpos, 0); + lseek(fd, fpos, 0); return(flen); } return(hdfragl[fd].flen); } -long +off_t hdfiluse(fd, all) /* compute file usage (in bytes) */ int fd; /* open file descriptor to check */ int all; /* include overhead and unflushed data */ { - long total = 0; + off_t total = 0; register int i, j; for (j = 0; hdlist[j] != NULL; j++) { @@ -413,7 +413,7 @@ int nr; /* number of new rays desired */ blglob(hp)->nrm += n; if ((n = hp->bl[i]->nrm = hp->bi[i].nrd)) { errno = 0; - if (lseek(hp->fd, (off_t)hp->bi[i].fo, 0) < 0) + if (lseek(hp->fd, hp->bi[i].fo, 0) < 0) error(SYSTEM, "seek error on holodeck file"); n *= sizeof(RAYVAL); if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) @@ -452,7 +452,7 @@ register int i; hp->bl[i] = (BEAM *)hdrealloc(NULL, hdbsiz(n), "hdgetbeam"); blglob(hp)->nrm += hp->bl[i]->nrm = n; errno = 0; - if (lseek(hp->fd, (off_t)hp->bi[i].fo, 0) < 0) + if (lseek(hp->fd, hp->bi[i].fo, 0) < 0) error(SYSTEM, "seek error on holodeck file"); n *= sizeof(RAYVAL); if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) @@ -632,14 +632,14 @@ register int4 *listsiz; } -long +off_t hdallocfrag(fd, nrays) /* allocate a file fragment */ int fd; unsigned int4 nrays; { register struct fraglist *f; register int j; - long nfo; + off_t nfo; if (nrays == 0) return(-1L); @@ -669,7 +669,7 @@ register int i; int fragfreed; unsigned int4 nrays; unsigned int n; - long nfo; + off_t nfo; /* check file status */ if (hdfragl[hp->fd].writable <= 0) return(hdfragl[hp->fd].writable); @@ -683,7 +683,7 @@ register int i; if (nrays) { /* get and write new fragment */ nfo = hdallocfrag(hp->fd, nrays); errno = 0; - if (lseek(hp->fd, (off_t)nfo, 0) < 0) + if (lseek(hp->fd, nfo, 0) < 0) error(SYSTEM, "cannot seek on holodeck file"); n = hp->bl[i]->nrm * sizeof(RAYVAL); if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) {