1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
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 * $FreeBSD$
22 */
23/*
24 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25 * Use is subject to license terms.
26 */
27
28#pragma ident	"%Z%%M%	%I%	%E% SMI"
29
30#pragma D depends_on provider io
31
32typedef struct devinfo {
33        int dev_major;                  /* major number */
34        int dev_minor;                  /* minor number */
35        int dev_instance;               /* instance number */
36        string dev_name;                /* name of device */
37        string dev_statname;            /* name of device + instance/minor */
38        string dev_pathname;            /* pathname of device */
39} devinfo_t;
40
41#pragma D binding "1.0" translator
42translator devinfo_t < struct devstat *D > {
43           dev_major = D->device_number;
44           dev_minor = D->unit_number;
45           dev_instance = 0;
46           dev_name = stringof(D->device_name);
47           dev_statname = stringof(D->device_name);
48           dev_pathname = stringof(D->device_name);
49};
50
51typedef struct bufinfo {
52        int b_flags;                    /* flags */
53        long b_bcount;                /* number of bytes */
54        caddr_t b_addr;                 /* buffer address */
55        uint64_t b_blkno;               /* expanded block # on device */
56        uint64_t b_lblkno;              /* block # on device */
57        size_t b_resid;                 /* # of bytes not transferred */
58        size_t b_bufsize;               /* size of allocated buffer */
59/*        caddr_t b_iodone;              I/O completion routine */
60        int b_error;                    /* expanded error field */
61/*        dev_t b_edev;                  extended device */
62} bufinfo_t;
63
64#pragma D binding "1.0" translator
65translator bufinfo_t < struct bio *B > {
66           b_flags = B->bio_flags;
67           b_bcount = B->bio_bcount;
68           b_addr = B->bio_data;
69           b_blkno = 0;
70           b_lblkno = 0;
71           b_resid = B->bio_resid;
72           b_bufsize = 0; /* XXX gnn */
73           b_error = B->bio_error;
74};
75
76/*
77 * The following inline constants can be used to examine fi_oflags when using
78 * the fds[] array or a translated fileinfo_t.  Note that the various open
79 * flags behave as a bit-field *except* for O_RDONLY, O_WRONLY, and O_RDWR.
80 * To test the open mode, you write code similar to that used with the fcntl(2)
81 * F_GET[X]FL command, such as: if ((fi_oflags & O_ACCMODE) == O_WRONLY).
82 */
83inline int O_ACCMODE = 0x0003;
84#pragma D binding "1.1" O_ACCMODE
85
86inline int O_RDONLY = 0x0000;
87#pragma D binding "1.1" O_RDONLY
88inline int O_WRONLY = 0x0001;
89#pragma D binding "1.1" O_WRONLY
90inline int O_RDWR = 0x0002;
91#pragma D binding "1.1" O_RDWR
92
93inline int O_APPEND = 0x0008;
94#pragma D binding "1.1" O_APPEND
95inline int O_CREAT = 0x0200;
96#pragma D binding "1.1" O_CREAT
97inline int O_EXCL = 0x0800;
98#pragma D binding "1.1" O_EXCL
99inline int O_NOCTTY = 0x8000;
100#pragma D binding "1.1" O_NOCTTY
101inline int O_NONBLOCK = 0x0004;
102#pragma D binding "1.1" O_NONBLOCK
103inline int O_NDELAY = 0x0004;
104#pragma D binding "1.1" O_NDELAY
105inline int O_SYNC = 0x0080;
106#pragma D binding "1.1" O_SYNC
107inline int O_TRUNC = 0x0400;
108#pragma D binding "1.1" O_TRUNC
109
110
111