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.
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.
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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/contract/device.h>
41 #include <libcontract.h>
42 #include <libcontract_priv.h>
43 #include "libcontract_impl.h"
44 #include "libcontract_priv.h"
48 event_device(FILE *file
, ct_evthdl_t ev
, int verbose
)
57 type
= ct_event_get_type(ev
);
58 ctid
= ct_event_get_ctid(ev
);
60 statfd
= contract_open(ctid
, "device", "status", O_RDONLY
);
62 (void) fprintf(file
, dgettext(TEXT_DOMAIN
, "[bad contract]\n"));
66 if (ct_status_read(statfd
, CTD_ALL
, &stathdl
) != 0) {
67 (void) fprintf(file
, dgettext(TEXT_DOMAIN
, "[status error]\n"));
71 if (ct_dev_status_get_minor(stathdl
, &device
) != 0) {
72 (void) fprintf(file
, dgettext(TEXT_DOMAIN
, "[bad status]\n"));
78 case CT_DEV_EV_OFFLINE
:
79 s
= dgettext(TEXT_DOMAIN
, "device %s offlining\n");
81 case CT_DEV_EV_DEGRADED
:
82 s
= dgettext(TEXT_DOMAIN
, "device %s degrading\n");
84 case CT_DEV_EV_ONLINE
:
85 s
= dgettext(TEXT_DOMAIN
, "device %s online\n");
88 contract_negend_dump(file
, ev
);
92 s
= dgettext(TEXT_DOMAIN
, "device %s sent an unknown event\n");
98 (void) fprintf(file
, s
, device
);
101 ct_status_free(stathdl
);
102 (void) close(statfd
);