summaryrefslogtreecommitdiff
path: root/usr/src/cmd/svr4pkg/libinst/pkgobjmap.c
blob: 13a041418c84150fcb0d6d0322021f3b5c56633a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */


#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <pkgstrct.h>
#include <locale.h>
#include <libintl.h>
#include <pkglib.h>
#include <install.h>
#include <libinst.h>

#define	WRN_NOPKGOBJ	"WARNING: no package objects found"

#define	ERR_MEMORY	"memory allocation failure"
#define	ERR_DUPPATH	"duplicate pathname <%s>"

/* libpkg/gpkgmap */
extern int	getmapmode(void);

#define	EPTMALLOC	512

static struct cfextra **extlist;

int	eptnum;
static int	array_preloaded = 0;
static int	errflg;
static int	nparts;
static int	xspace = -1;

void	pkgobjinit(void);
static int	pkgobjassign(struct cfent *ept, char **server_local,
		    char **client_local, char **server_path,
		    char **client_path, char **map_path, int mapflag,
		    int nc);

static int	ckdup(struct cfent *ept1, struct cfent *ept2);
static int	sortentry(int index);
static int	dup_merg(struct cfextra *ext1, struct cfextra *ext2);

void
pkgobjinit(void)
{
	if (array_preloaded)	/* Already done. */
		return;

	errflg = nparts = eptnum = 0;

	if (xspace != -1) {
		ar_free(xspace);
		xspace = -1;
	}

	/*
	 * initialize dynamic memory used to store
	 * path information which is read in
	 */
	(void) pathdup((char *)0);
}

/*
 * This function assigns appropriate values based upon the pkgmap entry
 * in the cfent structure.
 */
static int
pkgobjassign(struct cfent *ept, char **server_local, char **client_local,
    char **server_path, char **client_path, char **map_path, int mapflag,
    int nc)
{
	int	path_duped = 0;
	int	local_duped = 0;
	char	source[PATH_MAX+1];

	if (nc >= 0 && ept->ftype != 'i')
		if ((ept->pkg_class_idx = cl_idx(ept->pkg_class)) == -1)
			return (1);

	if (ept->volno > nparts)
		nparts++;

	/*
	 * Generate local (delivered source) paths for files
	 * which need them so that the install routine will know
	 * where to get the file from the package. Note that we
	 * do not resolve path environment variables here since
	 * they won't be resolved in the reloc directory.
	 */
	if ((mapflag > 1) && strchr("fve", ept->ftype)) {
		if (ept->ainfo.local == NULL) {
			source[0] = '~';
			(void) strlcpy(&source[1], ept->path,
						sizeof (source)-1);
			ept->ainfo.local = pathdup(source);
			*server_local = ept->ainfo.local;
			*client_local = ept->ainfo.local;

			local_duped = 1;
		}
	}

	/*
	 * Evaluate the destination path based upon available
	 * environment, then produce a client-relative and
	 * server-relative canonized path.
	 */
	if (mapflag && (ept->ftype != 'i')) {
		mappath(getmapmode(), ept->path); /* evaluate variables */
		canonize(ept->path);	/* Fix path as necessary. */

		(void) eval_path(server_path,
		    client_path,
		    map_path,
		    ept->path);
		path_duped = 1;	/* eval_path dup's it */
		ept->path = *server_path;	/* default */
	}

	/*
	 * Deal with source for hard and soft links.
	 */
	if (strchr("sl", ept->ftype)) {
		if (mapflag) {
			mappath(getmapmode(), ept->ainfo.local);
			if (!RELATIVE(ept->ainfo.local)) {
				canonize(ept->ainfo.local);

				/* check for hard link */
				if (ept->ftype == 'l') {
					(void) eval_path(
					    server_local,
					    client_local,
					    NULL,
					    ept->ainfo.local);
					local_duped = 1;

					/* Default to server. */
					ept->ainfo.local = *server_local;
				}
			}
		}
	}

	/*
	 * For the paths (both source and target) that were too mundane to
	 * have been copied into dup space yet, do that.
	 */
	if (!path_duped) {
		*server_path = pathdup(ept->path);
		*client_path = *server_path;
		ept->path = *server_path;

		path_duped = 1;
	}
	if (ept->ainfo.local != NULL)
		if (!local_duped) {
			*server_local = pathdup(ept->ainfo.local);
			ept->ainfo.local = *server_local;
			*client_local = ept->ainfo.local;

		local_duped = 1;
	}

	return (0);
}

