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 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2016 Joyent, Inc.
  26  */
  27 
  28 #include <devfsadm.h>
  29 #include <strings.h>
  30 #include <stdio.h>
  31 #include <sys/lx_ptm.h>
  32 #include <sys/lx_autofs.h>
  33 
  34 static int lx_ptm(di_minor_t minor, di_node_t node);
  35 static int lx_autofs(di_minor_t minor, di_node_t node);
  36 static int lx_systrace(di_minor_t minor, di_node_t node);
  37 
  38 static devfsadm_create_t lx_create_cbt[] = {
  39         { "pseudo", "ddi_pseudo", LX_PTM_DRV,
  40             TYPE_EXACT | DRV_EXACT, ILEVEL_0, lx_ptm },
  41         { "pseudo", "ddi_pseudo", LX_AUTOFS_NAME,
  42             TYPE_EXACT | DRV_EXACT, ILEVEL_0, lx_autofs },
  43         { "pseudo", "ddi_pseudo", "lx_systrace",
  44             TYPE_EXACT | DRV_EXACT, ILEVEL_0, lx_systrace },
  45 };
  46 
  47 DEVFSADM_CREATE_INIT_V0(lx_create_cbt);
  48 
  49 static int
  50 lx_ptm(di_minor_t minor, di_node_t node)
  51 {
  52         char *mname = di_minor_name(minor);
  53 
  54         if (strcmp(LX_PTM_MINOR_NODE, mname) == 0)
  55                 (void) devfsadm_mklink("brand/lx/ptmx", node, minor, 0);
  56 
  57         return (DEVFSADM_CONTINUE);
  58 }
  59 
  60 static int
  61 lx_autofs(di_minor_t minor, di_node_t node)
  62 {
  63         char *mname = di_minor_name(minor);
  64 
  65         if (strcmp(LX_AUTOFS_MINORNAME, mname) == 0)
  66                 (void) devfsadm_mklink("brand/lx/autofs", node, minor, 0);
  67 
  68         return (DEVFSADM_CONTINUE);
  69 }
  70 
  71 static int
  72 lx_systrace(di_minor_t minor, di_node_t node)
  73 {
  74         char *mname = di_minor_name(minor);
  75         char path[MAXPATHLEN];
  76 
  77         (void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname);
  78         (void) devfsadm_mklink(path, node, minor, 0);
  79 
  80         return (DEVFSADM_CONTINUE);
  81 }