1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _STAT_DSR_H 28*7c478bd9Sstevel@tonic-gate #define _STAT_DSR_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * Description of each device identified 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate typedef struct list_of_disks { 40*7c478bd9Sstevel@tonic-gate char *dtype; /* device type: sd, ssd, md, st, etc. */ 41*7c478bd9Sstevel@tonic-gate int dnum; /* device number */ 42*7c478bd9Sstevel@tonic-gate char *dsk; /* in form of cNtNdN */ 43*7c478bd9Sstevel@tonic-gate char *dname; /* in form of /dev/dsk/cNtNdN */ 44*7c478bd9Sstevel@tonic-gate char *devidstr; /* in form of "id1,sd@XXXX" */ 45*7c478bd9Sstevel@tonic-gate uint_t flags; /* see SLICES_OK and PARTITIONS_OK above */ 46*7c478bd9Sstevel@tonic-gate int devtype; /* disk, metadevice, tape */ 47*7c478bd9Sstevel@tonic-gate uint_t seen; /* Used for diffing disk lists */ 48*7c478bd9Sstevel@tonic-gate struct list_of_disks *next; /* link to next one */ 49*7c478bd9Sstevel@tonic-gate } disk_list_t; 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* 52*7c478bd9Sstevel@tonic-gate * Description of each mount point currently existing on the system. 53*7c478bd9Sstevel@tonic-gate */ 54*7c478bd9Sstevel@tonic-gate typedef struct mnt_info { 55*7c478bd9Sstevel@tonic-gate char *device_name; 56*7c478bd9Sstevel@tonic-gate char *mount_point; 57*7c478bd9Sstevel@tonic-gate char *devinfo; 58*7c478bd9Sstevel@tonic-gate uint_t minor; 59*7c478bd9Sstevel@tonic-gate struct mnt_info *next; 60*7c478bd9Sstevel@tonic-gate } mnt_t; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * A basic description of each device found 64*7c478bd9Sstevel@tonic-gate * on the system by walking the device tree. 65*7c478bd9Sstevel@tonic-gate * These entries are used to select the 66*7c478bd9Sstevel@tonic-gate * relevent entries from the actual /dev 67*7c478bd9Sstevel@tonic-gate * entries. 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate typedef struct ldinfo { 70*7c478bd9Sstevel@tonic-gate char *name; 71*7c478bd9Sstevel@tonic-gate char *dtype; 72*7c478bd9Sstevel@tonic-gate char *devidstr; 73*7c478bd9Sstevel@tonic-gate int dnum; 74*7c478bd9Sstevel@tonic-gate struct ldinfo *next; 75*7c478bd9Sstevel@tonic-gate } ldinfo_t; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* 78*7c478bd9Sstevel@tonic-gate * Optimization for lookup of kstats. 79*7c478bd9Sstevel@tonic-gate * For each kstat prefix (e.g., 'sd') 80*7c478bd9Sstevel@tonic-gate * found in a directory one of these 81*7c478bd9Sstevel@tonic-gate * structures will be created. 82*7c478bd9Sstevel@tonic-gate * 83*7c478bd9Sstevel@tonic-gate * name: prefix of kstat name (e.g., 'ssd') 84*7c478bd9Sstevel@tonic-gate * min: smallest number seen from kstat 85*7c478bd9Sstevel@tonic-gate * name (e.g., 101 from 'sd101') 86*7c478bd9Sstevel@tonic-gate * max: largest number seen from kstat 87*7c478bd9Sstevel@tonic-gate * list_start: beginning of disk_list structures 88*7c478bd9Sstevel@tonic-gate * for this kstat type in the main list for 89*7c478bd9Sstevel@tonic-gate * this directory 90*7c478bd9Sstevel@tonic-gate * list_end: end of entries for this kstat type 91*7c478bd9Sstevel@tonic-gate * in this directory. 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate typedef struct dev_name { 94*7c478bd9Sstevel@tonic-gate char *name; 95*7c478bd9Sstevel@tonic-gate uint_t min; 96*7c478bd9Sstevel@tonic-gate uint_t max; 97*7c478bd9Sstevel@tonic-gate disk_list_t *list_start; 98*7c478bd9Sstevel@tonic-gate disk_list_t *list_end; 99*7c478bd9Sstevel@tonic-gate struct dev_name *next; 100*7c478bd9Sstevel@tonic-gate } dev_name_t; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* 103*7c478bd9Sstevel@tonic-gate * Definition of a "type" of disk device. 104*7c478bd9Sstevel@tonic-gate * Tied to the directory containing entries 105*7c478bd9Sstevel@tonic-gate * for that device. Divides the list of 106*7c478bd9Sstevel@tonic-gate * devices into localized chunks and allows 107*7c478bd9Sstevel@tonic-gate * quick determination as to whether an entry 108*7c478bd9Sstevel@tonic-gate * exists or whether we need to look at the 109*7c478bd9Sstevel@tonic-gate * devices upon a state change. 110*7c478bd9Sstevel@tonic-gate */ 111*7c478bd9Sstevel@tonic-gate typedef struct dir_info { 112*7c478bd9Sstevel@tonic-gate char *name; /* directory name */ 113*7c478bd9Sstevel@tonic-gate time_t mtime; /* mod time */ 114*7c478bd9Sstevel@tonic-gate disk_list_t *list; /* master list of devices */ 115*7c478bd9Sstevel@tonic-gate dev_name_t *nf; /* lists per name */ 116*7c478bd9Sstevel@tonic-gate uint_t skip_lookup; /* skip lookup if device */ 117*7c478bd9Sstevel@tonic-gate /* does not have partitions */ 118*7c478bd9Sstevel@tonic-gate char *dtype; /* Type of device */ 119*7c478bd9Sstevel@tonic-gate char *trimstr; /* What do we prune */ 120*7c478bd9Sstevel@tonic-gate char trimchr; /* Char denoting end */ 121*7c478bd9Sstevel@tonic-gate /* of interesting data */ 122*7c478bd9Sstevel@tonic-gate } dir_info_t; 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * The following are used to control treatment of kstat names 126*7c478bd9Sstevel@tonic-gate * which fall beyond the number of disk partitions allowed on 127*7c478bd9Sstevel@tonic-gate * the particular ISA. PARTITIONS_OK is set only on an Intel 128*7c478bd9Sstevel@tonic-gate * system. 129*7c478bd9Sstevel@tonic-gate */ 130*7c478bd9Sstevel@tonic-gate #define SLICES_OK 1 131*7c478bd9Sstevel@tonic-gate #define PARTITIONS_OK 2 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate void do_mnttab(void); 134*7c478bd9Sstevel@tonic-gate mnt_t *lookup_mntent_byname(char *); 135*7c478bd9Sstevel@tonic-gate disk_list_t *lookup_ks_name(char *); 136*7c478bd9Sstevel@tonic-gate char *lookup_nfs_name(char *, kstat_ctl_t *); 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 139*7c478bd9Sstevel@tonic-gate } 140*7c478bd9Sstevel@tonic-gate #endif 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #endif /* _STAT_DSR_H */ 143