dumpnamespace.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "mdinclude.h"
/*
* work out the offset size
*/
#define MY_DID_SHR_NAMSIZ(n) \
(((sizeof (struct did_shr_name) - 1) + \
#define MY_SHR_NAMSIZ(n) \
(((sizeof (struct nm_shared_name) - 1) + \
#define MY_DID_NAMSIZ(n) \
(((sizeof (struct did_min_name) - 1) + \
#define MY_NAMSIZ(n) \
(((sizeof (struct nm_name) - 1) + \
static uintptr_t
{
struct did_shr_name shn;
void *sn_name;
sizeof (struct did_shr_name)) {
return (NULL);
}
return (NULL);
mdb_inc_indent(2);
sn_name_addr) <= 0) {
mdb_warn("failed to read sn_name at %p\n",
return (NULL);
}
}
mdb_dec_indent(2);
return (next_addr);
}
static uintptr_t
{
struct nm_shared_name shn;
void *sn_name;
sizeof (struct nm_shared_name)) {
return (NULL);
}
return (NULL);
mdb_inc_indent(2);
sn_name_addr) <= 0) {
mdb_warn("failed to read sn_name at %p\n",
}
}
mdb_dec_indent(2);
return (next_addr);
}
static uintptr_t
{
struct did_min_name didmn;
void *min_name;
sizeof (struct did_min_name)) {
return (NULL);
}
if (didmn.min_namlen == 0)
return (NULL);
mdb_inc_indent(2);
if (didmn.min_namlen > 0) {
did_name_addr) <= 0) {
mdb_warn("failed to read min_name at %p\n",
}
}
mdb_dec_indent(2);
return (next_addr);
}
static uintptr_t
{
void *n_name;
sizeof (struct nm_name)) {
return (NULL);
}
return (NULL);
mdb_inc_indent(2);
nm_name_addr) <= 0) {
}
}
mdb_dec_indent(2);
return (next_addr);
}
static uint_t
{
struct nm_rec_hdr rhdr;
/*
* we read this anyway as the first part of nm_rec, devid_min_rec,
* nm_shr_rec, and devid_shr_rec record is a nm_rec_hdr
*/
sizeof (struct nm_rec_hdr)) {
return (0);
}
mdb_inc_indent(2);
mdb_dec_indent(2);
return (rhdr.r_used_size);
}
static void
{
struct nm_shr_rec srhdr;
struct devid_shr_rec didsrhdr;
struct devid_min_rec devid_record;
int i;
if (devid) {
if (shared) {
addr) != sizeof (struct devid_shr_rec)) {
mdb_warn("failed to read devid_shr_rec at %p\n",
addr);
return;
}
} else {
if (mdb_vread(&devid_record,
sizeof (struct devid_min_rec), addr)
!= sizeof (struct devid_min_rec)) {
mdb_warn("failed to read devid_min_rec at %p\n",
addr);
return;
}
}
} else {
if (shared) {
!= sizeof (struct nm_shr_rec)) {
mdb_warn("failed to read nm_shr_rec at %p\n",
addr);
return;
}
} else {
!= sizeof (struct nm_rec)) {
return;
}
}
}
mdb_inc_indent(2);
if (devid) {
if (shared) {
/*
* Do the rest of the device_id records.
*/
for (i = 0; ; i++) {
mdb_dec_indent(2);
return;
}
/*
* Causes us to print one extra record.
*/
break;
}
}
} else {
/*
* Now do the rest of the record.
*/
for (i = 0; ; i++) {
mdb_dec_indent(2);
return;
}
break;
}
}
}
} else {
if (shared) {
/*
* Now do the rest of the sr_name records.
*/
for (i = 0; ; i++) {
mdb_dec_indent(2);
return;
}
/*
* Causes us to print one extra record
*/
break;
}
}
} else {
/*
* Now do the rest of the record
*/
for (i = 0; ; i++) {
mdb_dec_indent(2);
return;
}
break;
}
}
}
}
mdb_dec_indent(2);
}
static void
{
struct nm_next_hdr nhdr;
mdb_inc_indent(2);
sizeof (struct nm_next_hdr)) {
return;
}
mdb_printf("\n");
sizeof (struct nm_next_hdr)) {
break;
}
}
mdb_printf("\n");
mdb_dec_indent(2);
}
/*
* Start the processing of a nominated set
*/
static void
process_set(int setno)
{
sizeof (struct nm_header_hdr)) {
return;
}
did_addr) != sizeof (struct nm_header_hdr)) {
mdb_warn("failed to read nm_header_hdr at %p\n",
did_addr);
return;
}
}
}
mdb_printf("hh_names:");
process_nm_next_hdr(names_addr, 0, 0);
mdb_printf("\nhh_shared:");
mdb_printf("did hh_names:");
mdb_printf("\ndid hh_shared:");
}
}
/*
* Dump the name space for all sets or specified set (-s option)
* usage: ::dumpnamespace [-s setname]
*/
/* ARGSUSED */
int
{
int j;
int setno;
/* left over arguments ?? */
return (DCMD_USAGE);
}
snarf_sets();
if (argc == 0) {
for (j = 0; j < md_nsets; j++) {
process_set(j);
}
}
} else {
if (setno == -1) {
return (DCMD_ERR);
}
}
}
return (DCMD_OK);
}