OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [LINUX_2_4_26_OR32/] [linux/] [linux-2.4/] [Documentation/] [mkdev_dyn.cciss] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#!/bin/sh
2
#
3
# Author: Francis Wiran 
4
#
5
# Script to create device nodes for SMART Array controllers, idea from
6
# mkdev.cciss found in Documentation. The argument syntax is different,
7
# hence, the name change.
8
#
9
# Usage:
10
#       mkdev_dyn.cciss [ctlr num] [major num] [num log vol] [num partitions]
11
#
12
# With no arguments, the script will check to see if there are any cciss
13
# nodes already created in the /dev directory. If so, then it will assume
14
# that the nodes for the first 8 controllers are already created by
15
# /etc/makedev.d, which is likely. If not, then the script will create
16
# them, using the major numbers reserved for cciss controllers (104 thru 111).
17
#
18
# After that, it will start creating nodes for the controllers which major
19
# numbers are dynamically allocated by the kernel. It will check
20
# /proc/devices for any cciss controllers with major numbers other than
21
# 104 thru 111 and creates the nodes.
22
#
23
# Note that it is a good idea to run rmdev_dyn.cciss script if you remove
24
# those controllers (the ones which major numbers were dynamically allocated)
25
# This will unclutter /dev, as well as preventing possible problems due to
26
# referenced devices and major numbers no longer available or taken by
27
# other non-cciss drivers.
28
#
29
# With no arguments, the script assumes 16 logical volumes per controller
30
# and 16 partitions per volume;
31
#
32
# Passing arguments:
33
# If you know that one of your controllers, say cciss8, has been dynamically
34
# assigned major number 254, and were planning on no more than 2 logical
35
# volumes, using a maximum of 4 partitions per volume, you could do:
36
#
37
# mkdev_dyn.cciss 8 254 2 4
38
#
39
# Of course, this has no real benefit over "mkdev_dyn.cciss 8 254" except
40
# that it doesn't create as many device nodes in /dev/cciss.
41
#
42
 
43
# Inputs
44
NR_CTLR=${1-8}
45
NR_MAJOR=${2-254}
46
NR_VOL=${3-16}
47
NR_PART=${4-16}
48
 
49
echo_usage()
50
{
51
        echo "Usage: mkdev_dyn.cciss [ctlr num] [maj] [volumes] [partitions]"
52
        echo "The script assumes that ctlr 0 thru 7 is statically created"
53
        echo "Therefore, if you want to pass arguments make sure that"
54
        echo "ctlr num is equal or greater than 8, and the major number"
55
        echo "is not one that's statically assigned for cciss controller."
56
        echo "Check the correct major number in /proc/devices"
57
 
58
        # Hmm... we don't support volumes and partitions greater than 16
59
        # either.
60
}
61
 
62
echo_create()
63
{
64
        echo "created /dev/cciss/c${1}* nodes using major number ${2}"
65
}
66
 
67
 
68
# Function: do_mknod()
69
#           Creates devices nodes under /dev/cciss
70
# Inputs: $1 - ctlr number
71
#         $2 - major number
72
#         $3 - number of devices on controller
73
#         $4 - number of partitions per device
74
do_mknod()
75
{
76
        D=0;
77
        while [ $D -lt $3 ]; do
78
                P=0;
79
                while [ $P -lt $4 ]; do
80
                        MIN=`expr $D \* 16 + $P`;
81
                        if [ $P -eq 0 ]; then
82
                                mknod /dev/cciss/c${1}d${D} b $2 $MIN
83
                        else
84
                                mknod /dev/cciss/c${1}d${D}p${P} b $2 $MIN
85
                        fi
86
                        P=`expr $P + 1`;
87
                done
88
                D=`expr $D + 1`;
89
        done
90
}
91
 
92
# Function: do_dyn
93
#           Search and create cciss nodes for the controllers which
94
#           major numbers are allocated dynamically by the kernel
95
#           instead of using kernel.org 's value of 104 to 111.
96
#
97
# Input: $1 - ctlr num - will create nodes /dev/cciss/c${1}
98
#        $2 - major num - the major number to assign to the nodes
99
#        $3 - volumes - max number of volumes per controller
100
#        $4 - partitions - max number of partitions per volume
101
#
102
# Note: Without input, this function will start creating nodes
103
#       for controller c8 and above, making assumption that
104
#       c0 thru c7 are already made, and the name c8 and above
105
#       are not already taken.
106
do_dyn()
107
{
108
        if [ $# -eq 0 ]; then
109
                C=0;
110
                for MAJ in `cat /proc/devices |\
111
                        grep cciss |\
112
                        awk '/cciss[0-9]$/ { sub("cciss", "cciss0") }; {print}' |\
113
                        sort -k 2,2 |\
114
                        awk '{print $1-i}'`;
115
                do
116
                        if [ `ls -l /dev/cciss/c* |\
117
                                awk '{print $5-i}' |\
118
                                uniq |\
119
                                grep $MAJ |\
120
                                wc -l` -gt 0 ]; then
121
                                :
122
                        else
123
                                do_mknod $C $MAJ $NR_VOL $NR_PART;
124
                                echo_create $C $MAJ;
125
                        fi
126
                        C=`expr $C + 1`;
127
                done
128
        else
129
                do_mknod $1 $2 $3 $4;
130
                echo_create $1 $2;
131
        fi
132
 
133
        exit
134
}
135
 
136
# Start here
137
 
138
# Check the input values
139
if [ $NR_CTLR -lt 8 ]; then
140
        echo_usage;
141
        exit
142
fi
143
 
144
if [ $NR_CTLR -ge 8 ]; then
145
        if [ \( $NR_MAJOR -ge 104 \) -a \( $NR_MAJOR -le 111 \) ]; then
146
                echo_usage;
147
                exit
148
        fi
149
fi
150
 
151
if [ ! -d /dev/cciss ]; then
152
        mkdir -p /dev/cciss
153
fi
154
 
155
# Assume that if c0d0p1 node already exist, then all nodes from c0d0p1
156
# to c7d15p15 have been created for us.
157
if [ ! -b /dev/cciss/c0d0p1 ]; then
158
        C=0;
159
        while [ $C -lt 8 ]; do
160
                MAJ=`expr $C + 104`;
161
                do_mknod $C $MAJ $NR_VOL $NR_PART;
162
                echo_create $C $MAJ;
163
                C=`expr $C + 1`;
164
        done
165
fi
166
 
167
if [ $# -gt 0 ]; then
168
        do_dyn $NR_CTLR $NR_MAJOR $NR_VOL $NR_PART;
169
else
170
        do_dyn;
171
fi

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.