]> git.wh0rd.org - dump.git/blob - restore/symtab.c
Fix restore when symtab file is over 2GB in size.
[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.26 2005/07/07 08:47:16 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[DIRHASH_SIZE];
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 for (i = WINO; i <= maxino; i++) {
579 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
580 if (ep->e_entries != NULL) {
581 int j;
582 memcpy(temphash, ep->e_entries, DIRHASH_SIZE * sizeof(struct entry *));
583 for (j = 0; j < DIRHASH_SIZE; j++) {
584 if (temphash[j])
585 temphash[j] = (struct entry *)ep->e_entries[j]->e_index;
586 }
587 fwrite(temphash, DIRHASH_SIZE, sizeof(struct entry *), fd);
588 }
589 }
590 }
591 /*
592 * Convert pointers to indexes, and output
593 */
594 tep = &temp;
595 stroff = 0;
596 hashoff = 0;
597 for (i = WINO; i <= maxino; i++) {
598 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
599 memmove(tep, ep, sizeof(struct entry));
600 tep->e_name = (char *)stroff;
601 stroff += allocsize(ep->e_namlen);
602 tep->e_parent = (struct entry *)ep->e_parent->e_index;
603 if (ep->e_links != NULL)
604 tep->e_links =
605 (struct entry *)ep->e_links->e_index;
606 if (ep->e_sibling != NULL)
607 tep->e_sibling =
608 (struct entry *)ep->e_sibling->e_index;
609 if (ep->e_entries != NULL) {
610 tep->e_entries = (struct entry **)hashoff;
611 hashoff += DIRHASH_SIZE * sizeof(struct entry *);
612 }
613 if (ep->e_next != NULL)
614 tep->e_next =
615 (struct entry *)ep->e_next->e_index;
616 (void) fwrite((char *)tep, sizeof(struct entry), 1, fd);
617 }
618 }
619 /*
620 * Convert entry pointers to indexes, and output
621 */
622 for (i = 0; (long)i < entrytblsize; i++) {
623 if (entry[i] == NULL)
624 tentry = NULL;
625 else
626 tentry = (struct entry *)entry[i]->e_index;
627 (void) fwrite((char *)&tentry, sizeof(struct entry *), 1, fd);
628 }
629 hdr.volno = checkpt;
630 hdr.maxino = maxino;
631 hdr.entrytblsize = entrytblsize;
632 hdr.stringsize = stroff;
633 hdr.hashsize = hashoff;
634 hdr.dumptime = dumptime;
635 hdr.dumpdate = dumpdate;
636 hdr.ntrec = ntrec;
637 hdr.zflag = zflag;
638 (void) fwrite((char *)&hdr, sizeof(struct symtableheader), 1, fd);
639 if (ferror(fd)) {
640 warn("fwrite");
641 panic("output error to file %s writing symbol table\n",
642 filename);
643 }
644 (void) fclose(fd);
645 }
646
647 /*
648 * Initialize a symbol table from a file
649 */
650 void
651 initsymtable(char *filename)
652 {
653 char *base;
654 long tblsize;
655 struct entry *ep;
656 struct entry *baseep, *lep;
657 struct symtableheader hdr;
658 struct STAT stbuf;
659 long i;
660 int fd;
661
662 Vprintf(stdout, "Initialize symbol table.\n");
663 if (filename == NULL) {
664 entrytblsize = maxino / HASHFACTOR;
665 entry = (struct entry **)
666 calloc((unsigned)entrytblsize, sizeof(struct entry *));
667 if (entry == (struct entry **)NULL)
668 errx(1, "no memory for entry table");
669 ep = addentry(".", ROOTINO, NODE);
670 ep->e_flags |= NEW;
671 return;
672 }
673 if ((fd = OPEN(filename, O_RDONLY, 0)) < 0) {
674 warn("open");
675 errx(1, "cannot open symbol table file %s", filename);
676 }
677 if (FSTAT(fd, &stbuf) < 0) {
678 warn("stat");
679 errx(1, "cannot stat symbol table file %s", filename);
680 }
681 tblsize = stbuf.st_size - sizeof(struct symtableheader);
682 base = calloc(sizeof(char), (unsigned)tblsize);
683 if (base == NULL)
684 errx(1, "cannot allocate space for symbol table");
685 if (read(fd, base, (int)tblsize) < 0 ||
686 read(fd, (char *)&hdr, sizeof(struct symtableheader)) < 0) {
687 warn("read");
688 errx(1, "cannot read symbol table file %s", filename);
689 }
690 switch (command) {
691 case 'r':
692 /*
693 * For normal continuation, insure that we are using
694 * the next incremental tape
695 */
696 if (hdr.dumpdate != dumptime)
697 errx(1, "Incremental tape too %s",
698 (hdr.dumpdate < dumptime) ? "low" : "high");
699 break;
700 case 'R':
701 /*
702 * For restart, insure that we are using the same tape
703 */
704 curfile.action = SKIP;
705 dumptime = hdr.dumptime;
706 dumpdate = hdr.dumpdate;
707 zflag = hdr.zflag;
708 if (!bflag)
709 newtapebuf(hdr.ntrec);
710 getvol(hdr.volno);
711 break;
712 default:
713 panic("initsymtable called from command %c\n", command);
714 break;
715 }
716 if (hdr.maxino > maxino) {
717 resizemaps(maxino, hdr.maxino);
718 maxino = hdr.maxino;
719 }
720 entrytblsize = hdr.entrytblsize;
721 entry = (struct entry **)
722 (base + tblsize - (entrytblsize * sizeof(struct entry *)));
723 baseep = (struct entry *)(base + hdr.stringsize + hdr.hashsize - sizeof(struct entry));
724 lep = (struct entry *)entry;
725 for (i = 0; i < entrytblsize; i++) {
726 if (entry[i] == NULL)
727 continue;
728 entry[i] = &baseep[(long)entry[i]];
729 }
730 for (ep = &baseep[1]; ep < lep; ep++) {
731 ep->e_name = base + (long)ep->e_name;
732 ep->e_parent = &baseep[(long)ep->e_parent];
733 if (ep->e_sibling != NULL)
734 ep->e_sibling = &baseep[(long)ep->e_sibling];
735 if (ep->e_links != NULL)
736 ep->e_links = &baseep[(long)ep->e_links];
737 if (ep->e_type == NODE) {
738 int i;
739 ep->e_entries = (struct entry **)(base + hdr.stringsize + (long)ep->e_entries);
740 for (i = 0; i < DIRHASH_SIZE; i++) {
741 if (ep->e_entries[i])
742 ep->e_entries[i] = &baseep[(long)ep->e_entries[i]];
743 }
744 }
745 else
746 ep->e_entries = NULL;
747 if (ep->e_next != NULL)
748 ep->e_next = &baseep[(long)ep->e_next];
749 }
750 }