dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / devfsadm / ieee1394_link.c
blobf9495436ef190097935918c2af355cb8cf80b822
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2003 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 <stdio.h>
31 #include <stdlib.h>
32 #include <limits.h>
33 #include <string.h>
35 static int ieee1394_process(di_minor_t minor, di_node_t node);
37 static devfsadm_create_t ieee1394_cbt[] = {
38 { "ieee1394", "ddi_ctl:devctl", "hci1394",
39 TYPE_EXACT | DRV_EXACT, ILEVEL_0, ieee1394_process
43 static char *debug_mid = "ieee1394_mid";
45 DEVFSADM_CREATE_INIT_V0(ieee1394_cbt);
47 #define IEEE1394_LINK_RE "^1394/hba[0-9]+$"
49 static devfsadm_remove_t ieee1394_remove_cbt[] = {
50 { "ieee1394", IEEE1394_LINK_RE, RM_HOT | RM_POST,
51 ILEVEL_0, devfsadm_rm_all
55 DEVFSADM_REMOVE_INIT_V0(ieee1394_remove_cbt);
57 int
58 minor_init(void)
60 devfsadm_print(debug_mid, "ieee1394_link: minor_init\n");
61 return (DEVFSADM_SUCCESS);
64 int
65 minor_fini(void)
67 devfsadm_print(debug_mid, "ieee1394_link: minor_fini\n");
68 return (DEVFSADM_SUCCESS);
72 * This function is called for every ieee1394 minor node.
73 * Calls enumerate to assign a logical ieee1394 id, and then
74 * devfsadm_mklink to make the link.
76 static int
77 ieee1394_process(di_minor_t minor, di_node_t node)
79 char *buf, *devfspath;
80 char l_path[PATH_MAX], p_path[PATH_MAX];
81 devfsadm_enumerate_t re[] = {"^1394/hba([0-9]+)$", 1, MATCH_ALL};
83 devfspath = di_devfs_path(node);
85 devfsadm_print(debug_mid,
86 "ieee1394_process: path %s\n", devfspath);
88 (void) snprintf(p_path, sizeof (p_path), "%s:%s",
89 devfspath, di_minor_name(minor));
90 di_devfs_path_free(devfspath);
93 * Build the physical path from the components. Find the logical
94 * ieee1394 HBA id, and stuff it in buf
96 if (devfsadm_enumerate_int(p_path, 0, &buf, re, 1)) {
97 devfsadm_print(debug_mid, "ieee1394_process: exit/continue\n");
98 return (DEVFSADM_CONTINUE);
100 devfsadm_print(debug_mid, "ieee1394_process: p_path=%s buf=%s\n",
101 p_path, buf);
103 (void) snprintf(l_path, sizeof (l_path), "1394/hba%s", buf);
105 free(buf);
107 devfsadm_print(debug_mid, "mklink %s %s\n", l_path, p_path);
109 (void) devfsadm_mklink(l_path, node, minor, 0);
111 return (DEVFSADM_CONTINUE);