config.c revision b3fbe5e6c0ab1f506cd04f8dd39bf9656909f535
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "rtc.h"
#include "_crle.h"
#include "msg.h"
#pragma ident "%Z%%M% %I% %E% SMI"
#define MAXNBKTS 10007
static const int hashsize[] = {
3, 7, 13, 31, 53, 67, 83, 97,
101, 151, 211, 251, 307, 353, 401, 457, 503,
557, 601, 653, 701, 751, 809, 859, 907, 953,
1009, 1103, 1201, 1301, 1409, 1511, 1601, 1709, 1801,
1901, 2003, 2111, 2203, 2309, 2411, 2503, 2609, 2707,
2801, 2903, 3001, 3109, 3203, 3301, 3407, 3511, 3607,
3701, 3803, 3907, 4001, 5003, 6101, 7001, 8101, 9001,
};
/*
* Generate a configuration file from the internal configuration information.
* (very link-editor like).
*/
int
{
/*
* Establish the size of the configuration file.
*/
if (crle->c_hashstrnum) {
/*
* Increment the hash string number to account for an initial
* null entry. Indexes start at 1 to simplify hash lookup.
*/
crle->c_hashstrnum++;
/*
* Determine the hash table size. Establish the number of
* buckets from the number of strings, the number of chains is
* equivalent to the number of objects, and two entries for the
* nbucket and nchain entries.
*/
continue;
break;
}
if (hashbkts == 0)
/*
* Add the object table size (account for an 8-byte alignment
* requirement for each object).
*/
/*
* Add the file descriptor arrays.
*/
sizeof (Word));
/*
* Add the directory descriptor array.
*/
sizeof (Word));
}
/*
* Add any environment string array (insure zero last entry).
*/
sizeof (Word));
}
/*
* the filter array, the filtee arrays are already accounted for).
*/
sizeof (Word));
sizeof (Word));
}
/*
*/
}
/*
* Truncate our temporary file now that we know its size and map it.
*/
return (1);
}
return (1);
}
/*
* Save the mapped files info for possible dldump(3dl) updates.
*/
/*
* Establish the real address of each of the structures within the file.
*/
/* LINTED */
/* LINTED */
/* LINTED */
/* LINTED */
/* LINTED */
/* LINTED */
/* LINTED */
/*
* Fill in additional basic header information.
*/
}
#ifndef SGS_PRE_UNIFIED_PROCESS
#endif
/*
* If we have a hash table then there are directory and file entries
* to process.
*/
if (crle->c_hashstrnum) {
/*
* are cleared.
*/
/*
* Loop through the current string table list inspecting only
* directories.
*/
/*
* Skip any empty and non-directory entries.
*/
if ((obj == 0) ||
continue;
/*
* Assign basic object attributes.
*/
/*
* Assign the directory name (from its key),
* and copy its name to the string table.
*/
/*
* Establish an entry in the directory table and
* reserve space for its associated filename
* entries (note, we add a trailing null file
* entry to simplify later inspection of the
* final configuration file.
*/
/* LINTED */
/*
* Add this object to the hash table.
*/
/*
* Increment Rt_obj pointer (make sure pointer
* falls on an 8-byte boundary).
*/
sizeof (Lword));
}
}
/*
* Now collect all pathnames. These are typically full
* pathnames, but may also be relative. Simple filenames are
* recorded as offsets into these pathnames, thus we need to
* establish the new pathname first.
*/
char *_str;
int _id;
/*
* Skip empty and directory entries, and any
* simple filename entries.
*/
if ((obj == 0) ||
continue;
/*
* Assign basic object attributes.
*/
/*
* Assign the file name (from its key),
* and copy its name to the string table.
*/
/*
* Add this file to its associated directory.
*/
/* LINTED */
/*
* If object has an alternative, record it in
* the string table and assign the alternate
* pointer. The new alternative offset is
* retained for reuse in other filename entries.
*/
} else
/*
* If object identifies the specific application
* for which this cache is relevant, record it
* in the header.
*/
(RTC_OBJ_APP | RTC_OBJ_REALPTH)) ==
/*
* Add this object to the hash table.
*/
/*
* Increment Rt_obj pointer (make sure pointer
* falls on an 8-byte boundary).
*/
sizeof (Lword));
}
}
/*
* Finally pick off any simple filenames.
*/
int _id;
/*
* Skip everything except simple filenames.
*/
continue;
/*
* Assign basic object attributes.
*/
/*
* Assign the file name from its full name.
*/
/*
* Add this file to its associated directory.
*/
/* LINTED */
/*
* Add this object to the hash table.
*/
/*
* Increment Rt_obj pointer (make sure pointer
* falls on an 8-byte boundary).
*/
sizeof (Lword));
}
}
}
/*
* Add any library, or secure path definitions.
*/
if (crle->c_edlibpath) {
} else
head->ch_edlibpath = 0;
if (crle->c_adlibpath) {
} else
head->ch_adlibpath = 0;
if (crle->c_eslibpath) {
} else
head->ch_eslibpath = 0;
if (crle->c_aslibpath) {
} else
head->ch_aslibpath = 0;
/*
* Add any environment variable entries.
*/
envtbl++;
}
}
/*
*/
/*
* Establish the filter name, and filtee string, as
* offsets into the configuration files string table.
* Establish the filtee as the offset into the filtee
* table.
*/
/*
* Establish the filtee name as the offset into
* the configuration files string table.
*/
_fltetbl++;
}
}
}
/*
* Flush everything out.
*/
return (1);
}
return (0);
}
/*
* Update a configuration file. If dldump()'ed images have been created then
* the memory reservation of those images is added to the configuration file.
* The temporary file is then moved into its final resting place.
*/
int
{
MS_ASYNC) == -1) {
return (1);
}
}
/*
* If an original configuration file exists, remove it.
*/
/*
* Move the config file to its final resting place. If the two files
* exist on the same filesystem a rename is sufficient.
*/
int fd;
0666)) == -1) {
return (1);
}
crle->c_tempsize) {
return (1);
}
} else
return (0);
}