Print this page
6198 Let's EOL cachefs


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /* LINTLIBRARY */
  23 /* PROTOLIB1 */
  24 
  25 /*
  26  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  27  * Use is subject to license terms.

  28  */
  29 
  30 /*
  31  * nfsstat: Network File System statistics
  32  *
  33  */
  34 
  35 #include <stdio.h>
  36 #include <stdlib.h>
  37 #include <unistd.h>
  38 #include <stdarg.h>
  39 #include <string.h>
  40 #include <errno.h>
  41 #include <fcntl.h>
  42 #include <kvm.h>
  43 #include <kstat.h>
  44 #include <sys/param.h>
  45 #include <sys/types.h>
  46 #include <sys/t_lock.h>
  47 #include <sys/tiuser.h>


1098                          */
1099                         if ((mrp->ig_path = malloc(
1100                             strlen(m.mnt_mountp) + 1)) == 0) {
1101                                 fprintf(stderr, "nfsstat: not enough memory\n");
1102                                 exit(1);
1103                         }
1104                         (void) strcpy(mrp->ig_path, m.mnt_mountp);
1105                         ignored++;
1106                 } else {
1107                         mrp->ig_path = 0;
1108                         (void) strcpy(mrp->my_dir, m.mnt_mountp);
1109                 }
1110                 if ((mrp->my_path = strdup(m.mnt_special)) == NULL) {
1111                         fprintf(stderr, "nfsstat: not enough memory\n");
1112                         exit(1);
1113                 }
1114                 mrp->next = list;
1115                 list = mrp;
1116         }
1117 
1118         /*
1119          * If something got ignored, go to the beginning of the mnttab
1120          * and look for the cachefs entries since they are the one
1121          * causing this. The mount point saved for the ignored entries
1122          * is matched against the special to get the actual mount point.
1123          * We are interested in the acutal mount point so that the output
1124          * look nice too.
1125          */
1126         if (ignored) {
1127                 rewind(mt);
1128                 resetmnttab(mt);
1129                 while (getextmntent(mt, &m, sizeof (struct extmnttab)) == 0) {
1130 
1131                         /* ignore non "cachefs" */
1132                         if (strcmp(m.mnt_fstype, MNTTYPE_CACHEFS) != 0)
1133                                 continue;
1134 
1135                         for (mrp = list; mrp; mrp = mrp->next) {
1136                                 if (mrp->ig_path == 0)
1137                                         continue;
1138                                 if (strcmp(mrp->ig_path, m.mnt_special) == 0) {
1139                                         mrp->ig_path = 0;
1140                                         (void) strcpy(mrp->my_dir,
1141                                             m.mnt_mountp);
1142                                 }
1143                         }
1144                 }
1145                 /*
1146                  * Now ignored entries which do not have
1147                  * the my_dir initialized are really ignored; This never
1148                  * happens unless the mnttab is corrupted.
1149                  */
1150                 for (pmrp = 0, mrp = list; mrp; mrp = mrp->next) {
1151                         if (mrp->ig_path == 0)
1152                                 pmrp = mrp;
1153                         else if (pmrp)
1154                                 pmrp->next = mrp->next;
1155                         else
1156                                 list = mrp->next;
1157                 }
1158         }
1159 
1160         (void) fclose(mt);
1161 
1162 
1163         for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
1164                 int i;
1165 
1166                 if (ksp->ks_type != KSTAT_TYPE_RAW)
1167                         continue;
1168                 if (strcmp(ksp->ks_module, "nfs") != 0)
1169                         continue;
1170                 if (strcmp(ksp->ks_name, "mntinfo") != 0)
1171                         continue;
1172 
1173                 for (mrp = list; mrp; mrp = mrp->next) {
1174                         if ((mrp->my_fsid & MAXMIN) == ksp->ks_instance)
1175                                 break;
1176                 }
1177                 if (mrp == 0)
1178                         continue;
1179 
1180                 if (safe_kstat_read(kc, ksp, &mik) == -1)
1181                         continue;
1182 




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /* LINTLIBRARY */
  23 /* PROTOLIB1 */
  24 
  25 /*
  26  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  27  * Use is subject to license terms.
  28  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  29  */
  30 
  31 /*
  32  * nfsstat: Network File System statistics
  33  *
  34  */
  35 
  36 #include <stdio.h>
  37 #include <stdlib.h>
  38 #include <unistd.h>
  39 #include <stdarg.h>
  40 #include <string.h>
  41 #include <errno.h>
  42 #include <fcntl.h>
  43 #include <kvm.h>
  44 #include <kstat.h>
  45 #include <sys/param.h>
  46 #include <sys/types.h>
  47 #include <sys/t_lock.h>
  48 #include <sys/tiuser.h>


1099                          */
1100                         if ((mrp->ig_path = malloc(
1101                             strlen(m.mnt_mountp) + 1)) == 0) {
1102                                 fprintf(stderr, "nfsstat: not enough memory\n");
1103                                 exit(1);
1104                         }
1105                         (void) strcpy(mrp->ig_path, m.mnt_mountp);
1106                         ignored++;
1107                 } else {
1108                         mrp->ig_path = 0;
1109                         (void) strcpy(mrp->my_dir, m.mnt_mountp);
1110                 }
1111                 if ((mrp->my_path = strdup(m.mnt_special)) == NULL) {
1112                         fprintf(stderr, "nfsstat: not enough memory\n");
1113                         exit(1);
1114                 }
1115                 mrp->next = list;
1116                 list = mrp;
1117         }
1118 
1119         (void) fclose(mt);











1120 
1121         if (ignored) {













1122                 /*
1123                  * Now ignored entries which do not have
1124                  * the my_dir initialized are really ignored; This never
1125                  * happens unless the mnttab is corrupted.
1126                  */
1127                 for (pmrp = 0, mrp = list; mrp; mrp = mrp->next) {
1128                         if (mrp->ig_path == 0)
1129                                 pmrp = mrp;
1130                         else if (pmrp)
1131                                 pmrp->next = mrp->next;
1132                         else
1133                                 list = mrp->next;
1134                 }
1135         }
1136 



1137         for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
1138                 int i;
1139 
1140                 if (ksp->ks_type != KSTAT_TYPE_RAW)
1141                         continue;
1142                 if (strcmp(ksp->ks_module, "nfs") != 0)
1143                         continue;
1144                 if (strcmp(ksp->ks_name, "mntinfo") != 0)
1145                         continue;
1146 
1147                 for (mrp = list; mrp; mrp = mrp->next) {
1148                         if ((mrp->my_fsid & MAXMIN) == ksp->ks_instance)
1149                                 break;
1150                 }
1151                 if (mrp == 0)
1152                         continue;
1153 
1154                 if (safe_kstat_read(kc, ksp, &mik) == -1)
1155                         continue;
1156