summaryrefslogtreecommitdiff
blob: 81eb917b355c1c5b0eefa184b16a5aa62e549821 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2
# $Id$

depend() {
	need localmount modules
}

checkconfig() {
	if ! [ -e /dev/pktcdvd/control ]; then
		eerror "Could not find packet-writing control device at /dev/pktcdvd/control"
		eerror "Please ensure that your kernel includes packet writing support,"
		eerror "and if modular, ensure that the module is loaded."
		return 1
	fi
}

get_rw_devices() {
	devices_raw=$(sed -re '/^drive name:/I!d; s/.*:\s+//' /proc/sys/dev/cdrom/info)
	count=0
	for i in $devices_raw; do
		eval "devices_$count=\"\$i\""
		count=$(( $count + 1 ))
	done
	devs=""

	cdrw_caps=$(sed -re '/^Can write CD-RW:/I!d; s/.*:\s+//' /proc/sys/dev/cdrom/info)

	count=0
	for i in $cdrw_caps; do
		[ "$i" -eq 1 ] && eval "devs=\"\$devs \$devices_$count\""
		count=$(( $count + 1 ))
	done

	echo ${devs}
}

start() {
	checkconfig || return 1

	for i in $(get_rw_devices)
	do
		devnode="/dev/${i}"
		[ -e "${devnode}" ] || continue

		/usr/bin/pktsetup "${i}" "${devnode}" > /dev/null
		[ -e "/dev/pktcdvd/${i}" ] || continue
		chmod 660 "/dev/pktcdvd/${i}"
		chgrp cdrw "/dev/pktcdvd/${i}"
	done
}

stop() {
	checkconfig || return 1
	
	for i in $(get_rw_devices)
	do
		/usr/bin/pktsetup -d "${i}" > /dev/null
	done
}