From - Thu Oct 23 07:38:08 1997 Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news.aloha.net!news.gstis.net!zinger.callamer.com!news1.crl.com!nntp2.crl.com!nntp3.crl.com!news.gv.tsc.tdk.com!newsfeed.wli.net!su-news-hub1.bbnplanet.com!news.bbnplanet.com!news1.digital.com!pa.dec.com!usenet From: hoffman@xdelta.enet.dec.nospam (Stephen Hoff Hoffman) Newsgroups: comp.os.vms Subject: C stat() and 2GB files (was Re: Problem ZIPing 2gig file) Date: 22 Oct 1997 20:03:16 GMT Organization: Digital Equipment Corp Lines: 45 Distribution: world Message-ID: <62lm64$vsl@usenet.pa.dec.com> References: <1997Oct22.115415@alpha.vitro.com> Reply-To: hoffman@xdelta.zko.dec.nospam NNTP-Posting-Host: xdelta.zko.dec.com X-Newsreader: mxrn 6.18-32 In article <1997Oct22.115415@alpha.vitro.com>, vaxs09@alpha.vitro.com (John Briggs) writes: .. :The problem is that the file size is stored in a signed longword and :tested for values less than -2. (-2 and -1 are used as codes indicating :special file types). : :I started to hack up my copy of ZIP to use 64 bit integers and got the :thing to compile OK. But that just pushes the problem back. ZIP is :using stat() to return the file size and stat returns a longword. .. The C RTL stat() st_size field can overflow at present, due to the way the calculations are performed. The following is a suggestion from one of the DEC C RTL engineers: | I would recommend the following approach: | | 1. Open the file using the "ACC" callback to grab the address of the | RMS FAB used for the file. | | 2. Once the open returns, use the saved FAB address to locate the | address of the XABFHC block walking through the XAB's. | | 3. Use the following calculation: | | unsigned __int64 mysize; | if (fhc->xab$l_ebk != 0) | mysize = (fhc->xab$l_ebk - 1) * 512 + fhc->xab$w_ffb; | else mysize = fhc->xab$l_hbk * 512 + fhc->xab$w_ffb; | | 4. Close the file The engineer then goes on to admit that this is neither the cleanest nor the prettiest of solutions. :-) There are folks on the C team looking at ways of allowing off_t and other similar structure fields to expand to 64 bits, but this won't happen immediately. -------------------------- pure personal opinion --------------------------- Hoff (Stephen) Hoffman OpenVMS Engineering h*ffman@xdelta.enet.dec.c*m headers and addresses munged to avoid automated spammers: junk-e-mail