Make the directory hashtable optional and controled via restore -H
[dump.git] / restore / symtab.c
1 /*
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <stelian@popies.net>, 1999-2000
6 * Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
7 */
8
9 /*
10 * Copyright (c) 1983, 1993
11 * The Regents of the University of California. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 */
37
38 #ifndef lint
39 static const char rcsid[] =
40 "$Id: symtab.c,v 1.27 2005/07/07 09:16:08 stelian Exp $";
41 #endif /* not lint */
42
43 /*
44 * These routines maintain the symbol table which tracks the state
45 * of the file system being restored. They provide lookup by either
46 * name or inode number. They also provide for creation, deletion,
47 * and renaming of entries. Because of the dynamic nature of pathnames,
48 * names should not be saved, but always constructed just before they
49 * are needed, by calling "myname".
50 */
51
52 #include <config.h>
53 #include <compatlfs.h>
54 #include <sys/param.h>
55 #include <sys/stat.h>
56
57 #ifdef __linux__
58 #include <sys/time.h>
59 #include <time.h>
60 #ifdef HAVE_EXT2FS_EXT2_FS_H
61 #include <ext2fs/ext2_fs.h>
62 #else
63 #include <linux/ext2_fs.h>
64 #endif
65 #include <bsdcompat.h>
66 #else /* __linux__ */
67 #ifdef sunos
68 #include <sys/fcntl.h>
69 #include <bsdcompat.h>
70 #else
71 #include <ufs/ufs/dinode.h>
72 #endif
73 #endif /* __linux__ */
74
75 #include <errno.h>
76 #include <compaterr.h>
77 #include <fcntl.h>
78 #include <stdio.h>
79 #include <stdlib.h>
80 #include <string.h>
81 #include <unistd.h>
82
83 #ifdef __linux__
84 #include <ext2fs/ext2fs.h>
85 #endif
86
87 #include "restore.h"
88 #include "extern.h"
89
90 /*
91 * The following variables define the inode symbol table.
92 * The primary hash table is dynamically allocated based on
93 * the number of inodes in the file system (maxino), scaled by
94 * HASHFACTOR. The variable "entry" points to the hash table;
95 * the variable "entrytblsize" indicates its size (in entries).
96 */
97 #define HASHFACTOR 5
98 static struct entry **entry;
99 static long entrytblsize;
100
101 static void addino __P((dump_ino_t, struct entry *));
102 static struct entry *lookupparent __P((char *));
103 static void removeentry __P((struct entry *));
104 static int dir_hash __P((char *));
105
106 /*
107 * Returns a hash given a file name
108 */
109 static int
110 dir_hash(char *name)
111 {
112 unsigned long hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
113 int len = strlen(name);
114
115 while (len--) {
116 unsigned long hash = hash1 + (hash0 ^ (*name++ * 7152373));
117 if (hash & 0x80000000) hash -= 0x7fffffff;
118 hash1 = hash0;
119 hash0 = hash;
120 }
121 return hash0 % dirhash_size;
122 }
123
124 /*
125 * Look up an entry by inode number
126 */
127 struct entry *
128 lookupino(dump_ino_t inum)
129 {
130 struct entry *ep;
131
132 if (inum < WINO || inum >= maxino)
133 return (NULL);
134 for (ep = entry[inum % entrytblsize]; ep != NULL; ep = ep->e_next)
135 if (ep->e_ino == inum)
136 return (ep);
137 return (NULL);
138 }
139
140 /*
141 * Add an entry into the entry table
142 */
143 static void
144 addino(dump_ino_t inum, struct entry *np)
145 {
146 struct entry **epp;
147
148 if (inum < WINO || inum >= maxino)
149 panic("addino: out of range %d\n", inum);
150 epp = &entry[inum % entrytblsize];
151 np->e_ino = inum;
152 np->e_next = *epp;
153 *epp = np;
154 if (dflag)
155 for (np = np->e_next; np != NULL; np = np->e_next)
156 if (np->e_ino == inum)
157 badentry(np, "duplicate inum");
158 }
159
160 /*
161 * Delete an entry from the entry table
162 */
163 void
164 deleteino(dump_ino_t inum)
165 {
166 struct entry *next;
167 struct entry **prev;
168
169 if (inum < WINO || inum >= maxino)
170 panic("deleteino: out of range %d\n", inum);
171 prev = &entry[inum % entrytblsize];
172 for (next = *prev; next != NULL; next = next->e_next) {
173 if (next->e_ino == inum) {
174 next->e_ino = 0;
175 *prev = next->e_next;
176 return;
177 }
178 prev = &next->e_next;
179 }
180 panic("deleteino: %d not found\n", inum);
181 }
182
183 /*
184 * Look up an entry by name
185 */
186 struct entry *
187 lookupname(char *name)
188 {
189 struct entry *ep, *oldep;
190 char *np, *cp;
191 char buf[MAXPATHLEN];
192
193 ep = lookupino(ROOTINO);
194
195 cp = name;
196 if (*cp == '.')
197 ++cp;
198 if (*cp == '/')
199 ++cp;
200 if (*cp == '\0')
201 return ep;
202
203 while (ep != NULL) {
204 for (np = buf; *cp != '/' && *cp != '\0' &&
205 np < &buf[sizeof(buf)]; )
206 *np++ = *cp++;
207 if (np == &buf[sizeof(buf)])
208 break;
209 *np = '\0';
210
211 oldep = ep;
212
213 if (ep->e_entries != NULL) {
214
215 ep = ep->e_entries[dir_hash(buf)];
216 for ( ; ep != NULL; ep = ep->e_sibling)
217 if (strcmp(ep->e_name, buf) == 0)
218 break;
219
220 /* search all hash lists for renamed inodes */
221 if (ep == NULL) {
222 int j;
223 for (j = 0; j < dirhash_size; j++) {
224 ep = oldep->e_entries[j];
225 for ( ; ep != NULL; ep = ep->e_sibling)
226 if (strcmp(ep->e_name, buf) == 0)
227 break;
228 if (ep != NULL)
229 break;
230 }
231 }
232 }
233
234 if (ep == NULL)
235 break;
236 if (*cp++ == '\0')
237 return (ep);
238 }
239 return (NULL);
240 }
241
242 /*
243 * Look up the parent of a pathname
244 */
245 static struct entry *
246 lookupparent(char *name)
247 {
248 struct entry *ep;
249 char *tailindex;
250
251 tailindex = strrchr(name, '/');
252 if (tailindex == NULL)
253 return (NULL);
254 *tailindex = '\0';
255 ep = lookupname(name);
256 *tailindex = '/';
257 if (ep == NULL)
258 return (NULL);
259 if (ep->e_type != NODE)
260 panic("%s is not a directory\n", name);
261 return (ep);
262 }
263
264 /*
265 * Determine the current pathname of a node or leaf
266 */
267 char *
268 myname(struct entry *ep)
269 {
270 char *cp;
271 static char namebuf[MAXPATHLEN];
272
273 for (cp = &namebuf[MAXPATHLEN - 2]; cp > &namebuf[ep->e_namlen]; ) {
274 cp -= ep->e_namlen;
275 memmove(cp, ep->e_name, (size_t)ep->e_namlen);
276 if (ep == lookupino(ROOTINO))
277 return (cp);
278 *(--cp) = '/';
279 ep = ep->e_parent;
280 }
281 panic("%s: pathname too long\n", cp);
282 return(cp);
283 }
284
285 /*
286 * Unused symbol table entries are linked together on a free list
287 * headed by the following pointer.
288 */
289 static struct entry *freelist = NULL;
290
291 /*
292 * add an entry to the symbol table
293 */
294 struct entry *
295 addentry(char *name, dump_ino_t inum, int type)
296 {
297 struct entry *np, *ep;
298
299 if (freelist != NULL) {
300 np = freelist;
301 freelist = np->e_next;
302 memset(np, 0, sizeof(struct entry));
303 } else {
304 np = (struct entry *)calloc(1, sizeof(struct entry));
305 if (np == NULL)
306 errx(1, "no memory to extend symbol table");
307 }
308 np->e_type = type & ~LINK;
309 if (type & NODE) {
310 np->e_entries = calloc(1, dirhash_size * sizeof(struct entry *));
311 if (np->e_entries == NULL)
312 panic("unable to allocate directory entries\n");
313 }
314 ep = lookupparent(name);
315 if (ep == NULL) {
316 if (inum != ROOTINO || lookupino(ROOTINO) != NULL)
317 panic("bad name to addentry %s\n", name);
318 np->e_name = savename(name);
319 np->e_namlen = strlen(name);
320 np->e_parent = np;
321 addino(ROOTINO, np);
322 return (np);
323 }
324 np->e_name = savename(strrchr(name, '/') + 1);
325 np->e_namlen = strlen(np->e_name);
326 np->e_parent = ep;
327 np->e_sibling = ep->e_entries[dir_hash(np->e_name)];
328 ep->e_entries[dir_hash(np->e_name)] = np;
329 if (type & LINK) {
330 ep = lookupino(inum);
331 if (ep == NULL)
332 panic("link to non-existent name\n");
333 np->e_ino = inum;
334 np->e_links = ep->e_links;
335 ep->e_links = np;
336 } else if (inum != 0) {
337 if (lookupino(inum) != NULL)
338 panic("duplicate entry\n");
339 addino(inum, np);
340 }
341 return (np);
342 }
343
344 /*
345 * delete an entry from the symbol table
346 */
347 void
348 freeentry(struct entry *ep)
349 {
350 struct entry *np;
351 dump_ino_t inum;
352
353 if (ep->e_flags != REMOVED)
354 badentry(ep, "not marked REMOVED");
355 if (ep->e_type == NODE) {
356 if (ep->e_links != NULL)
357 badentry(ep, "freeing referenced directory");
358 if (ep->e_entries != NULL) {
359 int i;
360 for (i = 0; i < dirhash_size; i++) {
361 if (ep->e_entries[i] != NULL)
362 badentry(ep, "freeing non-empty directory");
363 }
364 }
365 }
366 if (ep->e_ino != 0) {
367 np = lookupino(ep->e_ino);
368 if (np == NULL)
369 badentry(ep, "lookupino failed");
370 if (np == ep) {
371 inum = ep->e_ino;
372 deleteino(inum);
373 if (ep->e_links != NULL)
374 addino(inum, ep->e_links);
375 } else {
376 for (; np != NULL; np = np->e_links) {
377 if (np->e_links == ep) {
378 np->e_links = ep->e_links;
379 break;
380 }
381 }
382 if (np == NULL)
383 badentry(ep, "link not found");
384 }
385 }
386 removeentry(ep);
387 freename(ep->e_name);
388 ep->e_next = freelist;
389 freelist = ep;
390 }
391
392 /*
393 * Relocate an entry in the tree structure
394 */
395 void
396 moveentry(struct entry *ep, char *newname)
397 {
398 struct entry *np;
399 char *cp;
400
401 np = lookupparent(newname);
402 if (np == NULL)
403 badentry(ep, "cannot move ROOT");
404 if (np != ep->e_parent) {
405 removeentry(ep);
406 ep->e_parent = np;
407 ep->e_sibling = np->e_entries[dir_hash(ep->e_name)];
408 np->e_entries[dir_hash(ep->e_name)] = ep;
409 }
410 cp = strrchr(newname, '/') + 1;
411 freename(ep->e_name);
412 ep->e_name = savename(cp);
413 ep->e_namlen = strlen(cp);
414 if (strcmp(gentempname(ep), ep->e_name) == 0)
415 ep->e_flags |= TMPNAME;
416 else
417 ep->e_flags &= ~TMPNAME;
418 }
419
420 /*
421 * Remove an entry in the tree structure
422 */
423 static void
424 removeentry(struct entry *ep)
425 {
426 struct entry *np = ep->e_parent;
427 struct entry *entry = np->e_entries[dir_hash(ep->e_name)];
428
429 if (entry == ep) {
430 np->e_entries[dir_hash(ep->e_name)] = ep->e_sibling;
431 } else {
432 for (np = entry; np != NULL; np = np->e_sibling) {
433 if (np->e_sibling == ep) {
434 np->e_sibling = ep->e_sibling;
435 break;
436 }
437 }
438 if (np == NULL) {
439
440 /* search all hash lists for renamed inodes */
441 int j;
442 for (j = 0; j < dirhash_size; j++) {
443 np = ep->e_parent;
444 entry = np->e_entries[j];
445 if (entry == ep) {
446 np->e_entries[j] = ep->e_sibling;
447 return;
448 }
449 else {
450 for (np = entry; np != NULL; np = np->e_sibling) {
451 if (np->e_sibling == ep) {
452 np->e_sibling = ep->e_sibling;
453 return;
454 }
455 }
456 }
457 }
458 badentry(ep, "cannot find entry in parent list");
459 }
460 }
461 }
462
463 /*
464 * Table of unused string entries, sorted by length.
465 *
466 * Entries are allocated in STRTBLINCR sized pieces so that names
467 * of similar lengths can use the same entry. The value of STRTBLINCR
468 * is chosen so that every entry has at least enough space to hold
469 * a "struct strtbl" header. Thus every entry can be linked onto an
470 * appropriate free list.
471 *
472 * NB. The macro "allocsize" below assumes that "struct strhdr"
473 * has a size that is a power of two.
474 */
475 struct strhdr {
476 struct strhdr *next;
477 };
478
479 #define STRTBLINCR (sizeof(struct strhdr))
480 #define allocsize(size) (((size) + 1 + STRTBLINCR - 1) & ~(STRTBLINCR - 1))
481
482 static struct strhdr strtblhdr[allocsize(MAXNAMLEN) / STRTBLINCR];
483
484 /*
485 * Allocate space for a name. It first looks to see if it already
486 * has an appropriate sized entry, and if not allocates a new one.
487 */
488 char *
489 savename(char *name)
490 {
491 struct strhdr *np;
492 long len;
493 char *cp;
494
495 if (name == NULL)
496 panic("bad name\n");
497 len = strlen(name);
498 np = strtblhdr[len / STRTBLINCR].next;
499 if (np != NULL) {
500 strtblhdr[len / STRTBLINCR].next = np->next;
501 cp = (char *)np;
502 } else {
503 cp = malloc((unsigned)allocsize(len));
504 if (cp == NULL)
505 errx(1, "no space for string table");
506 }
507 (void) strcpy(cp, name);
508 return (cp);
509 }
510
511 /*
512 * Free space for a name. The resulting entry is linked onto the
513 * appropriate free list.
514 */
515 void
516 freename(char *name)
517 {
518 struct strhdr *tp, *np;
519
520 tp = &strtblhdr[strlen(name) / STRTBLINCR];
521 np = (struct strhdr *)name;
522 np->next = tp->next;
523 tp->next = np;
524 }
525
526 /*
527 * Useful quantities placed at the end of a dumped symbol table.
528 */
529 struct symtableheader {
530 int32_t volno;
531 int32_t stringsize;
532 int32_t hashsize;
533 int32_t entrytblsize;
534 time_t dumptime;
535 time_t dumpdate;
536 dump_ino_t maxino;
537 int32_t ntrec;
538 int32_t zflag;
539 };
540
541 /*
542 * dump a snapshot of the symbol table
543 */
544 void
545 dumpsymtable(char *filename, long checkpt)
546 {
547 struct entry *ep, *tep;
548 dump_ino_t i;
549 struct entry temp, *tentry;
550 long mynum = 1, stroff = 0, hashoff = 0;
551 FILE *fd;
552 struct symtableheader hdr;
553 struct entry **temphash;
554
555 Vprintf(stdout, "Check pointing the restore\n");
556 if (Nflag)
557 return;
558 if ((fd = FOPEN(filename, "w")) == NULL) {
559 warn("fopen");
560 panic("cannot create save file %s for symbol table\n",
561 filename);
562 }
563 clearerr(fd);
564 /*
565 * Assign indices to each entry
566 * Write out the string entries
567 */
568 for (i = WINO; i <= maxino; i++) {
569 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
570 ep->e_index = mynum++;
571 (void) fwrite(ep->e_name, sizeof(char),
572 (int)allocsize(ep->e_namlen), fd);
573 }
574 }
575 /*
576 * Write out e_entries tables
577 */
578 temphash = calloc(1, dirhash_size * sizeof(struct entry *));
579 if (temphash == NULL)
580 errx(1, "no memory for saving hashtable");
581 for (i = WINO; i <= maxino; i++) {
582 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
583 if (ep->e_entries != NULL) {
584 int j;
585 memcpy(temphash, ep->e_entries, dirhash_size * sizeof(struct entry *));
586 for (j = 0; j < dirhash_size; j++) {
587 if (temphash[j])
588 temphash[j] = (struct entry *)ep->e_entries[j]->e_index;
589 }
590 fwrite(temphash, dirhash_size, sizeof(struct entry *), fd);
591 }
592 }
593 }
594 free(temphash);
595
596 /*
597 * Convert pointers to indexes, and output
598 */
599 tep = &temp;
600 stroff = 0;
601 hashoff = 0;
602 for (i = WINO; i <= maxino; i++) {
603 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
604 memmove(tep, ep, sizeof(struct entry));
605 tep->e_name = (char *)stroff;
606 stroff += allocsize(ep->e_namlen);
607 tep->e_parent = (struct entry *)ep->e_parent->e_index;
608 if (ep->e_links != NULL)
609 tep->e_links =
610 (struct entry *)ep->e_links->e_index;
611 if (ep->e_sibling != NULL)
612 tep->e_sibling =
613 (struct entry *)ep->e_sibling->e_index;
614 if (ep->e_entries != NULL) {
615 tep->e_entries = (struct entry **)hashoff;
616 hashoff += dirhash_size * sizeof(struct entry *);
617 }
618 if (ep->e_next != NULL)
619 tep->e_next =
620 (struct entry *)ep->e_next->e_index;
621 (void) fwrite((char *)tep, sizeof(struct entry), 1, fd);
622 }
623 }
624 /*
625 * Convert entry pointers to indexes, and output
626 */
627 for (i = 0; (long)i < entrytblsize; i++) {
628 if (entry[i] == NULL)
629 tentry = NULL;
630 else
631 tentry = (struct entry *)entry[i]->e_index;
632 (void) fwrite((char *)&tentry, sizeof(struct entry *), 1, fd);
633 }
634 hdr.volno = checkpt;
635 hdr.maxino = maxino;
636 hdr.entrytblsize = entrytblsize;
637 hdr.stringsize = stroff;
638 hdr.hashsize = hashoff;
639 hdr.dumptime = dumptime;
640 hdr.dumpdate = dumpdate;
641 hdr.ntrec = ntrec;
642 hdr.zflag = zflag;
643 (void) fwrite((char *)&hdr, sizeof(struct symtableheader), 1, fd);
644 if (ferror(fd)) {
645 warn("fwrite");
646 panic("output error to file %s writing symbol table\n",
647 filename);
648 }
649 (void) fclose(fd);
650 }
651
652 /*
653 * Initialize a symbol table from a file
654 */
655 void
656 initsymtable(char *filename)
657 {
658 char *base;
659 long tblsize;
660 struct entry *ep;
661 struct entry *baseep, *lep;
662 struct symtableheader hdr;
663 struct STAT stbuf;
664 long i;
665 int fd;
666
667 Vprintf(stdout, "Initialize symbol table.\n");
668 if (filename == NULL) {
669 entrytblsize = maxino / HASHFACTOR;
670 entry = (struct entry **)
671 calloc((unsigned)entrytblsize, sizeof(struct entry *));
672 if (entry == (struct entry **)NULL)
673 errx(1, "no memory for entry table");
674 ep = addentry(".", ROOTINO, NODE);
675 ep->e_flags |= NEW;
676 return;
677 }
678 if ((fd = OPEN(filename, O_RDONLY, 0)) < 0) {
679 warn("open");
680 errx(1, "cannot open symbol table file %s", filename);
681 }
682 if (FSTAT(fd, &stbuf) < 0) {
683 warn("stat");
684 errx(1, "cannot stat symbol table file %s", filename);
685 }
686 tblsize = stbuf.st_size - sizeof(struct symtableheader);
687 base = calloc(sizeof(char), (unsigned)tblsize);
688 if (base == NULL)
689 errx(1, "cannot allocate space for symbol table");
690 if (read(fd, base, (int)tblsize) < 0 ||
691 read(fd, (char *)&hdr, sizeof(struct symtableheader)) < 0) {
692 warn("read");
693 errx(1, "cannot read symbol table file %s", filename);
694 }
695 switch (command) {
696 case 'r':
697 /*
698 * For normal continuation, insure that we are using
699 * the next incremental tape
700 */
701 if (hdr.dumpdate != dumptime)
702 errx(1, "Incremental tape too %s",
703 (hdr.dumpdate < dumptime) ? "low" : "high");
704 break;
705 case 'R':
706 /*
707 * For restart, insure that we are using the same tape
708 */
709 curfile.action = SKIP;
710 dumptime = hdr.dumptime;
711 dumpdate = hdr.dumpdate;
712 zflag = hdr.zflag;
713 if (!bflag)
714 newtapebuf(hdr.ntrec);
715 getvol(hdr.volno);
716 break;
717 default:
718 panic("initsymtable called from command %c\n", command);
719 break;
720 }
721 if (hdr.maxino > maxino) {
722 resizemaps(maxino, hdr.maxino);
723 maxino = hdr.maxino;
724 }
725 entrytblsize = hdr.entrytblsize;
726 entry = (struct entry **)
727 (base + tblsize - (entrytblsize * sizeof(struct entry *)));
728 baseep = (struct entry *)(base + hdr.stringsize + hdr.hashsize - sizeof(struct entry));
729 lep = (struct entry *)entry;
730 for (i = 0; i < entrytblsize; i++) {
731 if (entry[i] == NULL)
732 continue;
733 entry[i] = &baseep[(long)entry[i]];
734 }
735 for (ep = &baseep[1]; ep < lep; ep++) {
736 ep->e_name = base + (long)ep->e_name;
737 ep->e_parent = &baseep[(long)ep->e_parent];
738 if (ep->e_sibling != NULL)
739 ep->e_sibling = &baseep[(long)ep->e_sibling];
740 if (ep->e_links != NULL)
741 ep->e_links = &baseep[(long)ep->e_links];
742 if (ep->e_type == NODE) {
743 int i;
744 ep->e_entries = (struct entry **)(base + hdr.stringsize + (long)ep->e_entries);
745 for (i = 0; i < dirhash_size; i++) {
746 if (ep->e_entries[i])
747 ep->e_entries[i] = &baseep[(long)ep->e_entries[i]];
748 }
749 }
750 else
751 ep->e_entries = NULL;
752 if (ep->e_next != NULL)
753 ep->e_next = &baseep[(long)ep->e_next];
754 }
755 }