Print this page
11691 ptree could show service FMRIs
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>


   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 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.

  24  */
  25 
  26 #include <sys/mutex.h>
  27 #include <sys/debug.h>
  28 #include <sys/types.h>
  29 #include <sys/param.h>
  30 #include <sys/kmem.h>
  31 #include <sys/thread.h>
  32 #include <sys/id_space.h>
  33 #include <sys/avl.h>
  34 #include <sys/list.h>
  35 #include <sys/sysmacros.h>
  36 #include <sys/proc.h>
  37 #include <sys/contract.h>
  38 #include <sys/contract_impl.h>
  39 #include <sys/contract/process.h>
  40 #include <sys/contract/process_impl.h>
  41 #include <sys/cmn_err.h>
  42 #include <sys/nvpair.h>
  43 #include <sys/policy.h>


 719          */
 720         VERIFY(nvlist_add_uint32(nvl, CTPS_PARAMS, ctp->conp_params) == 0);
 721         VERIFY(nvlist_add_uint32(nvl, CTPS_EV_FATAL, ctp->conp_ev_fatal) == 0);
 722         if (detail == CTD_ALL) {
 723                 VERIFY(nvlist_add_uint32_array(nvl, CTPS_MEMBERS, pids,
 724                     npids) == 0);
 725                 VERIFY(nvlist_add_uint32_array(nvl, CTPS_CONTRACTS, ctids,
 726                     nctids) == 0);
 727                 VERIFY(nvlist_add_string(nvl, CTPS_CREATOR_AUX,
 728                     refstr_value(ctp->conp_svc_aux)) == 0);
 729                 VERIFY(nvlist_add_string(nvl, CTPS_SVC_CREATOR,
 730                     refstr_value(ctp->conp_svc_creator)) == 0);
 731                 kmem_free(pids, spids * sizeof (uint32_t));
 732                 kmem_free(ctids, sctids * sizeof (uint32_t));
 733         }
 734 
 735         /*
 736          * if we are in a local zone and svc_fmri was inherited from
 737          * the global zone, we provide fake svc_fmri and svc_ctid
 738          */
 739         if (local_svc_zone_enter == 0||
 740             zone->zone_uniqid == GLOBAL_ZONEUNIQID) {
 741                 if (detail > CTD_COMMON) {
 742                         VERIFY(nvlist_add_int32(nvl, CTPS_SVC_CTID,
 743                             ctp->conp_svc_ctid) == 0);
 744                 }
 745                 if (detail == CTD_ALL) {
 746                         VERIFY(nvlist_add_string(nvl, CTPS_SVC_FMRI,
 747                             refstr_value(ctp->conp_svc_fmri)) == 0);
 748                 }
 749         } else {
 750                 if (detail > CTD_COMMON) {
 751                         VERIFY(nvlist_add_int32(nvl, CTPS_SVC_CTID,
 752                             local_svc_zone_enter) == 0);
 753                 }
 754                 if (detail == CTD_ALL) {
 755                         VERIFY(nvlist_add_string(nvl, CTPS_SVC_FMRI,
 756                             CT_PR_SVC_FMRI_ZONE_ENTER) == 0);
 757                 }
 758         }
 759 }
 760 
 761 /*ARGSUSED*/
 762 static int
 763 contract_process_newct(contract_t *ct)
 764 {
 765         return (0);
 766 }
 767 
 768 /* process contracts don't negotiate */
 769 static contops_t contract_process_ops = {
 770         contract_process_free,          /* contop_free */
 771         contract_process_abandon,       /* contop_abandon */
 772         contract_process_destroy,       /* contop_destroy */
 773         contract_process_status,        /* contop_status */
 774         contract_ack_inval,             /* contop_ack */




   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 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2019 Joyent, Inc.
  25  */
  26 
  27 #include <sys/mutex.h>
  28 #include <sys/debug.h>
  29 #include <sys/types.h>
  30 #include <sys/param.h>
  31 #include <sys/kmem.h>
  32 #include <sys/thread.h>
  33 #include <sys/id_space.h>
  34 #include <sys/avl.h>
  35 #include <sys/list.h>
  36 #include <sys/sysmacros.h>
  37 #include <sys/proc.h>
  38 #include <sys/contract.h>
  39 #include <sys/contract_impl.h>
  40 #include <sys/contract/process.h>
  41 #include <sys/contract/process_impl.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/nvpair.h>
  44 #include <sys/policy.h>


 720          */
 721         VERIFY(nvlist_add_uint32(nvl, CTPS_PARAMS, ctp->conp_params) == 0);
 722         VERIFY(nvlist_add_uint32(nvl, CTPS_EV_FATAL, ctp->conp_ev_fatal) == 0);
 723         if (detail == CTD_ALL) {
 724                 VERIFY(nvlist_add_uint32_array(nvl, CTPS_MEMBERS, pids,
 725                     npids) == 0);
 726                 VERIFY(nvlist_add_uint32_array(nvl, CTPS_CONTRACTS, ctids,
 727                     nctids) == 0);
 728                 VERIFY(nvlist_add_string(nvl, CTPS_CREATOR_AUX,
 729                     refstr_value(ctp->conp_svc_aux)) == 0);
 730                 VERIFY(nvlist_add_string(nvl, CTPS_SVC_CREATOR,
 731                     refstr_value(ctp->conp_svc_creator)) == 0);
 732                 kmem_free(pids, spids * sizeof (uint32_t));
 733                 kmem_free(ctids, sctids * sizeof (uint32_t));
 734         }
 735 
 736         /*
 737          * if we are in a local zone and svc_fmri was inherited from
 738          * the global zone, we provide fake svc_fmri and svc_ctid
 739          */
 740         if (local_svc_zone_enter == 0 ||
 741             zone->zone_uniqid == GLOBAL_ZONEUNIQID) {
 742                 if (detail > CTD_COMMON) {
 743                         VERIFY(nvlist_add_int32(nvl, CTPS_SVC_CTID,
 744                             ctp->conp_svc_ctid) == 0);


 745                         VERIFY(nvlist_add_string(nvl, CTPS_SVC_FMRI,
 746                             refstr_value(ctp->conp_svc_fmri)) == 0);
 747                 }
 748         } else {
 749                 if (detail > CTD_COMMON) {
 750                         VERIFY(nvlist_add_int32(nvl, CTPS_SVC_CTID,
 751                             local_svc_zone_enter) == 0);


 752                         VERIFY(nvlist_add_string(nvl, CTPS_SVC_FMRI,
 753                             CT_PR_SVC_FMRI_ZONE_ENTER) == 0);
 754                 }
 755         }
 756 }
 757 
 758 /*ARGSUSED*/
 759 static int
 760 contract_process_newct(contract_t *ct)
 761 {
 762         return (0);
 763 }
 764 
 765 /* process contracts don't negotiate */
 766 static contops_t contract_process_ops = {
 767         contract_process_free,          /* contop_free */
 768         contract_process_abandon,       /* contop_abandon */
 769         contract_process_destroy,       /* contop_destroy */
 770         contract_process_status,        /* contop_status */
 771         contract_ack_inval,             /* contop_ack */