ptm.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <mdb/mdb_modapi.h>
typedef struct pt_flags {
const char *pt_name;
const char *pt_descr;
} ptflags_t;
{ "PTMOPEN", "Master side is open" },
{ "PTSOPEN", "Slave side is open" },
{ "PTSTTY", "Slave side is tty" },
{ NULL },
};
static int
{
int i;
*flag |= (1 << i);
return (0);
}
}
return (-1);
}
static void
{
int i;
mdb_printf("%12s %s\n",
}
static void
{
"pts/%d:%s: %p\nprocess: %d(%s)",
}
static int
{
char c[MAXCOMLEN + 1];
proc_t p;
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
(void) mdb_printf("%?-s %s %s %?-s %?-s %3s %-6s %s\n",
"ADDR", "PTY", "FL", "MASTERQ", "SLAVEQ",
"ZID", "PID", "PROC");
}
return (DCMD_USAGE);
}
return (DCMD_USAGE);
}
mdb_warn("failed to read pty structure");
return (DCMD_ERR);
}
return (DCMD_OK);
return (DCMD_OK);
/*
* Options are specified for filtering, so If any option is specified on
* the command line, just print address and exit.
*/
return (DCMD_OK);
}
(void) strcpy(c, "<defunct>");
else
} else
(void) strcpy(c, "<unknown>");
(void) mdb_printf("%0?p %3d %2x %0?p %0?p %3d %6d %s\n",
if (verbose) {
int i, arm = 0;
continue;
if (!arm) {
mdb_printf("%*s|\n%*s+--> ",
arm = 1;
} else
mdb_printf("%-12s %s\n",
}
}
return (DCMD_OK);
}
static void
{
char c[MAXCOMLEN + 1];
proc_t p;
(void) strcpy(c, "<defunct>");
else
} else
(void) strcpy(c, "<unknown>");
if (ismaster)
else
}
void
{
}
void
{
}
static int
{
mdb_warn("ptms supports only global walks");
return (WALK_ERR);
}
mdb_warn("failed to read 'ptms_slots'");
return (WALK_ERR);
}
mdb_warn("failed to read 'ptms_nslots'");
return (WALK_ERR);
}
/*
* We remember the pointer value at the end of the array. When
* the walk gets there, we're done.
*/
return (WALK_NEXT);
}
static int
{
int status;
return (WALK_DONE);
(sizeof (struct pt_ttys *))) {
return (WALK_DONE);
}
return (WALK_NEXT);
}
sizeof (struct pt_ttys)) {
return (WALK_DONE);
}
return (status);
}
static void
{
}
static const mdb_dcmd_t dcmds[] = {
{ "ptms", "?[-v] [-f flag] [-F flag]",
"print pseudo-terminal information", ptms },
{ "pty", "?[-v] [-f flag] [-F flag]",
"print pseudo-terminal information (alias of ::ptms", ptms },
{ NULL }
};
static const mdb_walker_t walkers[] = {
{ "ptms", "walk list of pseudo-tty's",
{ "pty", "walk list of pseudo-tty's (alias of ::walk ptms)",
{ NULL }
};
static const mdb_qops_t ptm_qops = {
};
static const mdb_qops_t pts_qops = {
};
static const mdb_modinfo_t modinfo = {
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}
void
_mdb_fini(void)
{
}