Updates and enhancements to io.d to aid DTrace scripting
+ Add dev_type do devinfo_t + Add b_cmd to bufinfo_t + Add constants for BIO_* and DEVSTAT_TYPE_* + Add inline for converting BIO_* int to string + Add inline for converting DEVSTAT_TYPE_* int to string + Add mask for dev_type & DEVSTAT_TYPE_MASK to string + Add mask for dev_type & DEVSTAT_TYPE_IF_MASK to string Reviewed by: markj Sponsored by: Smule, Inc. Differential Revision: https://reviews.freebsd.org/D14396
This commit is contained in:
parent
a241c14f9a
commit
03a3981b89
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329914
@ -18,6 +18,8 @@
|
|||||||
*
|
*
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*
|
*
|
||||||
|
* Portions Copyright 2018 Devin Teske dteske@freebsd.org
|
||||||
|
*
|
||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
@ -32,6 +34,7 @@ typedef struct devinfo {
|
|||||||
int dev_major; /* major number */
|
int dev_major; /* major number */
|
||||||
int dev_minor; /* minor number */
|
int dev_minor; /* minor number */
|
||||||
int dev_instance; /* instance number */
|
int dev_instance; /* instance number */
|
||||||
|
int dev_type; /* type of device */
|
||||||
string dev_name; /* name of device */
|
string dev_name; /* name of device */
|
||||||
string dev_statname; /* name of device + instance/minor */
|
string dev_statname; /* name of device + instance/minor */
|
||||||
string dev_pathname; /* pathname of device */
|
string dev_pathname; /* pathname of device */
|
||||||
@ -42,12 +45,14 @@ translator devinfo_t < struct devstat *D > {
|
|||||||
dev_major = D->device_number;
|
dev_major = D->device_number;
|
||||||
dev_minor = D->unit_number;
|
dev_minor = D->unit_number;
|
||||||
dev_instance = 0;
|
dev_instance = 0;
|
||||||
|
dev_type = D->device_type;
|
||||||
dev_name = stringof(D->device_name);
|
dev_name = stringof(D->device_name);
|
||||||
dev_statname = stringof(D->device_name);
|
dev_statname = stringof(D->device_name);
|
||||||
dev_pathname = stringof(D->device_name);
|
dev_pathname = stringof(D->device_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct bufinfo {
|
typedef struct bufinfo {
|
||||||
|
int b_cmd; /* I/O operation */
|
||||||
int b_flags; /* flags */
|
int b_flags; /* flags */
|
||||||
long b_bcount; /* number of bytes */
|
long b_bcount; /* number of bytes */
|
||||||
caddr_t b_addr; /* buffer address */
|
caddr_t b_addr; /* buffer address */
|
||||||
@ -62,6 +67,7 @@ typedef struct bufinfo {
|
|||||||
|
|
||||||
#pragma D binding "1.0" translator
|
#pragma D binding "1.0" translator
|
||||||
translator bufinfo_t < struct bio *B > {
|
translator bufinfo_t < struct bio *B > {
|
||||||
|
b_cmd = B->bio_cmd;
|
||||||
b_flags = B->bio_flags;
|
b_flags = B->bio_flags;
|
||||||
b_bcount = B->bio_bcount;
|
b_bcount = B->bio_bcount;
|
||||||
b_addr = B->bio_data;
|
b_addr = B->bio_data;
|
||||||
@ -105,3 +111,151 @@ inline int O_SYNC = 0x0080;
|
|||||||
#pragma D binding "1.1" O_SYNC
|
#pragma D binding "1.1" O_SYNC
|
||||||
inline int O_TRUNC = 0x0400;
|
inline int O_TRUNC = 0x0400;
|
||||||
#pragma D binding "1.1" O_TRUNC
|
#pragma D binding "1.1" O_TRUNC
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following inline constants can be used to examine bio_cmd of struct bio
|
||||||
|
* or a translated bufinfo_t.
|
||||||
|
*/
|
||||||
|
inline int BIO_READ = 0x01;
|
||||||
|
#pragma D binding "1.13" BIO_READ
|
||||||
|
inline int BIO_WRITE = 0x02;
|
||||||
|
#pragma D binding "1.13" BIO_WRITE
|
||||||
|
inline int BIO_DELETE = 0x03;
|
||||||
|
#pragma D binding "1.13" BIO_DELETE
|
||||||
|
inline int BIO_GETATTR = 0x04;
|
||||||
|
#pragma D binding "1.13" BIO_GETATTR
|
||||||
|
inline int BIO_FLUSH = 0x05;
|
||||||
|
#pragma D binding "1.13" BIO_FLUSH
|
||||||
|
inline int BIO_CMD0 = 0x06;
|
||||||
|
#pragma D binding "1.13" BIO_CMD0
|
||||||
|
inline int BIO_CMD1 = 0x07;
|
||||||
|
#pragma D binding "1.13" BIO_CMD1
|
||||||
|
inline int BIO_CMD2 = 0x08;
|
||||||
|
#pragma D binding "1.13" BIO_CMD2
|
||||||
|
inline int BIO_ZONE = 0x09;
|
||||||
|
#pragma D binding "1.13" BIO_ZONE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following inline constants can be used to examine bio_flags of struct
|
||||||
|
* bio or a translated bufinfo_t.
|
||||||
|
*/
|
||||||
|
inline int BIO_ERROR = 0x01;
|
||||||
|
#pragma D binding "1.13" BIO_ERROR
|
||||||
|
inline int BIO_DONE = 0x02;
|
||||||
|
#pragma D binding "1.13" BIO_DONE
|
||||||
|
inline int BIO_ONQUEUE = 0x04;
|
||||||
|
#pragma D binding "1.13" BIO_ONQUEUE
|
||||||
|
inline int BIO_ORDERED = 0x08;
|
||||||
|
#pragma D binding "1.13" BIO_ORDERED
|
||||||
|
inline int BIO_UNMAPPED = 0x10;
|
||||||
|
#pragma D binding "1.13" BIO_UNMAPPED
|
||||||
|
inline int BIO_TRANSIENT_MAPPING = 0x20;
|
||||||
|
#pragma D binding "1.13" BIO_TRANSIENT_MAPPING
|
||||||
|
inline int BIO_VLIST = 0x40;
|
||||||
|
#pragma D binding "1.13" BIO_VLIST
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following inline constants can be used to examine device_type of struct
|
||||||
|
* devstat or a translated devinfo_t.
|
||||||
|
*/
|
||||||
|
inline int DEVSTAT_TYPE_DIRECT = 0x000;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_DIRECT
|
||||||
|
inline int DEVSTAT_TYPE_SEQUENTIAL = 0x001;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_SEQUENTIAL
|
||||||
|
inline int DEVSTAT_TYPE_PRINTER = 0x002;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_PRINTER
|
||||||
|
inline int DEVSTAT_TYPE_PROCESSOR = 0x003;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_PROCESSOR
|
||||||
|
inline int DEVSTAT_TYPE_WORM = 0x004;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_WORM
|
||||||
|
inline int DEVSTAT_TYPE_CDROM = 0x005;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_CDROM
|
||||||
|
inline int DEVSTAT_TYPE_SCANNER = 0x006;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_SCANNER
|
||||||
|
inline int DEVSTAT_TYPE_OPTICAL = 0x007;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_OPTICAL
|
||||||
|
inline int DEVSTAT_TYPE_CHANGER = 0x008;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_CHANGER
|
||||||
|
inline int DEVSTAT_TYPE_COMM = 0x009;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_COMM
|
||||||
|
inline int DEVSTAT_TYPE_ASC0 = 0x00a;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_ASC0
|
||||||
|
inline int DEVSTAT_TYPE_ASC1 = 0x00b;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_ASC1
|
||||||
|
inline int DEVSTAT_TYPE_STORARRAY = 0x00c;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_STORARRAY
|
||||||
|
inline int DEVSTAT_TYPE_ENCLOSURE = 0x00d;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_ENCLOSURE
|
||||||
|
inline int DEVSTAT_TYPE_FLOPPY = 0x00e;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_FLOPPY
|
||||||
|
inline int DEVSTAT_TYPE_MASK = 0x00f;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_MASK
|
||||||
|
inline int DEVSTAT_TYPE_IF_SCSI = 0x010;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_IF_SCSI
|
||||||
|
inline int DEVSTAT_TYPE_IF_IDE = 0x020;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_IF_IDE
|
||||||
|
inline int DEVSTAT_TYPE_IF_OTHER = 0x030;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_IF_OTHER
|
||||||
|
inline int DEVSTAT_TYPE_IF_MASK = 0x0f0;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_IF_MASK
|
||||||
|
inline int DEVSTAT_TYPE_PASS = 0x100;
|
||||||
|
#pragma D binding "1.13" DEVSTAT_TYPE_PASS
|
||||||
|
|
||||||
|
#pragma D binding "1.13" device_type_string
|
||||||
|
inline string device_type_string[int type] =
|
||||||
|
type == DEVSTAT_TYPE_DIRECT ? "DIRECT" :
|
||||||
|
type == DEVSTAT_TYPE_SEQUENTIAL ? "SEQUENTIAL" :
|
||||||
|
type == DEVSTAT_TYPE_PRINTER ? "PRINTER" :
|
||||||
|
type == DEVSTAT_TYPE_PROCESSOR ? "PROCESSOR" :
|
||||||
|
type == DEVSTAT_TYPE_WORM ? "WORM" :
|
||||||
|
type == DEVSTAT_TYPE_CDROM ? "CDROM" :
|
||||||
|
type == DEVSTAT_TYPE_SCANNER ? "SCANNER" :
|
||||||
|
type == DEVSTAT_TYPE_OPTICAL ? "OPTICAL" :
|
||||||
|
type == DEVSTAT_TYPE_CHANGER ? "CHANGER" :
|
||||||
|
type == DEVSTAT_TYPE_COMM ? "COMM" :
|
||||||
|
type == DEVSTAT_TYPE_ASC0 ? "ASC0" :
|
||||||
|
type == DEVSTAT_TYPE_ASC1 ? "ASC1" :
|
||||||
|
type == DEVSTAT_TYPE_STORARRAY ? "STORARRAY" :
|
||||||
|
type == DEVSTAT_TYPE_ENCLOSURE ? "ENCLOSURE" :
|
||||||
|
type == DEVSTAT_TYPE_FLOPPY ? "FLOPPY" :
|
||||||
|
strjoin("UNKNOWN(", strjoin(lltostr(type), ")"));
|
||||||
|
|
||||||
|
#pragma D binding "1.13" device_type
|
||||||
|
inline string device_type[int type] =
|
||||||
|
device_type_string[type & DEVSTAT_TYPE_MASK];
|
||||||
|
|
||||||
|
#pragma D binding "1.13" device_if_string
|
||||||
|
inline string device_if_string[int type] =
|
||||||
|
type == 0 ? "ACCESS" :
|
||||||
|
type == DEVSTAT_TYPE_IF_SCSI ? "SCSI" :
|
||||||
|
type == DEVSTAT_TYPE_IF_IDE ? "IDE" :
|
||||||
|
type == DEVSTAT_TYPE_IF_OTHER ? "OTHER" :
|
||||||
|
strjoin("UNKNOWN(", strjoin(lltostr(type), ")"));
|
||||||
|
|
||||||
|
#pragma D binding "1.13" device_if
|
||||||
|
inline string device_if[int type] =
|
||||||
|
device_if_string[type & DEVSTAT_TYPE_IF_MASK];
|
||||||
|
|
||||||
|
#pragma D binding "1.13" bio_cmd_string
|
||||||
|
inline string bio_cmd_string[int cmd] =
|
||||||
|
cmd == BIO_READ ? "READ" :
|
||||||
|
cmd == BIO_WRITE ? "WRITE" :
|
||||||
|
cmd == BIO_DELETE ? "DELETE" :
|
||||||
|
cmd == BIO_GETATTR ? "GETATTR" :
|
||||||
|
cmd == BIO_FLUSH ? "FLUSH" :
|
||||||
|
cmd == BIO_CMD0 ? "CMD0" :
|
||||||
|
cmd == BIO_CMD1 ? "CMD1" :
|
||||||
|
cmd == BIO_CMD2 ? "CMD2" :
|
||||||
|
cmd == BIO_ZONE ? "ZONE" :
|
||||||
|
strjoin("UNKNOWN(", strjoin(lltostr(cmd), ")"));
|
||||||
|
|
||||||
|
#pragma D binding "1.13" bio_flag_string
|
||||||
|
inline string bio_flag_string[int flag] =
|
||||||
|
flag == BIO_ERROR ? "ERROR" :
|
||||||
|
flag == BIO_DONE ? "DONE" :
|
||||||
|
flag == BIO_ONQUEUE ? "ONQUEUE" :
|
||||||
|
flag == BIO_ORDERED ? "ORDERED" :
|
||||||
|
flag == BIO_UNMAPPED ? "UNMAPPED" :
|
||||||
|
flag == BIO_TRANSIENT_MAPPING ? "TRANSIENT_MAPPING" :
|
||||||
|
flag == BIO_VLIST ? "VLIST" :
|
||||||
|
"";
|
||||||
|
Loading…
Reference in New Issue
Block a user