cap.c revision d29b2c4438482eb00488be49a1f5d6835f455546
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "_synonyms.h"
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <debug.h>
#include <conv.h>
#include "_rtld.h"
#include "_audit.h"
#include "msg.h"
/*
* qsort(3c) comparison function.
*/
static int
{
return (-1);
return (1);
return (0);
return (-1);
return (1);
return (0);
}
/*
* If this object defines a set of hardware capability requirements, insure the
* kernal can cope with them.
*/
int
{
int cnt;
/* LINTED */
continue;
/* LINTED */
break;
cptr++;
}
break;
static Conv_cap_val_hw1_buf_t cap_buf;
return (0);
}
/*
* Retain this hardware capabilities pointer for possible later
* inspection should this object be processed as a filtee.
*/
}
return (1);
}
static void
{
#if defined(MAP_ALIGN)
#else
#endif
/*
* Note, this file descriptor might be duplicating information
* from the global fmap descriptor. If so, clean up the global
* descriptor to prevent a duplicate (unnecessary) unmap.
*/
fmap_setup();
}
}
}
/*
* When $HWCAP is used to represent dependencies, take the associated directory
* and analyze all the files it contains.
*/
int
{
const char *src;
int error = 0;
/*
* Access the directory in preparation for reading its entries. If
* successful, establish the initial pathname.
*/
return (0);
}
*dst++ = '/';
/*
* Read each entry from the directory and determine whether it is a
* valid ELF file.
*/
char *_dst;
/*
* Ignore "." and ".." entries.
*/
continue;
/*
* Complete the full pathname, and verify its usability. Note,
* an auditor can supply an alternative name.
*/
*_dst = '\0';
error = 1;
break;
}
continue;
}
/*
* Note, all directory entries are processed by find_path(),
* even entries that are directories themselves. This single
* point for control keeps the number of stat()'s down, and
* provides a single point for error diagnostics.
*/
continue;
}
/*
* If this object has already been loaded, obtain the hardware
* capabilities for later sorting. Otherwise we have a new
* candidate.
*/
else
error = 1;
break;
}
/*
* Clear the global file mapping structure so that the mapping
* for this file won't be overriden.
*/
}
/*
* If no objects have been found, we're done. Also, if an allocation
* error occurred while processing any object, remove any objects that
* had already been added to the list and return.
*/
if (fdalp) {
}
return (0);
}
/*
* Having processed and retained all candidates from this directory,
* sort them, based on the precedence of their hardware capabilities.
*/
return (1);
}
static Pnode *
{
int unused = 0;
remove_rej(&rej);
return (0);
}
/*
* Now complete the mapping of each of the ordered objects, adding
* each object to a new Pnode.
*/
int audit = 0;
if (unused) {
/*
* Flush out objects remaining.
*/
continue;
}
/*
* Complete mapping the file, obtaining a handle, and continue
* to analyze the object, establishing dependencies and
* relocating. Remove the file descriptor at this point, as it
* is no longer required.
*/
if (nlmp == 0)
continue;
/*
* Create a new Pnode to represent this filtee, and substitute
* the calling Pnode (which was used to represent the hardware
* capability directory).
*/
if (ghp) {
}
return (0);
}
if (ghp) {
}
return (0);
}
if (fpnp == 0) {
/*
* If this is the first pnode, reuse the original after
* freeing any of its pathnames.
*/
} else {
}
/*
* Establish the filter handle to prevent any recursion.
*/
}
/*
* indicates the auditor wishes to ignore this filtee.
*/
audit = 1;
nlmp = 0;
}
}
/*
* Finish processing the objects associated with this request.
*/
nlmp = 0;
/*
* If the filtee has been successfully processed, then create
* an association between the filter and the filtee. This
* association provides sufficient information to tear down the
* filter and filtee if necessary.
*/
nlmp = 0;
/*
* If this object is marked an end-filtee, we're done.
*/
unused = 1;
/*
* If this filtee loading has failed, generate a diagnostic.
* Null out the pnode entry, and continue the search.
*/
if (nlmp == 0) {
/*
* If attempting to load this filtee required a new
* link-map control list to which this request has
* added objects, then remove all the objects that
* have been associated to this request.
*/
}
}
return (fpnp);
}
Pnode *
{
flags)) != 0)
return (pnp);
/*
* If no hardware capability filtees have been found, provide suitable
* diagnostics and mark the incoming Pnode as unused.
*/
return (pnp);
}
/*
* Load an individual hardware capabilities object.
*/
Rt_map *
{
int found = 0;
/*
* Obtain the sorted list of hardware capabilites objects available.
*/
return (0);
/*
* From the list of hardware capability objects, use the first and
* discard the rest.
*/
found++;
/*
* Remove the used file descriptor and any objects remaining.
*/
}
return (lmp);
}