ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holofile.c
(Generate patch)

Comparing ray/src/hd/holofile.c (file contents):
Revision 3.5 by gregl, Wed Nov 5 17:28:49 1997 UTC vs.
Revision 3.8 by gregl, Tue Nov 11 11:31:54 1997 UTC

# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ SGI";
22   #define PCTFREE         20      /* maximum fraction to free (%) */
23   #endif
24  
25 < #define MAXFRAG         (128*FRAGBLK)   /* maximum fragments per file */
25 > /* define MAXFRAG if you want to limit fragment tracking memory */
26  
27 + #ifndef BSD
28 + #define write   writebuf        /* safe i/o routines */
29 + #define read    readbuf
30 + #endif
31 +
32   #define FRAGBLK         64      /* number of fragments to allocate at a time */
33  
34   int     hdcachesize = CACHESIZE*1024*1024;      /* target cache size (bytes) */
# Line 68 | Line 73 | register int   fd;
73   hdrelease(fd)           /* stop tracking file fragments for some section */
74   register int    fd;
75   {
76 <        if (fd >= nhdfrags || !hdfrag[fd].nlinks)
76 >        if (fd < 0 | fd >= nhdfrags || !hdfrag[fd].nlinks)
77                  return;
78          if (!--hdfrag[fd].nlinks && hdfrag[fd].nfrags) {
79                  free((char *)hdfrag[fd].fi);
# Line 78 | Line 83 | register int   fd;
83   }
84  
85  
86 + markdirty(hp)                   /* mark holodeck section directory dirty */
87 + register HOLO   *hp;
88 + {
89 +        static BEAMI    smudge = {0, -1};
90 +
91 +        if (hp->dirty)          /* already marked? */
92 +                return;
93 +        hp->dirty = 1;
94 +        if (lseek(hp->fd, biglob(hp)->fo+(nbeams(hp)-1)*sizeof(BEAMI), 0) < 0
95 +                        || write(hp->fd, (char *)&smudge,
96 +                                        sizeof(BEAMI)) != sizeof(BEAMI))
97 +                error(SYSTEM, "seek/write error in markdirty");
98 + }
99 +
100 +
101   HOLO *
102   hdinit(fd, hproto)      /* initialize a holodeck section in a file */
103   int     fd;                     /* corresponding file descriptor */
# Line 102 | Line 122 | HDGRID *hproto;                /* holodeck section grid */
122                  n = nbeams(hp)*sizeof(BEAMI);
123                  if (read(fd, (char *)(hp->bi+1), n) != n)
124                          error(SYSTEM, "failure loading holodeck directory");
125 +                                                /* check that it's clean */
126 +                if (hp->bi[nbeams(hp)].fo < 0)
127 +                        error(USER, "dirty holodeck section");
128          } else {                        /* assume we're creating it */
129                  if ((hp = hdalloc(hproto)) == NULL)
130                          goto memerr;
# Line 188 | Line 211 | int    all;                    /* include overhead (painful) */
211  
212  
213   long
214 + hdfilen(fd)             /* return file length for fd */
215 + int     fd;
216 + {
217 +        long    fpos, flen;
218 +
219 +        if (fd < 0)
220 +                return(-1);
221 +        if (fd >= nhdfrags || !hdfrag[fd].nlinks) {
222 +                if ((fpos = lseek(fd, 0L, 1)) < 0)
223 +                        return(-1);
224 +                flen = lseek(fd, 0L, 2);
225 +                lseek(fd, fpos, 0);
226 +                return(flen);
227 +        }
228 +        return(hdfrag[fd].flen);
229 + }
230 +
231 +
232 + long
233   hdfiluse(fd, all)       /* compute file usage (in bytes) */
234   int     fd;                     /* open file descriptor to check */
235   int     all;                    /* include overhead and unflushed data */
# Line 375 | Line 417 | register int   i;
417          }
418          biglob(hp)->nrd += nrays - hp->bi[i].nrd;
419          hp->bi[i].nrd = nrays;
420 <        hp->dirty++;            /* section directory now out of date */
420 >        markdirty(hp);          /* section directory now out of date */
421          return(1);
422   }
423  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines