10 werrstr("bad block size %#ux", n);
16 // _VtEntryBig integer format is floating-point:
18 // Convert this number; must be exact or return -1.
27 while(n >= (1<<(16 - 5))) {
35 if(((n>>5)<<(n&31)) != n0)
36 sysfatal("vttobig %#lux => %#lux failed", n0, n);
41 vtentrypack(VtEntry *e, uchar *p, int index)
49 p += index * VtEntrySize;
52 depth = e->type&VtTypeDepthMask;
53 flags = (e->flags&~(_VtEntryDir|_VtEntryDepthMask));
54 flags |= depth << _VtEntryDepthShift;
55 if(e->type - depth == VtDirType)
61 if(psize >= (1<<16) || dsize >= (1<<16)) {
63 psize = vttobig(psize);
64 dsize = vttobig(dsize);
65 if(psize < 0 || dsize < 0)
66 sysfatal("invalid entry psize/dsize: %ld/%ld", e->psize, e->dsize);
76 U48PUT(p, e->size, t32);
78 memmove(p, e->score, VtScoreSize);
81 assert(p-op == VtEntrySize);
85 vtentryunpack(VtEntry *e, uchar *p, int index)
89 p += index * VtEntrySize;
100 if(e->flags & _VtEntryBig) {
101 e->psize = (e->psize>>5)<<(e->psize & 31);
102 e->dsize = (e->dsize>>5)<<(e->dsize & 31);
104 e->type = (e->flags&_VtEntryDir) ? VtDirType : VtDataType;
105 e->type += (e->flags & _VtEntryDepthMask) >> _VtEntryDepthShift;
106 e->flags &= ~(_VtEntryDir|_VtEntryDepthMask|_VtEntryBig);
110 memmove(e->score, p, VtScoreSize);
113 assert(p-op == VtEntrySize);
115 if(!(e->flags & VtEntryActive))
119 * Some old vac files use psize==0 and dsize==0 when the
120 * file itself has size 0 or is zeros. Just to make programs not
121 * have to figure out what block sizes of 0 means, rewrite them.
123 if(e->psize == 0 && e->dsize == 0
124 && memcmp(e->score, vtzeroscore, VtScoreSize) == 0){
128 if(checksize(e->psize) < 0 || checksize(e->dsize) < 0)