libstand: gzipfs unused variable
[unleashed.git] / usr / src / cmd / devfsadm / smp_link.c
blob578f1b923f6887feb63a838ac85b7f729dbf2e96
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <devfsadm.h>
30 #include <strings.h>
31 #include <stdlib.h>
32 #include <limits.h>
33 #include <bsm/devalloc.h>
35 #define SMP_LINK_RE "^smp/expd[0-9]+$"
36 #define SMP_CLASS "sas"
37 #define SMP_DRV_NAME "smp"
39 static int smp_callback(di_minor_t minor, di_node_t node);
41 static devfsadm_create_t smp_create_cbt[] = {
42 { SMP_CLASS, "ddi_sas_smp", SMP_DRV_NAME,
43 TYPE_EXACT | DRV_EXACT, ILEVEL_0, smp_callback
47 DEVFSADM_CREATE_INIT_V0(smp_create_cbt);
50 * HOT auto cleanup of smp links not desired.
52 static devfsadm_remove_t smp_remove_cbt[] = {
53 { SMP_CLASS, SMP_LINK_RE, RM_PRE,
54 ILEVEL_0, devfsadm_rm_all
58 DEVFSADM_REMOVE_INIT_V0(smp_remove_cbt);
61 * Create link for expander devices as form
62 * dev/smp/expd0 -> ../../devices/pci@0,0/.../smp@w5001636000005aff:smp
64 static int
65 smp_callback(di_minor_t minor, di_node_t node)
67 char l_path[PATH_MAX + 1];
68 char *buf;
69 char *mn;
70 char *devfspath;
71 devfsadm_enumerate_t rules[1] = {"smp/expd([0-9]+)", 1, MATCH_ADDR};
73 mn = di_minor_name(minor);
75 devfspath = di_devfs_path(node);
77 (void) strcpy(l_path, devfspath);
78 (void) strcat(l_path, ":");
79 (void) strcat(l_path, mn);
81 di_devfs_path_free(devfspath);
83 if (devfsadm_enumerate_int(l_path, 0, &buf, rules, 1)) {
84 return (DEVFSADM_CONTINUE);
87 (void) strcpy(l_path, "smp/expd");
88 (void) strcat(l_path, buf);
89 free(buf);
91 (void) devfsadm_mklink(l_path, node, minor, 0);
93 return (DEVFSADM_CONTINUE);