summaryrefslogtreecommitdiff
path: root/usr/src/cmd/devfsadm
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/devfsadm')
-rw-r--r--usr/src/cmd/devfsadm/Makefile.com7
-rw-r--r--usr/src/cmd/devfsadm/devfsadm.c21
-rw-r--r--usr/src/cmd/devfsadm/devlink.tab.sh5
-rw-r--r--usr/src/cmd/devfsadm/i386/Makefile3
-rw-r--r--usr/src/cmd/devfsadm/i386/lx_link_i386.c81
-rw-r--r--usr/src/cmd/devfsadm/i386/misc_link_i386.c101
-rw-r--r--usr/src/cmd/devfsadm/misc_link.c43
-rw-r--r--usr/src/cmd/devfsadm/sensor_link.c79
8 files changed, 275 insertions, 65 deletions
diff --git a/usr/src/cmd/devfsadm/Makefile.com b/usr/src/cmd/devfsadm/Makefile.com
index b446b148ff..cec58108c8 100644
--- a/usr/src/cmd/devfsadm/Makefile.com
+++ b/usr/src/cmd/devfsadm/Makefile.com
@@ -21,7 +21,7 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2019, Joyent, Inc.
# This target builds both a command (daemon) and various shared objects. This
# isn't a typical target, and the inclusion of both library and command
@@ -71,7 +71,8 @@ LINK_OBJS_CMN = \
dtrace_link.o \
vscan_link.o \
zfs_link.o \
- zut_link.o
+ zut_link.o \
+ sensor_link.o
LINK_OBJS = $(LINK_OBJS_CMN) \
$(LINK_OBJS_$(MACH))
@@ -164,7 +165,7 @@ install: all \
clean:
- $(RM) $(OBJS)
+ $(RM) $(OBJS)
lint: $(DEVFSADM_MOD).ln $(LINT_MODULES)
diff --git a/usr/src/cmd/devfsadm/devfsadm.c b/usr/src/cmd/devfsadm/devfsadm.c
index f81d5b5d67..52f4f4c0da 100644
--- a/usr/src/cmd/devfsadm/devfsadm.c
+++ b/usr/src/cmd/devfsadm/devfsadm.c
@@ -23,6 +23,7 @@
* Copyright 2016 Toomas Soome <tsoome@me.com>
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2019, Joyent, Inc.
*/
/*
@@ -2073,6 +2074,16 @@ class_ok(char *class)
return (DEVFSADM_SUCCESS);
}
+ /*
+ * Some create tabs operate on multiple classes of devices because the
+ * kernel doesn't have a good way for a driver to indicate that a
+ * particular minor's class is different from that of the dev_info_t
+ * it belongs to. As such, we'll always fail to match those here.
+ */
+ if (class == NULL) {
+ return (DEVFSADM_FAILURE);
+ }
+
for (i = 0; i < num_classes; i++) {
if (strcmp(class, classes[i]) == 0) {
return (DEVFSADM_SUCCESS);
@@ -3717,10 +3728,10 @@ do_inst_sync(char *filename, char *instfilename)
* safely, the database is flushed to a temporary file, then moved into place.
*
* The following files are used during this process:
- * /etc/path_to_inst: The path_to_inst file
- * /etc/path_to_inst.<pid>: Contains data flushed from the kernel
- * /etc/path_to_inst.old: The backup file
- * /etc/path_to_inst.old.<pid>: Temp file for creating backup
+ * /etc/path_to_inst: The path_to_inst file
+ * /etc/path_to_inst.<pid>: Contains data flushed from the kernel
+ * /etc/path_to_inst.old: The backup file
+ * /etc/path_to_inst.old.<pid>: Temp file for creating backup
*
*/
static void
@@ -7803,7 +7814,7 @@ add_verbose_id(char *mid)
* returns DEVFSADM_TRUE if contents is a minor node in /devices.
* If mn_root is not NULL, mn_root is set to:
* if contents is a /dev node, mn_root = contents
- * OR
+ * OR
* if contents is a /devices node, mn_root set to the '/'
* following /devices.
*/
diff --git a/usr/src/cmd/devfsadm/devlink.tab.sh b/usr/src/cmd/devfsadm/devlink.tab.sh
index 6724fcb573..0267efeb9f 100644
--- a/usr/src/cmd/devfsadm/devlink.tab.sh
+++ b/usr/src/cmd/devfsadm/devlink.tab.sh
@@ -22,8 +22,7 @@
#
# Copyright (c) 1998, 2000 by Sun Microsystems, Inc.
# All rights reserved.
-#
-#ident "%Z%%M% %I% %E% SMI"
+# Copyright (c) 2012 Joyent, Inc. All rights reserved.
#
# This is the script that generates the devlink.tab file. It is
# architecture-aware, and dumps different stuff for x86 and sparc.
@@ -34,8 +33,6 @@
#
cat <<EOM
-#ident "%Z%%M% %I% %E% SMI"
-#
# Copyright (c) 1998 by Sun Microsystems, Inc.
#
#
diff --git a/usr/src/cmd/devfsadm/i386/Makefile b/usr/src/cmd/devfsadm/i386/Makefile
index 179db79979..8bd5a45401 100644
--- a/usr/src/cmd/devfsadm/i386/Makefile
+++ b/usr/src/cmd/devfsadm/i386/Makefile
@@ -25,8 +25,11 @@
LINK_OBJS_i386 = \
drm_link_i386.o \
misc_link_i386.o \
+ lx_link_i386.o \
xen_link.o
+lx_link_i386.o lx_link_i386.po lx_link_i386.ln := CPPFLAGS += -I$(UTSBASE)/common/brand/lx
+
xen_link.o xen_link.ln xen_link.po := CPPFLAGS += -I$(UTSBASE)/i86xpv
include ../Makefile.com
diff --git a/usr/src/cmd/devfsadm/i386/lx_link_i386.c b/usr/src/cmd/devfsadm/i386/lx_link_i386.c
new file mode 100644
index 0000000000..b99a8361a0
--- /dev/null
+++ b/usr/src/cmd/devfsadm/i386/lx_link_i386.c
@@ -0,0 +1,81 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ * Copyright 2016 Joyent, Inc.
+ */
+
+#include <devfsadm.h>
+#include <strings.h>
+#include <stdio.h>
+#include <sys/lx_ptm.h>
+#include <sys/lx_autofs.h>
+
+static int lx_ptm(di_minor_t minor, di_node_t node);
+static int lx_autofs(di_minor_t minor, di_node_t node);
+static int lx_systrace(di_minor_t minor, di_node_t node);
+
+static devfsadm_create_t lx_create_cbt[] = {
+ { "pseudo", "ddi_pseudo", LX_PTM_DRV,
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, lx_ptm },
+ { "pseudo", "ddi_pseudo", LX_AUTOFS_NAME,
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, lx_autofs },
+ { "pseudo", "ddi_pseudo", "lx_systrace",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, lx_systrace },
+};
+
+DEVFSADM_CREATE_INIT_V0(lx_create_cbt);
+
+static int
+lx_ptm(di_minor_t minor, di_node_t node)
+{
+ char *mname = di_minor_name(minor);
+
+ if (strcmp(LX_PTM_MINOR_NODE, mname) == 0)
+ (void) devfsadm_mklink("brand/lx/ptmx", node, minor, 0);
+
+ return (DEVFSADM_CONTINUE);
+}
+
+static int
+lx_autofs(di_minor_t minor, di_node_t node)
+{
+ char *mname = di_minor_name(minor);
+
+ if (strcmp(LX_AUTOFS_MINORNAME, mname) == 0)
+ (void) devfsadm_mklink("brand/lx/autofs", node, minor, 0);
+
+ return (DEVFSADM_CONTINUE);
+}
+
+static int
+lx_systrace(di_minor_t minor, di_node_t node)
+{
+ char *mname = di_minor_name(minor);
+ char path[MAXPATHLEN];
+
+ (void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname);
+ (void) devfsadm_mklink(path, node, minor, 0);
+
+ return (DEVFSADM_CONTINUE);
+}
diff --git a/usr/src/cmd/devfsadm/i386/misc_link_i386.c b/usr/src/cmd/devfsadm/i386/misc_link_i386.c
index 67d06ee101..6b21eabe3b 100644
--- a/usr/src/cmd/devfsadm/i386/misc_link_i386.c
+++ b/usr/src/cmd/devfsadm/i386/misc_link_i386.c
@@ -21,7 +21,7 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- * Copyright 2012 Joyent, Inc. All rights reserved.
+ * Copyright 2018 Joyent, Inc. All rights reserved.
*/
#include <regex.h>
@@ -36,6 +36,7 @@
extern int system_labeled;
+static int ln_minor_name(di_minor_t minor, di_node_t node);
static int lp(di_minor_t minor, di_node_t node);
static int serial_dialout(di_minor_t minor, di_node_t node);
static int serial(di_minor_t minor, di_node_t node);
@@ -43,12 +44,9 @@ static int diskette(di_minor_t minor, di_node_t node);
static int vt00(di_minor_t minor, di_node_t node);
static int kdmouse(di_minor_t minor, di_node_t node);
static int ipmi(di_minor_t minor, di_node_t node);
-static int smbios(di_minor_t minor, di_node_t node);
static int mc_node(di_minor_t minor, di_node_t node);
-static int xsvc(di_minor_t minor, di_node_t node);
-static int srn(di_minor_t minor, di_node_t node);
-static int ucode(di_minor_t minor, di_node_t node);
-
+static int vmmctl(di_minor_t minor, di_node_t node);
+static int ppt(di_minor_t minor, di_node_t node);
static devfsadm_create_t misc_cbt[] = {
{ "vt00", "ddi_display", NULL,
@@ -61,7 +59,7 @@ static devfsadm_create_t misc_cbt[] = {
TYPE_EXACT | DRV_EXACT, ILEVEL_0, ipmi,
},
{ "pseudo", "ddi_pseudo", "smbios",
- TYPE_EXACT | DRV_EXACT, ILEVEL_1, smbios,
+ TYPE_EXACT | DRV_EXACT, ILEVEL_1, ln_minor_name,
},
/* floppies share the same class, but not link regex, as hard disks */
{ "disk", "ddi_block:diskette", NULL,
@@ -76,18 +74,27 @@ static devfsadm_create_t misc_cbt[] = {
{ "serial", "ddi_serial:dialout,mb", NULL,
TYPE_EXACT, ILEVEL_1, serial_dialout
},
- { "pseudo", "ddi_pseudo", NULL,
- TYPE_EXACT, ILEVEL_0, xsvc
+ { "pseudo", "ddi_pseudo", "xsvc",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
},
- { "pseudo", "ddi_pseudo", NULL,
- TYPE_EXACT, ILEVEL_0, srn
+ { "pseudo", "ddi_pseudo", "srn",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
},
{ "memory-controller", "ddi_mem_ctrl", NULL,
TYPE_EXACT, ILEVEL_0, mc_node
},
{ "pseudo", "ddi_pseudo", "ucode",
- TYPE_EXACT | DRV_EXACT, ILEVEL_0, ucode,
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
+ },
+ { "pseudo", "ddi_pseudo", "viona",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
+ },
+ { "pseudo", "ddi_pseudo", "vmm",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, vmmctl,
},
+ { "pseudo", "ddi_pseudo", "ppt",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, ppt,
+ }
};
DEVFSADM_CREATE_INIT_V0(misc_cbt);
@@ -113,12 +120,32 @@ static devfsadm_remove_t misc_remove_cbt[] = {
},
{ "serial", "^tty[a-z]$", RM_ALWAYS | RM_PRE,
ILEVEL_1, devfsadm_rm_all
+ },
+ { "pseudo", "^viona$", RM_ALWAYS | RM_PRE | RM_HOT,
+ ILEVEL_0, devfsadm_rm_all
+ },
+ { "pseudo", "^vmmctl$", RM_ALWAYS | RM_PRE | RM_HOT,
+ ILEVEL_0, devfsadm_rm_all
+ },
+ { "pseudo", "^ppt$", RM_ALWAYS | RM_PRE | RM_HOT,
+ ILEVEL_0, devfsadm_rm_all
}
};
DEVFSADM_REMOVE_INIT_V0(misc_remove_cbt);
/*
+ * Any /dev/foo named named after the minor name such as
+ * /devices/.../driver@0:foo
+ */
+static int
+ln_minor_name(di_minor_t minor, di_node_t node)
+{
+ (void) devfsadm_mklink(di_minor_name(minor), node, minor, 0);
+ return (DEVFSADM_CONTINUE);
+}
+
+/*
* Handles minor node type "ddi_display", in addition to generic processing
* done by display().
*
@@ -305,13 +332,6 @@ ipmi(di_minor_t minor, di_node_t node)
return (DEVFSADM_CONTINUE);
}
-static int
-smbios(di_minor_t minor, di_node_t node)
-{
- (void) devfsadm_mklink("smbios", node, minor, 0);
- return (DEVFSADM_CONTINUE);
-}
-
/*
* /dev/mc/mc<chipid> -> /devices/.../pci1022,1102@<chipid+24>,2:mc-amd
*/
@@ -347,49 +367,24 @@ mc_node(di_minor_t minor, di_node_t node)
}
/*
- * Creates \M0 devlink for xsvc node
+ * /dev/vmmctl -> /devices/pseudo/vmm@0:ctl
*/
static int
-xsvc(di_minor_t minor, di_node_t node)
+vmmctl(di_minor_t minor, di_node_t node)
{
- char *mn;
-
- if (strcmp(di_node_name(node), "xsvc") != 0)
- return (DEVFSADM_CONTINUE);
-
- mn = di_minor_name(minor);
- if (mn == NULL)
- return (DEVFSADM_CONTINUE);
-
- (void) devfsadm_mklink(mn, node, minor, 0);
+ if (strcmp(di_minor_name(minor), "ctl") == 0)
+ (void) devfsadm_mklink("vmmctl", node, minor, 0);
return (DEVFSADM_CONTINUE);
}
-/*
- * Creates \M0 devlink for srn device
- */
static int
-srn(di_minor_t minor, di_node_t node)
+ppt(di_minor_t minor, di_node_t node)
{
- char *mn;
-
- if (strcmp(di_node_name(node), "srn") != 0)
- return (DEVFSADM_CONTINUE);
-
- mn = di_minor_name(minor);
- if (mn == NULL)
- return (DEVFSADM_CONTINUE);
+ char linkpath[PATH_MAX];
- (void) devfsadm_mklink(mn, node, minor, 0);
- return (DEVFSADM_CONTINUE);
-}
+ (void) snprintf(linkpath, sizeof (linkpath), "ppt%d",
+ di_instance(node));
-/*
- * /dev/ucode -> /devices/pseudo/ucode@0:ucode
- */
-static int
-ucode(di_minor_t minor, di_node_t node)
-{
- (void) devfsadm_mklink("ucode", node, minor, 0);
+ (void) devfsadm_mklink(linkpath, node, minor, 0);
return (DEVFSADM_CONTINUE);
}
diff --git a/usr/src/cmd/devfsadm/misc_link.c b/usr/src/cmd/devfsadm/misc_link.c
index 5f241df296..55aff1e4f7 100644
--- a/usr/src/cmd/devfsadm/misc_link.c
+++ b/usr/src/cmd/devfsadm/misc_link.c
@@ -32,6 +32,7 @@
#include <limits.h>
#include <sys/zone.h>
#include <sys/zcons.h>
+#include <sys/zfd.h>
#include <sys/cpuid_drv.h>
static int display(di_minor_t minor, di_node_t node);
@@ -53,6 +54,7 @@ static int av_create(di_minor_t minor, di_node_t node);
static int tsalarm_create(di_minor_t minor, di_node_t node);
static int ntwdt_create(di_minor_t minor, di_node_t node);
static int zcons_create(di_minor_t minor, di_node_t node);
+static int zfd_create(di_minor_t minor, di_node_t node);
static int cpuid(di_minor_t minor, di_node_t node);
static int glvc(di_minor_t minor, di_node_t node);
static int ses_callback(di_minor_t minor, di_node_t node);
@@ -114,6 +116,9 @@ static devfsadm_create_t misc_cbt[] = {
"(^nca$)|(^rds$)|(^sdp$)|(^ipnet$)|(^dlpistub$)|(^bpf$)",
TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name
},
+ { "pseudo", "ddi_pseudo", "inotify",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
+ },
{ "pseudo", "ddi_pseudo", "ipd",
TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
},
@@ -180,6 +185,9 @@ static devfsadm_create_t misc_cbt[] = {
{ "pseudo", "ddi_pseudo", "zcons",
TYPE_EXACT | DRV_EXACT, ILEVEL_0, zcons_create,
},
+ { "pseudo", "ddi_pseudo", "zfd",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, zfd_create,
+ },
{ "pseudo", "ddi_pseudo", CPUID_DRIVER_NAME,
TYPE_EXACT | DRV_EXACT, ILEVEL_0, cpuid,
},
@@ -204,6 +212,9 @@ static devfsadm_create_t misc_cbt[] = {
{ "pseudo", "ddi_pseudo", "tpm",
TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
},
+ { "pseudo", "ddi_pseudo", "overlay",
+ TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
+ }
};
DEVFSADM_CREATE_INIT_V0(misc_cbt);
@@ -228,6 +239,9 @@ static devfsadm_remove_t misc_remove_cbt[] = {
ZCONS_SLAVE_NAME ")$",
RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
},
+ { "pseudo", "^zfd/" ZONENAME_REGEXP "/(master|slave)/[0-9]+$",
+ RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
+ },
{ "pseudo", "^" CPUID_SELF_NAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
ILEVEL_0, devfsadm_rm_all
},
@@ -675,6 +689,35 @@ zcons_create(di_minor_t minor, di_node_t node)
return (DEVFSADM_CONTINUE);
}
+static int
+zfd_create(di_minor_t minor, di_node_t node)
+{
+ char *minor_str;
+ char *zonename;
+ int *id;
+ char path[MAXPATHLEN];
+
+ minor_str = di_minor_name(minor);
+
+ if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, "zfd_zname",
+ &zonename) == -1)
+ return (DEVFSADM_CONTINUE);
+
+ if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "zfd_id", &id) == -1)
+ return (DEVFSADM_CONTINUE);
+
+ if (strncmp(minor_str, "slave", 5) == 0) {
+ (void) snprintf(path, sizeof (path), "zfd/%s/slave/%d",
+ zonename, id[0]);
+ } else {
+ (void) snprintf(path, sizeof (path), "zfd/%s/master/%d",
+ zonename, id[0]);
+ }
+ (void) devfsadm_mklink(path, node, minor, 0);
+
+ return (DEVFSADM_CONTINUE);
+}
+
/*
* /dev/cpu/self/cpuid -> /devices/pseudo/cpuid@0:self
*/
diff --git a/usr/src/cmd/devfsadm/sensor_link.c b/usr/src/cmd/devfsadm/sensor_link.c
new file mode 100644
index 0000000000..7a2b48af75
--- /dev/null
+++ b/usr/src/cmd/devfsadm/sensor_link.c
@@ -0,0 +1,79 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2019, Joyent, Inc.
+ */
+
+/*
+ * Create /devices links for various sensors. The sensor series of node types
+ * all begin with ddi_sensor. After which, there is a series of : delineated
+ * paths in the node type. Those represent the directory under /dev/sensors that
+ * the nodes should ultimately be created.
+ *
+ * For example, ddi_sensor:temperature:cpu would cause us to place the named
+ * minor under /dev/sensors/temperature/cpu/. Currently it is up to drivers to
+ * not conflict in names or if there is a fear of conflicting, make sure their
+ * minor is unique.
+ */
+
+#include <devfsadm.h>
+#include <string.h>
+
+#define SENSORS_BASE "sensors"
+
+static int
+sensor_link(di_minor_t minor, di_node_t node)
+{
+ const char *t, *minor_name, *dir_path = NULL;
+ char *type, *c;
+ char buf[PATH_MAX];
+ size_t len;
+
+ if ((t = di_minor_nodetype(minor)) == NULL) {
+ return (DEVFSADM_CONTINUE);
+ }
+
+ if ((minor_name = di_minor_name(minor)) == NULL) {
+ return (DEVFSADM_CONTINUE);
+ }
+
+ if ((type = strdup(t)) == NULL) {
+ return (DEVFSADM_TERMINATE);
+ }
+
+ while ((c = strchr(type, ':')) != NULL) {
+ if (dir_path == NULL) {
+ dir_path = c + 1;
+ }
+ *c = '/';
+ }
+
+ if (dir_path == NULL || *dir_path == '\0') {
+ len = snprintf(buf, sizeof (buf), "%s/%s", SENSORS_BASE,
+ minor_name);
+ } else {
+ len = snprintf(buf, sizeof (buf), "%s/%s/%s", SENSORS_BASE,
+ dir_path, minor_name);
+ }
+
+ if (len < sizeof (buf)) {
+ (void) devfsadm_mklink(buf, node, minor, 0);
+ }
+
+ free(type);
+ return (DEVFSADM_CONTINUE);
+}
+
+static devfsadm_create_t sensor_create_cbt[] = {
+ { NULL, "ddi_sensor", NULL, TYPE_PARTIAL, ILEVEL_0, sensor_link }
+};
+DEVFSADM_CREATE_INIT_V0(sensor_create_cbt);