procmap.c revision 5c51f1241dbbdf2656d0e10011981411ed0c9673
/*
* 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
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <pkgstrct.h>
#include <locale.h>
#include <libintl.h>
#include <pkglib.h>
#include <install.h>
#include <libinst.h>
#define ERR_MEMORY "memory allocation failure"
#define ERR_DUPPATH "duplicate pathname <%s>"
extern int getmapmode(void);
#define EPTMALLOC 512
static int eptnum;
static int errflg;
static int nparts;
static int space = -1;
static void procinit(void);
char **client_local, char **server_path,
int nc);
static void
procinit(void)
{
if (space != -1) {
space = -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
int nc)
{
int path_duped = 0;
int local_duped = 0;
return (1);
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.
*/
source[0] = '~';
local_duped = 1;
}
}
/*
* Evaluate the destination path based upon available
* environment, then produce a client-relative and
* server-relative canonized path.
*/
(void) eval_path(server_path,
}
/*
* Deal with source for hard and soft links.
*/
if (mapflag) {
/* check for hard link */
(void) eval_path(
NULL,
local_duped = 1;
/* Default to server. */
}
}
}
}
/*
* For the paths (both source and target) that were too mundane to
* have been copied into dup space yet, do that.
*/
if (!path_duped) {
*client_path = *server_path;
path_duped = 1;
}
if (!local_duped) {
local_duped = 1;
}
return (0);
}
/*
* This function reads the prototype file and returns a pointer to a list of
* struct cfent representing the contents of that file.
*/
/*ARGSUSED*/
struct cfent **
{
int i;
int n;
int nc;
static char *server_local, *client_local;
procinit();
"prototype object");
if (space == -1) {
return (NULL);
}
for (;;) {
/* Clear the buffer. */
if (n == 0)
break; /* no more entries in pkgmap */
else if (n < 0) {
return (NULL);
}
/*
* A valid entry was found in the map, so allocate an
* official record.
*/
return (NULL);
}
/* Transfer what we just read in. */
/* It didn't take. */
continue;
}
eptnum++;
}
/* setup a pointer array to point to malloc'd entries space */
return (NULL);
}
(void) sortentry(-1);
for (i = 0; i < eptnum; /* void */) {
if (!sortentry(i))
i++;
}
}
/*
* This function sorts the final list of cfent 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
{
static int last = 0;
int i, n, j;
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.
*/
/* quick comparison optimization for pre-sorted arrays */
/* do nothing */
return (0);
}
lower = 0; /* lower bound of the unsorted elements */
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.
*/
if (n == 0) {
errflg++;
}
/* remove the entry at 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;
} else {
/* Move up array */
lower = i+1;
}
/* expand to insert at i */
for (j = index; j > i; j--)
return (0);
}
/*
* 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
{
/* ept2 will be modified to contain "merged" entries */
return (0);
return (0);
return (0);
return (0);
return (0);
}
return (1);
}