Mercurial > illumos > illumos-gate
changeset 3406:65b3165d3917
6507354 nfsstat cores if nothing nfs mounted or shared and no nfs modules loaded.
author | th199096 |
---|---|
date | Thu, 11 Jan 2007 15:39:02 -0800 |
parents | 3fb8d8f7ae30 |
children | d9ac3b8746e4 |
files | usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c |
diffstat | 1 files changed, 31 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c Thu Jan 11 13:08:20 2007 -0800 +++ b/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c Thu Jan 11 15:39:02 2007 -0800 @@ -2,9 +2,8 @@ * 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. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -19,11 +18,12 @@ * * CDDL HEADER END */ + /* LINTLIBRARY */ /* PROTOLIB1 */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -433,7 +433,6 @@ static void putstats(void) { - if (rpc_clts_client_kstat != NULL) safe_kstat_write(kc, rpc_clts_client_kstat, NULL); if (rpc_cots_client_kstat != NULL) @@ -510,7 +509,7 @@ if (rpc_clts_client_kstat == NULL && rpc_cots_server_kstat == NULL && rfsproccnt_v2_kstat == NULL && rfsreqcnt_v3_kstat == NULL) fail(0, "Multiple kstat lookups failed." - "Your kernal module may not be loaded\n"); + "Your kernel module may not be loaded\n"); } static int @@ -574,6 +573,9 @@ int field_width; field_width = getstats_rpc(); + if (field_width == 0) + return; + stat_print("\nClient rpc:\nConnection oriented:", rpc_cots_client_kstat, &old_rpc_cots_client_kstat.kst, field_width, @@ -592,6 +594,9 @@ int field_width; field_width = getstats_rpc(); + if (field_width == 0) + return; + stat_print("\nServer rpc:\nConnection oriented:", rpc_cots_server_kstat, &old_rpc_cots_server_kstat.kst, field_width, zflag); @@ -609,6 +614,8 @@ int field_width; field_width = getstats_nfs(); + if (field_width == 0) + return; if (vflag == 0) { kstat_sum(nfs_client_kstat, nfs4_client_kstat, ksum_kstat); @@ -653,6 +660,9 @@ int field_width; field_width = getstats_nfs(); + if (field_width == 0) + return; + if (vflag == 2 || vflag == 0) { stat_print("\nServer NFSv2:", nfs_server_v2_kstat, &old_nfs_server_v2_kstat.kst, @@ -697,6 +707,9 @@ int field_width; field_width = getstats_aclreq(); + if (field_width == 0) + return; + printf("\nClient nfs_acl:\n"); if (vflag == 2 || vflag == 0) { @@ -716,6 +729,8 @@ int field_width; field_width = getstats_aclproc(); + if (field_width == 0) + return; printf("\nServer nfs_acl:\n"); @@ -746,6 +761,9 @@ if (req == NULL) return; + if (field_width == 0) + return; + ncolumns = (MAX_COLUMNS -1)/field_width; knp = kstat_data_lookup(req, "null"); knp_old = KSTAT_NAMED_PTR(req_old); @@ -753,7 +771,6 @@ kptr = KSTAT_NAMED_PTR(req); nreq = req->ks_ndata - (knp - KSTAT_NAMED_PTR(req)); - tot = 0; old_tot = 0; @@ -826,6 +843,9 @@ if (req == NULL) return; + if (field_width == 0) + return; + ncolumns = (MAX_COLUMNS)/field_width; kptr = KSTAT_NAMED_PTR(req); kptr_old = KSTAT_NAMED_PTR(req_old); @@ -921,6 +941,9 @@ if (req == NULL) return; + if (field_width == 0) + return; + printf("%s\n", title_string); ncolumns = (MAX_COLUMNS -1)/field_width; @@ -956,6 +979,7 @@ else kstat_copy(req, req_old, 0); } + static void kstat_sum(kstat_t *kstat1, kstat_t *kstat2, kstat_t *sum) { @@ -1018,7 +1042,6 @@ list = NULL; resetmnttab(mt); - while (getextmntent(mt, &m, sizeof (struct extmnttab)) == 0) { /* ignore non "nfs" and save the "ignore" entries */ if (strcmp(m.mnt_fstype, MNTTYPE_NFS) != 0)