8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / devfsadm / fssnap_link.c
bloba1df4003727a8d0a501c97ce416335c0f9ef1217
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 (c) 2000-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <regex.h>
30 #include <devfsadm.h>
31 #include <stdio.h>
32 #include <strings.h>
33 #include <stdlib.h>
34 #include <limits.h>
35 #include <sys/fssnap_if.h>
38 static int fssnap(di_minor_t minor, di_node_t node);
40 static devfsadm_create_t fssnap_cbt[] = {
41 { "pseudo", "ddi_pseudo", SNAP_NAME,
42 TYPE_EXACT | DRV_EXACT, ILEVEL_0, fssnap,
46 DEVFSADM_CREATE_INIT_V0(fssnap_cbt);
49 * For the master device:
50 * /dev/fssnapctl -> /devices/pseudo/fssnap@0:ctl
51 * For each other device
52 * /dev/fssnap/1 -> /devices/pseudo/fssnap@0:1
53 * /dev/rfssnap/1 -> /devices/pseudo/fssnap@0:1,raw
55 static int
56 fssnap(di_minor_t minor, di_node_t node)
58 dev_t dev;
59 char mn[MAXNAMELEN + 1];
60 char blkname[MAXNAMELEN + 1];
61 char rawname[MAXNAMELEN + 1];
62 char path[PATH_MAX + 1];
64 (void) strcpy(mn, di_minor_name(minor));
66 if (strcmp(mn, "ctl") == 0) {
67 (void) devfsadm_mklink(SNAP_CTL_NAME, node, minor, 0);
68 } else {
69 dev = di_minor_devt(minor);
70 (void) snprintf(blkname, sizeof (blkname), "%d",
71 (int)minor(dev));
72 (void) snprintf(rawname, sizeof (rawname), "%d,raw",
73 (int)minor(dev));
75 if (strcmp(mn, blkname) == 0) {
76 (void) snprintf(path, sizeof (path), "%s/%s",
77 SNAP_BLOCK_NAME, blkname);
78 } else if (strcmp(mn, rawname) == 0) {
79 (void) snprintf(path, sizeof (path), "%s/%s",
80 SNAP_CHAR_NAME, blkname);
81 } else {
82 return (DEVFSADM_CONTINUE);
85 (void) devfsadm_mklink(path, node, minor, 0);
87 return (DEVFSADM_CONTINUE);