/* This initializes the package object array. */
int
init_pkgobjspace(void)
{
	if (array_preloaded)	/* Already done. */
		return (1);

	if (xspace == -1) {
		xspace = ar_create(EPTMALLOC, sizeof (struct cfextra),
		    "package object");
		if (xspace == -1) {
			progerr(gettext(ERR_MEMORY));
			return (0);
		}
	}

	return (1);
}

int
seed_pkgobjmap(struct cfextra *ext_entry, char *path, char *local)
{
	struct cfextra *ext, **ext_ptr;

	/* offsets for the various path images. */
	int client_path_os;
	int server_path_os;
	int map_path_os;
	int client_local_os;
	int server_local_os;

	ext_ptr = (struct cfextra **)ar_next_avail(xspace);

	if (ext_ptr == NULL || *ext_ptr == NULL) {
		progerr(gettext(ERR_MEMORY));
		return (NULL);
	}

	ext = *ext_ptr;

	(void) memcpy(ext, ext_entry, sizeof (struct cfextra));

	/* Figure out all of the offsets. */
	client_path_os = ((ptrdiff_t)ext->client_path -
			(ptrdiff_t)ext->cf_ent.path);
	server_path_os = ((ptrdiff_t)ext->server_path -
			(ptrdiff_t)ext->cf_ent.path);
	map_path_os = ((ptrdiff_t)ext->map_path -
			(ptrdiff_t)ext->cf_ent.path);
	client_local_os = ((ptrdiff_t)ext->client_local -
			(ptrdiff_t)ext->cf_ent.ainfo.local);
	server_local_os = ((ptrdiff_t)ext->server_local -
			(ptrdiff_t)ext->cf_ent.ainfo.local);

	/* Allocate and store the path name. */
	ext->cf_ent.path = pathdup(path);

	/* Assign the path substring pointers. */
	ext->client_path = (ext->cf_ent.path + client_path_os);
	ext->server_path = (ext->cf_ent.path + server_path_os);
	ext->map_path = (ext->cf_ent.path + map_path_os);

	/* If there's a local entry, allocate and store it as well. */
	if (local) {
		ext->cf_ent.ainfo.local = pathdup(local);

		ext->client_local = (ext->cf_ent.ainfo.local + client_local_os);
		ext->server_local = (ext->cf_ent.ainfo.local + server_local_os);
	} else {
		ext->cf_ent.ainfo.local = NULL;
		ext->client_local = NULL;
		ext->server_local = NULL;
	}

	eptnum++;
	array_preloaded = 1;

	return (0);
}

/*
 * This function reads the pkgmap (or any file similarly formatted) and
 * returns a pointer to a list of struct cfextra (each of which
 * contains a struct cfent) representing the contents of that file.
 */

/* ARGSUSED ir in pkgobjmap */
struct cfextra **
pkgobjmap(VFP_T *vfp, int mapflag, char *ir)
{
	struct	cfextra *ext, **ext_ptr;
	struct	cfent *ept, map_entry;
	int	i;
	int	n;
	int	nc;

	pkgobjinit();
	if (!init_pkgobjspace())
		quit(99);

	nc = cl_getn();
	for (;;) {
		/* Clear the buffer. */
		(void) memset(&map_entry, '\000', sizeof (struct cfent));

		/*
		 * Fill in a cfent structure in a very preliminary fashion.
		 * ept->path and ept->ainfo.local point to static memory
		 * areas of size PATH_MAX. These are manipulated and
		 * then provided their own allocations later in this function.
		 */
		n = gpkgmapvfp(&map_entry, vfp);

		if (n == 0)
			break; /* no more entries in pkgmap */
		else if (n < 0) {
			char	*errstr = getErrstr();
			progerr(gettext("bad entry read in pkgmap"));
			logerr(gettext("pathname=%s"),
			    (map_entry.path && *map_entry.path) ?
			    map_entry.path : "Unknown");
			logerr(gettext("problem=%s"),
			    (errstr && *errstr) ? errstr : "Unknown");
			return (NULL);
		}

		/*
		 * A valid entry was found in the map, so allocate an
		 * official record.
		 */
		ext_ptr = (struct cfextra **)ar_next_avail(xspace);
		if (ext_ptr == NULL || *ext_ptr == NULL) {
			progerr(gettext(ERR_MEMORY));
			return (NULL);
		}

		ext = *ext_ptr;
		ept = &(ext->cf_ent);

		/* Transfer what we just read in. */
		(void) memcpy(ept, &map_entry, sizeof (struct cfent));

		/* And process it into the cfextra structure. */
		if (pkgobjassign(ept,
		    &(ext->server_local),
		    &(ext->client_local),
		    &(ext->server_path),
		    &(ext->client_path),
		    &(ext->map_path),
		    mapflag, nc)) {
			/* It didn't take. */
			(void) ar_delete(xspace, eptnum);
			continue;
		}

		eptnum++;
		ext->fsys_value = BADFSYS;	/* No file system data yet */
		ext->fsys_base = BADFSYS;
	}

	if (eptnum == 0) {
		logerr(gettext(WRN_NOPKGOBJ));
		return (NULL);
	}

	/* setup a pointer array to point to malloc'd entries space */
	extlist = (struct cfextra **)ar_get_head(xspace);
	if (extlist == NULL) {
		progerr(gettext(ERR_MEMORY));
		return (NULL);
	}

	(void) sortentry(-1);
	for (i = 0; i < eptnum; /* void */) {
		if (!sortentry(i))
			i++;
	}

	return (errflg ? NULL : extlist);
}

