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 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <sys/ctfs.h>
29 #include <sys/contract.h>
30 #include <string.h>
31 #include <libnvpair.h>
32 #include <assert.h>
33 #include <unistd.h>
34 #include <errno.h>
35 #include <libcontract.h>
36 #include "libcontract_impl.h"
37
38 /*
39 * Common template routines
40 */
41
42 int
43 ct_tmpl_activate(int fd)
44 {
45 if (ioctl(fd, CT_TACTIVATE) == -1)
46 return (errno);
47 return (0);
450
451 if (event->ctev_goffset > 0 && (error = unpack_and_merge(&info->nvl,
452 event->ctev_buffer, event->ctev_goffset)) != 0)
453 goto errout;
454
455 if (event->ctev_goffset < event->ctev_nbytes &&
456 (error = unpack_and_merge(&info->nvl,
457 event->ctev_buffer + event->ctev_goffset,
458 event->ctev_nbytes - event->ctev_goffset)) != 0)
459 goto errout;
460
461 free(event_buffer);
462
463 *evt = info;
464 return (0);
465
466 errout:
467 if (event_buffer)
468 free(event_buffer);
469 if (info) {
470 if (info->nvl)
471 nvlist_free(info->nvl);
472 free(info);
473 }
474 return (error);
475 }
476
477 int
478 ct_event_read(int fd, ct_evthdl_t *evthdl)
479 {
480 return (ct_event_read_internal(fd, CT_ERECV, evthdl));
481 }
482
483 int
484 ct_event_read_critical(int fd, ct_evthdl_t *evthdl)
485 {
486 return (ct_event_read_internal(fd, CT_ECRECV, evthdl));
487 }
488
489 int
490 ct_event_reset(int fd)
491 {
492 if (ioctl(fd, CT_ERESET) == -1)
493 return (errno);
494 return (0);
495 }
496
497 int
498 ct_event_reliable(int fd)
499 {
500 if (ioctl(fd, CT_ERELIABLE) == -1)
501 return (errno);
502 return (0);
503 }
504
505 void
506 ct_event_free(ct_evthdl_t evthdl)
507 {
508 struct ctlib_event_info *info = evthdl;
509
510 if (info->nvl)
511 nvlist_free(info->nvl);
512 free(info);
513 }
514
515
516 uint_t
517 ct_event_get_flags(ct_evthdl_t evthdl)
518 {
519 struct ctlib_event_info *info = evthdl;
520 return (info->event.ctev_flags);
521 }
522
523 ctid_t
524 ct_event_get_ctid(ct_evthdl_t evthdl)
525 {
526 struct ctlib_event_info *info = evthdl;
527 return (info->event.ctev_id);
528 }
529
530 ctevid_t
|
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 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/ctfs.h>
27 #include <sys/contract.h>
28 #include <string.h>
29 #include <libnvpair.h>
30 #include <assert.h>
31 #include <unistd.h>
32 #include <errno.h>
33 #include <libcontract.h>
34 #include "libcontract_impl.h"
35
36 /*
37 * Common template routines
38 */
39
40 int
41 ct_tmpl_activate(int fd)
42 {
43 if (ioctl(fd, CT_TACTIVATE) == -1)
44 return (errno);
45 return (0);
448
449 if (event->ctev_goffset > 0 && (error = unpack_and_merge(&info->nvl,
450 event->ctev_buffer, event->ctev_goffset)) != 0)
451 goto errout;
452
453 if (event->ctev_goffset < event->ctev_nbytes &&
454 (error = unpack_and_merge(&info->nvl,
455 event->ctev_buffer + event->ctev_goffset,
456 event->ctev_nbytes - event->ctev_goffset)) != 0)
457 goto errout;
458
459 free(event_buffer);
460
461 *evt = info;
462 return (0);
463
464 errout:
465 if (event_buffer)
466 free(event_buffer);
467 if (info) {
468 nvlist_free(info->nvl);
469 free(info);
470 }
471 return (error);
472 }
473
474 int
475 ct_event_read(int fd, ct_evthdl_t *evthdl)
476 {
477 return (ct_event_read_internal(fd, CT_ERECV, evthdl));
478 }
479
480 int
481 ct_event_read_critical(int fd, ct_evthdl_t *evthdl)
482 {
483 return (ct_event_read_internal(fd, CT_ECRECV, evthdl));
484 }
485
486 int
487 ct_event_reset(int fd)
488 {
489 if (ioctl(fd, CT_ERESET) == -1)
490 return (errno);
491 return (0);
492 }
493
494 int
495 ct_event_reliable(int fd)
496 {
497 if (ioctl(fd, CT_ERELIABLE) == -1)
498 return (errno);
499 return (0);
500 }
501
502 void
503 ct_event_free(ct_evthdl_t evthdl)
504 {
505 struct ctlib_event_info *info = evthdl;
506
507 nvlist_free(info->nvl);
508 free(info);
509 }
510
511
512 uint_t
513 ct_event_get_flags(ct_evthdl_t evthdl)
514 {
515 struct ctlib_event_info *info = evthdl;
516 return (info->event.ctev_flags);
517 }
518
519 ctid_t
520 ct_event_get_ctid(ct_evthdl_t evthdl)
521 {
522 struct ctlib_event_info *info = evthdl;
523 return (info->event.ctev_id);
524 }
525
526 ctevid_t
|