Change the devstat generation number from an int to a long. The int-sized

generation was causing unaligned access faults on the Alpha.

I have incremented the devstat version number, since this is an interface
change.  You'll need to recompile libdevstat, systat, iostat, vmstat and
rpc.rstatd along with your kernel.

Partially Submitted by:	Andrew Gallatin <gallatin@cs.duke.edu>
This commit is contained in:
Kenneth D. Merry 1998-09-20 00:11:23 +00:00
parent 0637c2cccd
commit bcc6a3da92
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39498
9 changed files with 48 additions and 42 deletions

View File

@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id$
.\" $Id: devstat.3,v 1.1 1998/09/15 06:23:21 gibbs Exp $
.\"
.Dd May 21, 1998
.Dt DEVSTAT 3
@ -37,7 +37,7 @@
.Fd #include <devstat.h>
.Ft int
.Fn getnumdevs "void"
.Ft int
.Ft long
.Fn getgeneration "void"
.Ft int
.Fn getversion "void"
@ -50,8 +50,8 @@
.Fa "struct device_selection **dev_select"
.Fa "int *num_selected"
.Fa "int *num_selections"
.Fa "int *select_generation"
.Fa "int current_generation"
.Fa "long *select_generation"
.Fa "long current_generation"
.Fa "struct devstat *devices"
.Fa "int numdevs"
.Fa "struct devstat_match *matches"
@ -146,7 +146,7 @@ subelement contains the following elements:
struct devinfo {
struct devstat *devices;
u_int8_t *mem_ptr;
int generation;
long generation;
int numdevs;
};
.Ed

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: devstat.c,v 1.1 1998/09/15 06:23:21 gibbs Exp $
* $Id: devstat.c,v 1.2 1998/09/18 02:35:25 ken Exp $
*/
#include <sys/types.h>
@ -101,14 +101,14 @@ getnumdevs(void)
* the device list and the generation could change between the time that
* this function is called and the device list is retreived.
*/
int
long
getgeneration(void)
{
size_t gensize;
int generation;
long generation;
char *func_name = "getgeneration";
gensize = sizeof(int);
gensize = sizeof(long);
/*
* Get the current generation number.
@ -234,7 +234,8 @@ getdevs(struct statinfo *stats)
{
int error;
size_t dssize;
int oldnumdevs, oldgeneration;
int oldnumdevs;
long oldgeneration;
int retval = 0;
struct devinfo *dinfo;
char *func_name = "getdevs";
@ -266,10 +267,10 @@ getdevs(struct statinfo *stats)
* number, as well as all the devices. So we need four
* bytes more.
*/
dssize =(dinfo->numdevs * sizeof(struct devstat)) + sizeof(int);
dssize =(dinfo->numdevs * sizeof(struct devstat)) +sizeof(long);
dinfo->mem_ptr = (u_int8_t *)malloc(dssize);
} else
dssize =(dinfo->numdevs * sizeof(struct devstat)) + sizeof(int);
dssize =(dinfo->numdevs * sizeof(struct devstat)) +sizeof(long);
/* Get the current time when we get the stats */
gettimeofday(&stats->busy_time, NULL);
@ -298,7 +299,7 @@ getdevs(struct statinfo *stats)
return(-1);
dssize = (dinfo->numdevs * sizeof(struct devstat)) +
sizeof(int);
sizeof(long);
dinfo->mem_ptr = (u_int8_t *)realloc(dinfo->mem_ptr,
dssize);
if ((error = sysctlbyname("kern.devstat.all",
@ -322,7 +323,7 @@ getdevs(struct statinfo *stats)
* The sysctl spits out the generation as the first four bytes,
* then all of the device statistics structures.
*/
dinfo->generation = *(int *)dinfo->mem_ptr;
dinfo->generation = *(long *)dinfo->mem_ptr;
/*
* If the generation has changed, and if the current number of
@ -344,14 +345,14 @@ getdevs(struct statinfo *stats)
if ((dinfo->numdevs = getnumdevs()) < 0)
return(-1);
dssize = (dinfo->numdevs * sizeof(struct devstat)) +
sizeof(int);
sizeof(long);
dinfo->mem_ptr = (u_int8_t *)realloc(dinfo->mem_ptr,
dssize);
}
retval = 1;
}
dinfo->devices = (struct devstat *)(dinfo->mem_ptr + sizeof(int));
dinfo->devices = (struct devstat *)(dinfo->mem_ptr + sizeof(long));
return(retval);
}
@ -419,8 +420,8 @@ getdevs(struct statinfo *stats)
*/
int
selectdevs(struct device_selection **dev_select, int *num_selected,
int *num_selections, int *select_generation,
int current_generation, struct devstat *devices, int numdevs,
int *num_selections, long *select_generation,
long current_generation, struct devstat *devices, int numdevs,
struct devstat_match *matches, int num_matches,
char **dev_selections, int num_dev_selections,
devstat_select_mode select_mode, int maxshowdevs, int perf_select)

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: devstat.h,v 1.1 1998/09/15 06:23:21 gibbs Exp $
*/
#ifndef _DEVSTAT_H
@ -68,7 +68,7 @@ struct device_selection {
struct devinfo {
struct devstat *devices;
u_int8_t *mem_ptr;
int generation;
long generation;
int numdevs;
};
@ -89,13 +89,13 @@ typedef enum {
__BEGIN_DECLS
int getnumdevs(void);
int getgeneration(void);
long getgeneration(void);
int getversion(void);
int checkversion(void);
int getdevs(struct statinfo *stats);
int selectdevs(struct device_selection **dev_select, int *num_selected,
int *num_selections, int *select_generation,
int current_generation, struct devstat *devices, int numdevs,
int *num_selections, long *select_generation,
long current_generation, struct devstat *devices, int numdevs,
struct devstat_match *matches, int num_matches,
char **dev_selections, int num_dev_selections,
devstat_select_mode select_mode, int maxshowdevs,

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: subr_devstat.c,v 1.1 1998/09/15 08:16:09 gibbs Exp $
*/
#include <sys/param.h>
@ -38,7 +38,7 @@
#include <sys/devicestat.h>
static int devstat_num_devs;
static int devstat_generation;
static long devstat_generation;
static int devstat_version = DEVSTAT_VERSION;
static int devstat_current_devnumber;
@ -212,7 +212,7 @@ sysctl_devstat SYSCTL_HANDLER_ARGS
/*
* First push out the generation number.
*/
error = SYSCTL_OUT(req, &devstat_generation, sizeof(int));
error = SYSCTL_OUT(req, &devstat_generation, sizeof(long));
/*
* Now push out all the devices.
@ -239,7 +239,7 @@ SYSCTL_PROC(_kern_devstat, OID_AUTO, all, CTLFLAG_RD|CTLTYPE_OPAQUE,
*/
SYSCTL_INT(_kern_devstat, OID_AUTO, numdevs, CTLFLAG_RD, &devstat_num_devs,
0, "Number of devices in the devstat list");
SYSCTL_INT(_kern_devstat, OID_AUTO, generation, CTLFLAG_RD, &devstat_generation,
0, "Devstat list generation");
SYSCTL_LONG(_kern_devstat, OID_AUTO, generation, CTLFLAG_RD,
&devstat_generation, 0, "Devstat list generation");
SYSCTL_INT(_kern_devstat, OID_AUTO, version, CTLFLAG_RD, &devstat_version,
0, "Devstat list version number");

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: devicestat.h,v 1.1 1998/09/15 08:16:17 gibbs Exp $
*/
#ifndef _DEVICESTAT_H
@ -45,7 +45,7 @@
* userland utilities to determine whether or not they are in sync with the
* kernel.
*/
#define DEVSTAT_VERSION 1
#define DEVSTAT_VERSION 2
/*
* These flags specify which statistics features are supported or not

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: devs.c,v 1.1 1998/09/15 08:16:40 gibbs Exp $
*/
/*
* Some code and ideas taken from the old disks.c.
@ -81,8 +81,10 @@ typedef enum {
last_match_type last_type;
struct device_selection *dev_select;
int generation, num_devices, num_selected;
int num_selections, select_generation;
long generation;
int num_devices, num_selected;
int num_selections;
long select_generation;
struct devstat_match *matches = NULL;
int num_matches = 0;
char **specified_devices;

View File

@ -61,11 +61,11 @@ extern int verbose;
struct inpcb;
extern struct device_selection *dev_select;
extern int generation;
extern long generation;
extern int num_devices;
extern int num_selected;
extern int num_selections;
extern int select_generation;
extern long select_generation;
int checkhost __P((struct inpcb *));
int checkport __P((struct inpcb *));

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)vmstat.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: vmstat.c,v 1.25 1998/09/15 08:16:43 gibbs Exp $";
"$Id: vmstat.c,v 1.26 1998/09/16 18:20:23 dillon Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -142,12 +142,14 @@ struct nlist namelist[] = {
};
struct statinfo cur, last;
int num_devices, maxshowdevs, generation;
int num_devices, maxshowdevs;
long generation;
struct device_selection *dev_select;
int num_selected;
struct devstat_match *matches;
int num_matches = 0;
int num_devices_specified, num_selections, select_generation;
int num_devices_specified, num_selections;
long select_generation;
char **specified_devices;
devstat_select_mode select_mode;

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: iostat.c,v 1.10 1998/09/16 18:03:44 dillon Exp $
* $Id: iostat.c,v 1.11 1998/09/16 23:14:47 ken Exp $
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
@ -155,7 +155,7 @@ usage(void)
* This isn't mentioned in the man page, or the usage statement,
* but it is supported.
*/
fprintf(stderr, "usage: iostat [-CdhIoT?] [-c count] [-M core]"
fprintf(stderr, "usage: iostat [-CdhIKoT?] [-c count] [-M core]"
" [-n devs] [-N system]\n"
"\t [-t type,if,pass] [-w wait] [drives]\n");
}
@ -175,9 +175,10 @@ main(int argc, char **argv)
kvm_t *kd;
int hz, stathz;
int headercount;
int generation;
long generation;
int num_devices_specified;
int num_selected, num_selections, select_generation;
int num_selected, num_selections;
long select_generation;
char **specified_devices;
devstat_select_mode select_mode;