/*
 * This function sorts the final list of cfextra entries. If index = -1, the
 * function is initialized. index = 0 doesn't get us anywhere because this
 * sorts against index-1. Positive natural index values are compared and
 * sorted into the array appropriately. Yes, it does seem we should use a
 * quicksort on the whole array or something. The apparent reason for taking
 * this approach is that there are enough special considerations to be
 * applied to each package object that inserting them one-by-one doesn't cost
 * that much.
 */
static int
sortentry(int index)
{
	struct cfextra *ext;
	struct cfent *ept, *ept_i;
	static int last = 0;
	int	i, n, j;
	int	upper, lower;

	if (index == 0)
		return (0);
	else if (index < 0) {
		last = 0;
		return (0);
	}

	/*
	 * Based on the index, this is the package object we're going to
	 * review. It may stay where it is or it may be repositioned in the
	 * array.
	 */
	ext = extlist[index];
	ept = &(ext->cf_ent);

	/* quick comparison optimization for pre-sorted arrays */
	if (strcmp(ept->path, extlist[index-1]->cf_ent.path) > 0) {
		/* do nothing */
		last = index-1;
		return (0);
	}

	lower = 0;		/* lower bound of the unsorted elements */
	upper = index;		/* upper bound */
	i = last;
	do {
		/*
		 * NOTE: This does a binary sort on path. There are lots of
		 * other worthy items in the array, but path is the key into
		 * the package database.
		 */
		ept_i = &(extlist[i]->cf_ent);

		n = strcmp(ept->path, ept_i->path);
		if (n == 0) {
			if (!ckdup(ept, ept_i)) {
				/*
				 * If the array was seeded then there are
				 * bound to be occasional duplicates.
				 * Otherwise, duplicates are definitely a
				 * sign of major damage.
				 */
				if (array_preloaded) {
					if (!dup_merg(ext, extlist[i])) {
						progerr(gettext(ERR_DUPPATH),
						    ept->path);
						errflg++;
					}
				} else {
					progerr(gettext(ERR_DUPPATH),
					    ept->path);
					errflg++;
				}
			}
			/* remove the entry at index */
			(void) ar_delete(xspace, index);

			eptnum--;
			return (1);	/* Use this index again. */
		} else if (n < 0) {
			/*
			 * The path of interest is smaller than the path
			 * under test. Move down array using the method of
			 * division
			 */
			upper = i;
			i = lower + (upper-lower)/2;
		} else {
			/* Move up array */
			lower = i+1;
			i = upper - (upper-lower)/2 - 1;
		}
	} while (upper != lower);
	last = i = upper;

	/* expand to insert at i */
	for (j = index; j > i; j--)
		extlist[j] = extlist[j-1];

	extlist[i] = ext;

	return (0);
}

