File: devmap_mknod.sh

package info (click to toggle)
devmapper 2%3A1.01.00-4sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,044 kB
  • ctags: 2,336
  • sloc: ansic: 11,777; sh: 2,695; makefile: 291; perl: 16
file content (41 lines) | stat: -rwxr-xr-x 996 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /bin/sh

# Startup script to create the device-mapper control device 
# on non-devfs systems.
# Non-zero exit status indicates failure.

# These must correspond to the definitions in device-mapper.h and dm.h
DM_DIR="mapper"
DM_NAME="device-mapper"

set -e

DIR="/dev/$DM_DIR"
CONTROL="$DIR/control"

# Check for devfs, procfs
if test -e /dev/.devfsd ; then
	echo "devfs detected: devmap_mknod.sh script not required."
	exit
fi

if test ! -e /proc/devices ; then
	echo "procfs not found: please create $CONTROL manually."
	exit 1
fi

# Get major, minor, and mknod
MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)

if test -z "$MAJOR" || test -z "$MINOR" ; then
	echo "$DM_NAME kernel module not loaded: can't create $CONTROL."
	exit 1
fi

mkdir -p --mode=755 $DIR
test -e $CONTROL && rm -f $CONTROL

echo "Creating $CONTROL character device with major:$MAJOR minor:$MINOR."
mknod --mode=600 $CONTROL c $MAJOR $MINOR