/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include <syslog.h>
#include <sys/sysmacros.h>
#include <procfs.h>
#include <libintl.h>
#include <locale.h>
extern int gmatch(const char *s, const char *p);
#pragma init(__mpssmain)
/* environment variables */
#define MPSSHEAP 0
/* config file */
/*
* avoid malloc which causes certain applications to crash
*/
#ifdef MPSSDEBUG
static int mpssdebug;
#else
#define MPSSPRINT(x, y)
#endif
#if !defined(TEXT_DOMAIN)
#endif
/*PRINTFLIKE2*/
static void
{
if (fp)
else
}
/*
* Return the pointer to the fully-resolved path name of the process's
* executable file obtained from the AT_SUN_EXECNAME aux vector entry.
*/
static const char *
mygetexecname(void)
{
/*
* The first time through, read the initial aux vector that was
* passed to the process at exec(2). Only do this once.
*/
if (fd >= 0) {
break;
}
}
}
return (execname);
}
static size_t
{
char *endptr, c;
while (c = *endptr++) {
switch (c) {
case 't':
case 'T':
sz *= 1024;
/*FALLTHRU*/
case 'g':
case 'G':
sz *= 1024;
/*FALLTHRU*/
case 'm':
case 'M':
sz *= 1024;
/*FALLTHRU*/
case 'k':
case 'K':
sz *= 1024;
default:
break;
}
}
return (sz);
}
static int nelem;
static int
{
int i;
if (sz == 0)
return (1);
for (i = 0; i < nelem; i++) {
break;
}
return (i < nelem);
}
static void
pgszinit()
{
if (!nelem)
return;
#ifdef MPSSDEBUG
nelem++;
#endif
}
static int
{
int rc;
return (rc);
}
/*
* check if exec name matches cfgname found in mpss cfg file.
*/
static int
{
const char *ename;
int rc;
/* cfgname should not have a '/' unless it begins with one */
if (cfgname[0] == '/') {
/*
* if execname does not begin with a '/', prepend the
* current directory.
*/
if (execname[0] != '/') {
} else
} else { /* simple cfg name */
/* execname is a path name - get the base name */
ename++;
else
}
return (rc);
}
/*
* Check if string matches any of exec arguments.
*/
static int
{
int fd;
int rc = 0;
int arg;
char **argv;
if (fd >= 0) {
argv++;
break;
}
}
} else {
}
} else {
}
return (rc);
}
static int
{
char c;
str++;
return (*str == '\0');
}
void
{
const char *execname;
char *cwd;
int cwdlen;
int lineno = 0;
char *locale;
/*
* If a private error file is indicated then set the locale
* for error messages for the duration of this routine.
* Error messages destined for syslog should not be translated
* and thus come from the default C locale.
*/
if (errfp) {
} else {
"%s: cannot open error file: %s [%s]\n"),
}
}
#ifdef MPSSDEBUG
#endif
pgszinit();
else
"%s: invalid stack page size specified:"
" MPSSSTACK=%s\n"),
}
else
"%s: invalid heap page size specified:"
" MPSSHEAP=%s\n"),
}
/*
* Open specified cfg file or default one.
*/
if (!fp) {
"%s: cannot open configuration file: %s [%s]\n"),
}
} else {
}
execname = mygetexecname();
if (fp) {
if (!cwd)
return;
lineno++;
continue;
/*
* Make sure line wasn't truncated.
*/
"%s: invalid entry, "
"line too long - cfgfile:"
" %s, line: %d\n"),
continue;
}
/*
* parse right to left in case delimiter is
* in name.
*/
"%s: no delimiters specified - cfgfile:"
" %s, line: %d\n"),
continue;
}
/* found delimiter in lbuf */
*tokstack++ = '\0';
/* remove for error message */
*str = '\0';
"%s: invalid entry, "
"missing delimiter - cfgfile: %s,"
" line: %d\n"),
continue;
}
*tokheap++ = '\0';
/* exec-args is optional */
*tokarg++ = '\0';
}
continue;
}
if (tokarg &&
continue;
}
/* heap token */
/* empty cfg entry */
} else {
else {
"%s: invalid heap page size"
" specified (%s) for %s - "
"cfgfile: %s, line: %d\n"),
lineno);
}
}
/* stack token */
break;
} else {
else {
"%s: invalid stack page size"
" specified (%s) for %s - "
"cfgfile: %s, line: %d\n"),
}
}
break;
}
}
"%s: memcntl() failed [%s]: heap page size (%s)"
" for %s not set\n"),
execname);
"%s: memcntl() failed [%s]: stack page size (%s)"
" for %s not set\n"),
execname);
if (errfp) {
} else {
/* close log file: no-op if nothing logged to syslog */
closelog();
}
}