/* Return the number of blocks required by the package object provided. */
static fsblkcnt_t
nblks(short fsys_entry, struct cfextra *ext)
{
	fsblkcnt_t blk;
	ulong_t block_size;
	ulong_t frag_size;

	block_size = (ulong_t)get_blk_size_n(fsys_entry);
	frag_size = (ulong_t)get_frag_size_n(fsys_entry);

	if (strchr("dxs", ext->cf_ent.ftype))
		blk =
		    nblk(block_size, block_size, frag_size);
	else if (ext->cf_ent.cinfo.size != BADCONT)
		blk = nblk(ext->cf_ent.cinfo.size, block_size,
		    frag_size);
	else
		blk = 0;

	return (blk);
}

/* Remove ext1 from the filesystem size calculations and add ext2. */
static void
size_xchng(struct cfextra *ext1, struct cfextra *ext2)
{
	fsblkcnt_t bused;
	ulong_t block_size;
	ulong_t frag_size;
	fsblkcnt_t	blks1, blks2;
	short	fsys_entry;

	/*
	 * Since these are on the same filesystem, either one will yield the
	 * correct block and fragment size.
	 */
	fsys_entry = ext1->fsys_base;
	block_size = (ulong_t)get_blk_size_n(fsys_entry);
	frag_size = (ulong_t)get_frag_size_n(fsys_entry);

	blks1 = nblk(ext1->cf_ent.cinfo.size, block_size, frag_size);
	blks2 = nblk(ext2->cf_ent.cinfo.size, block_size, frag_size);

	if (blks1 != blks2) {
		/* First, lose the old size, then add the new size. */
		bused = get_blk_used_n(fsys_entry);
		bused -= nblks(fsys_entry, ext1);
		bused += nblks(fsys_entry, ext2);

		set_blk_used_n(fsys_entry, bused);
	}
}

/*
 * This function merges duplicate non-directory entries resulting from a
 * dryrun or other procedure which preloads the extlist. It uses an odd
 * heuristic to determine which package object is newest: only package
 * objects from the dryrun file will have pinfo pointers. Therefore, the
 * object with a pinfo pointer is from the dryrun file and it will be
 * overwritten by the object being installed by this package.
 *
 * Assumptions:
 *	1. The newer object will be overwriting the older object.
 *	2. The two objects are close enough to the same size that
 *	   the sizing is still OK.
 *
 * The calling routine will overwrite ept1, so this must return ept2 with
 * the correct data to keep. There being only one logical outcome of a
 * failure, this returns 1 for OK and 0 for FAIL.
 */
static int
dup_merg(struct cfextra *ext1, struct cfextra *ext2)
{
	struct cfent *ept1, *ept2;

	ept1 = &(ext1->cf_ent);
	ept2 = &(ext2->cf_ent);

	if (strchr("?dx", ept1->ftype))
		return (0);

	if (strchr("?dx", ept2->ftype))
		return (0);

	/* First, which is the eldest? */
	if (ext2->mstat.preloaded) {
		/*
		 * While ept2 has the correct pinfo list (it was preloaded into
		 * the array before the pkgmap was read), ept1 has everything
		 * else. Here we copy the guts of ept1 into ept2.
		 *
		 * Start by grabbing the pointers to the ext2 items that we
		 * need to either restore or free.
		 */
		/* to free() */
		char *path = ept2->path;
		char *local = ept2->ainfo.local;

		/* to preserve */
		short npkgs = ept2->npkgs;
		struct pinfo *pinfo = ept2->pinfo;

		/* Copy everything from the new entry to the old */
		(void) memcpy(ept2, ept1, sizeof (struct cfent));

		/* Now restore the original stuff.. */
		ept2->path = path;
		ept2->ainfo.local = local;
		ept2->npkgs = npkgs;
		ept2->pinfo = pinfo;

		size_xchng(ext2, ext1);
	} else if (ext1->mstat.preloaded) {
		/*
		 * ept2 is already the one we will keep. All we have to do is
		 * copy over the pinfo pointer.
		 */
		ept2->pinfo = ept1->pinfo;
		size_xchng(ext1, ext2);
	} else
		return (0);

	return (1);
}

/*
 * Check duplicate entries in the package object list. If it's a directory,
 * this just merges them, if not, it returns a 0 to force further processing.
 */
