/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* This command can now print the value of data items
* file passed with the -n argument. If the read is from
* The logic to support this is: if read is from file,
* [1] find the section number of .bss, [2] look through
* nlist for symbols that are in .bss section and zero
* the n_value field. At print time, if the n_value field
* is non-zero, print the info.
*
* This protects us from trying to read a bss symbol from
* the file and, possibly, dropping core.
*
* seek address, and the contents are read from that address.
*
* values will be printed, for example: the current nodename
* will be printed, etc.
*
* the cmn line usage is: sysdef -i -n namelist -h -d -D
* (-i for incore, though this is now the default, the option
* is left in place for SVID compatibility)
*/
#include <stdio.h>
#include <nlist.h>
#include <string.h>
#include <sys/sysmacros.h>
#include <sys/tuneable.h>
#include <sys/resource.h>
#include <sys/priocntl.h>
#include <sys/systeminfo.h>
#include <dirent.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <libelf.h>
extern void sysdef_devinfo(void);
struct var v;
/* 1 == print just the hostid */
int nflag = 0;
/* This wont fully replace it funtionally */
/* but is a reasonable default/placeholder */
int nstrpush;
short ts_maxupri;
void setln(char *, int, int, int);
void getnlist(void);
void memseek(int);
void devices(void);
void sysdev(void);
int setup(char *);
void modules(void);
struct link {
/* ELF Items */
#ifdef _ELF64
#else
#endif
/* This procedure checks if module "name" is currently loaded */
int
{
/* mi_nextid of -1 means we're getting info on all modules */
return (1);
return (0);
}
const char *sysv_transition =
"*\n* IPC %s\n*\n"
"* The IPC %s module no longer has system-wide limits.\n"
"* Please see the \"Solaris Tunable Parameters Reference Manual\" for\n"
"* information on how the old limits map to resource controls and\n"
"* the prctl(1) and getrctl(2) manual pages for information on\n"
"* observing the new limits.\n*\n";
const char *sysv_notloaded =
"*\n* IPC %s module is not loaded\n*\n";
/*
* Emit a message pointing script writers to the new source for
* System V IPC information.
*/
void
{
if (loaded_mod(module))
else
}
int
{
char *name;
int ndx;
int i;
unsigned long hostval;
switch (i) {
case 'D':
drvname_flag++;
break;
case 'd':
devflag++;
break;
case 'h':
hostidf++;
break;
case 'i':
incore++; /* In case "-i and -n" passed */
break; /* Not logical, but not disallowed */
case 'n':
nflag = 1;
incore--; /* Not incore, use specified file */
break;
default:
"usage: %s [-D -d -i -h -n namelist]\n",
argv[0]);
return (1);
}
}
/*
* Prints hostid of machine.
*/
return (1);
}
"sysinfo not numeric: \"%s\"\n", hostid);
return (1);
}
if (!devflag)
if (hostidf)
return (0);
return (1);
}
if (sysfile) {
if (incore) {
int memfd;
return (1);
}
}
/*
* Use libelf to read both COFF and ELF namelists
*/
return (1);
}
return (1);
}
return (1);
}
return (1);
}
/*
* If this is a file read, look for .bss section
*/
if (!incore) {
ndx = 1;
"%s: Error reading Shdr (%s)\n",
return (1);
}
}
ndx++;
}
} /* (!incore) */
}
if (!devflag)
if (sysfile) {
setup("");
getnlist();
if (!devflag)
printf("*\n* Devices\n*\n");
devices();
if (devflag)
return (0);
printf("*\n* Loadable Objects\n");
modules();
}
printf("*\n* System Configuration\n*\n");
sysdev();
if (sysfile) {
/* easy stuff */
printf("*\n* Tunable Parameters\n*\n");
/*
* This assignment to endnm must follow all calls to setup().
*/
getnlist();
/* return (1); */
}
}
MEMREAD(v);
}
printf("%8d maximum memory allowed in buffer cache "
printf("%8d maximum number of processes (v.v_proc)\n",
v.v_proc);
printf("%8d maximum global priority in sys class "
"(MAXCLSYSPRI)\n", v.v_maxsyspri);
printf("%8d maximum processes per user id (v.v_maxup)\n",
v.v_maxup);
printf("%8d auto update time limit in seconds (NAUTOUP)\n",
v.v_autoup);
}
printf("%8d page stealing low water mark (GPGSLO)\n",
printf("%8d fsflush run rate (FSFLUSHR)\n",
printf("%8d minimum resident memory for avoiding "
printf("%8d minimum swapable memory for avoiding deadlock "
}
printf("*\n* Utsname Tunables\n*\n");
}
if (sysfile) {
printf("*\n* Process Resource Limit Tunables "
"(Current:Maximum)\n*\n");
}
}
printf("\tfile descriptors\n");
printf("*\n* Streams Tunables\n*\n");
printf("%6d maximum number of pushes allowed "
"(NSTRPUSH)\n", nstrpush);
}
printf("%6ld maximum stream message size "
"(STRMSGSZ)\n", strmsgsz);
}
printf("%6ld max size of ctl part of message "
"(STRCTLSZ)\n", strctlsz);
}
}
if (sysfile) {
if (SYM_VALUE(pts_maxupri)) {
printf("*\n* Time Sharing Scheduler Tunables\n*\n");
printf("%d maximum time sharing user "
"priority (TSMAXUPRI)\n", ts_maxupri);
}
printf("%s system class name (SYS_NAME)\n",
sys_name);
}
if (elfd)
}
return (0);
}
/*
* setup - add an entry to a namelist structure array
*/
int
{
int idx;
exit(1);
}
}
return (idx);
}
/*
* Handle the configured devices
*/
void
devices(void)
{
}
void
modules()
{
int i;
int n_dirs = 0;
char **dirs;
char *tmpf;
int sfd;
exit(1);
}
exit(1);
}
exit(1);
}
/*
* Figure out number of directory entries in modpath.
* Module paths are stored in a space separated string
*/
while (curr) {
n_dirs++;
}
exit(1);
}
exit(1);
}
for (i = 0; i < n_dirs; i++) {
*next = '\0';
}
/*
* Make sure the module path is present.
*/
continue;
}
/*
* and skip any duplication.
*/
;
if (j != i) {
continue;
}
exit(1);
}
/*
* List the loadable objects in the directory tree, sorting
* them by inode so as to note any hard links. A temporary
* file in /tmp is used to store output from sort before
* listing.
*/
exit(1);
}
"sysdef: cannot create unique tmp file name\n");
exit(1);
}
0600)) == -1) {
exit(1);
}
exit(1);
}
char *tmp;
/*
* 'line' has <cr>, skip blank lines & dir entries
*/
continue;
/* remember path of each subdirectory */
if (line[0] == '/') {
continue;
}
continue;
} else {
/*
* eliminate .conf file
*/
continue;
}
/*
* Printing the (inode, path, module)
* ripple.
*/
}
}
/*
* A note on data synchronization. We opened sfd above,
* before calling popen, to ensure that the tempfile
* was created exclusively to prevent a malicious user
* from creating a link in /tmp to make us overwrite
* another file. We have never read from sfd, there
* can be no stale data cached anywhere.
*/
exit(1);
}
inode = -1;
printf("\thard link: ");
}
(void) unlink(sorted_fname);
}
}
void
sysdev(void)
{
printf(" swap files\n");
}
void
{
long eoff;
if (incore) {
exit(1);
}
} else {
exit(1);
}
exit(1);
}
exit(1);
}
}
}
/*
* filter out bss symbols if the reads are from the file
*/
void
getnlist(void)
{
struct nlist *p;
/*
* The nlist is done. If any symbol is a bss
* and we are not reading from incore, zero
* the n_value field. (Won't be printed if
* n_value == 0.)
*/
if (!incore) {
p->n_value = 0;
}
}
}
}