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
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
35 #define DCAM_RE_STRING_LEN 64
37 #define DCAM_STR_LINK_RE "^dcam([0-9]+)$"
38 #define DCAM_CTL_LINK_RE "^dcamctl([0-9]+)$"
40 static int dcam1394_process(di_minor_t minor
, di_node_t node
);
42 static devfsadm_create_t dcam1394_cbt
[] = {
53 static char *debug_mid
= "dcam1394_mid";
55 DEVFSADM_CREATE_INIT_V0(dcam1394_cbt
);
58 static devfsadm_remove_t dcam1394_remove_cbt
[] = {
62 RM_PRE
| RM_HOT
| RM_ALWAYS
,
69 RM_PRE
| RM_HOT
| RM_ALWAYS
,
75 DEVFSADM_REMOVE_INIT_V0(dcam1394_remove_cbt
);
80 devfsadm_print(debug_mid
, "dcam1394_link: minor_init\n");
81 return (DEVFSADM_SUCCESS
);
87 devfsadm_print(debug_mid
, "dcam1394_link: minor_fini\n");
88 return (DEVFSADM_SUCCESS
);
93 * This function is called for every dcam1394 minor node.
94 * Calls enumerate to assign a logical dcam1394 id, and then
95 * devfsadm_mklink to make the link.
98 dcam1394_process(di_minor_t minor
, di_node_t node
)
100 char m_name
[PATH_MAX
], restring0
[DCAM_RE_STRING_LEN
];
101 char l_path
[PATH_MAX
], p_path
[PATH_MAX
], *buf
, *devfspath
;
102 devfsadm_enumerate_t re
[1];
104 (void) strcpy(m_name
, di_minor_name(minor
));
106 if (strcmp(di_driver_name(node
), "dcam1394") != 0) {
107 return (DEVFSADM_CONTINUE
);
110 if (strncmp(m_name
, "dcamctl", 7) == 0) {
111 (void) snprintf(restring0
, DCAM_RE_STRING_LEN
,
113 } else if (strncmp(m_name
, "dcam", 4) == 0) {
114 (void) snprintf(restring0
, DCAM_RE_STRING_LEN
,
117 return (DEVFSADM_CONTINUE
);
120 re
[0].re
= restring0
;
122 re
[0].flags
= MATCH_ALL
;
124 devfsadm_print(debug_mid
,
125 "dcam1394_process: path %s\n", di_devfs_path(node
));
127 (void) strcpy(p_path
, devfspath
= di_devfs_path(node
));
128 (void) strcat(p_path
, ":");
129 (void) strcat(p_path
, di_minor_name(minor
));
130 di_devfs_path_free(devfspath
);
133 * Build the physical path from the components, omitting
134 * minor name field. Find the logical dcam1394 id, and
137 if (devfsadm_enumerate_int(p_path
, 0, &buf
, re
, 1)) {
138 devfsadm_print(debug_mid
,
139 "dcam1394_process: exit/continue\n");
140 return (DEVFSADM_CONTINUE
);
143 devfsadm_print(debug_mid
, "dcam1394_process: p_path=%s buf=%s\n",
146 if (strncmp(di_minor_name(minor
), "dcamctl", 7) == 0)
147 (void) snprintf(l_path
, PATH_MAX
, "dcamctl%s", buf
);
149 (void) snprintf(l_path
, PATH_MAX
, "dcam%s", buf
);
151 (void) devfsadm_mklink(l_path
, node
, minor
, 0);
155 return (DEVFSADM_CONTINUE
);