static int
ckdup(struct cfent *ept1, struct cfent *ept2)
{
	/* ept2 will be modified to contain "merged" entries */

	if (!strchr("?dx", ept1->ftype))
		return (0);

	if (!strchr("?dx", ept2->ftype))
		return (0);

	if (ept2->ainfo.mode == BADMODE)
		ept2->ainfo.mode = ept1->ainfo.mode;
	if ((ept1->ainfo.mode != ept2->ainfo.mode) &&
	    (ept1->ainfo.mode != BADMODE))
		return (0);

	if (strcmp(ept2->ainfo.owner, "?") == 0)
		(void) strlcpy(ept2->ainfo.owner, ept1->ainfo.owner,
			sizeof (ept2->ainfo.owner));
	if (strcmp(ept1->ainfo.owner, ept2->ainfo.owner) &&
	    strcmp(ept1->ainfo.owner, "?"))
		return (0);

	if (strcmp(ept2->ainfo.group, "?") == 0)
		(void) strlcpy(ept2->ainfo.group, ept1->ainfo.group,
			sizeof (ept2->ainfo.group));
	if (strcmp(ept1->ainfo.group, ept2->ainfo.group) &&
	    strcmp(ept1->ainfo.group, "?"))
		return (0);

	if (ept1->pinfo) {
		ept2->npkgs = ept1->npkgs;
		ept2->pinfo = ept1->pinfo;
	}

	return (1);
}

/*
 * Replace the old package database entry with the new one preserving the
 * data which remains constant across the replacement.
 *	copied directly:
 *		ftype, pkg_class
 *
 *	preserved from old:
 *		path, npkgs, pinfo
 */
void
repl_cfent(struct cfent *new, struct cfent *old)
{
	char *path = old->path;
	short npkgs = old->npkgs;
	struct pinfo *pinfo = old->pinfo;

	/* Copy everything from the new entry over */
	(void) memcpy(old, new, sizeof (struct cfent));

	if (strchr("sl", new->ftype) == NULL)
		old->ainfo.local = NULL;

	old->path = path;
	old->npkgs = npkgs;
	old->pinfo = pinfo;

	old->volno = 0;
}

/*
 * Copy critical portions of cf_ent (from the package database) and el_ent
 * (constructed from the pkgmap) into a merged cfent structure, tp. Then copy
 * that to the el_ent structure. The approach we take here is to copy over
 * everything from the package database entry, condition the paths based upon
 * the currently installed path and then insert the following entries from
 * the new structure :
 *	cfent.volno
 *	pkg_class
 *	pkg_class_idx
 *
 * The pinfo list is then copied from the cfent list. While
 * fsys_value is also copied over, it hasn't been set yet. This function
 * copies over whatever the default value is from the new structure.
 *
 * The copied entry is returned in the el_ent argument and the function
 * value is 1 on success, 0 on failure. There is no recovery plan for
 * failure.
 */
int
cp_cfent(struct cfent *cf_ent, struct cfextra *el_ent)
{
	struct cfextra	*tp;

	/* Allocate space for cfent copy */
	if ((tp = (struct cfextra *)calloc(1,
	    sizeof (struct cfextra))) == NULL) {
		progerr(gettext("cp_cfent: memory allocation error"));
		return (0);
	}

	/* Copy everything from the package database over */
	(void) memcpy(&(tp->cf_ent), cf_ent, sizeof (struct cfent));

	/* Now overlay new items from the pkgmap */
	tp->fsys_value = el_ent->fsys_value;
	tp->cf_ent.volno = el_ent->cf_ent.volno;
	(void) strlcpy(tp->cf_ent.pkg_class, el_ent->cf_ent.pkg_class,
			sizeof (tp->cf_ent.pkg_class));
	tp->cf_ent.pkg_class_idx = el_ent->cf_ent.pkg_class_idx;
	tp->cf_ent.pinfo = cf_ent->pinfo;

	/*
	 * The paths are identical, so we get them from the new entry.  These
	 * are pointing to a malloc'd section of memory containing a string
	 * that we aren't moving in this operation, so everybody points to
	 * the same thing during these transfers.
	 */
	tp->cf_ent.path = el_ent->client_path;
	tp->server_path = el_ent->server_path;
	tp->client_path = el_ent->client_path;
	tp->map_path = el_ent->map_path;

	/*
	 * Since instvol() expects to work with the *original* mstat data,
	 * mstat is just copied here. NOTE: mstat looks like a structure, but
	 * it's really a short bit array.
	 */
	tp->mstat = el_ent->mstat;

	/* Copy everything from the temporary structure to the new entry */
	(void) memcpy(el_ent, tp, sizeof (struct cfextra));
	free(tp);

	return (1);
}