[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Issues with cdrsin and USB devices on RHEL5



On Mon, Jul 14, 2008 at 9:30 PM, Thomas Schmitt <scdbackup@gmx.net> wrote:
>
> Hi,
>
>
> /proc is an interesting thing. But where is it documented ?
> On what feature in /proc can i rely ?
> /proc/scsi/sg/devices once gave me hints about the activities
> of my drives. Not any more. :(

Docs are often outdated about Linux /proc /sys stuff.

FYI, on RHEL5 /dev is managed by udev infrastructure; udev will
automatically create nodes for all devices under /dev, and in some
cases it will make symlinks to make device names more user-friendly.
For CD/DVD it will create cdrom, cd-writer, dvd, dvd-writer, symlinks
depending on device capabilities; for doing this it uses the following
script:

============ /lib/udev/check-cdrom.sh
#!/bin/bash
pos=0
n=0
sp="$1"
what="$2"
found=0
[ -e /proc/sys/dev/cdrom/info ] || exit 1
/bin/cat /proc/sys/dev/cdrom/info | {
    while read line; do
    if [ "$found" = "0" -a "${line/drive name:}"
        set ${line/drive name:}
        while [ $# -gt 0 ]; do
        pos=$[$pos+1]
        if [ "$1" == "$sp" ]; then
            found=1
            break
        fi
        shift
        done
        [ "$found" = "0" ] && exit 1
    elif [ "${line/$what:}" != "$line" ]; then
        set ${line##*$what:}
        while [ $# -gt 0 ]; do
        n=$[$n+1]
        if [ "$n" == "$pos" ]; then
            if [ "$1" = "1" ]; then
            exit 0
            fi
            break
        fi
        shift
        done
    fi
    done
    exit 1
}
============

On my system

$ /lib/udev/check-cdrom.sh hda DVD;echo $?
1
$ /lib/udev/check-cdrom.sh hda CD-R;echo $?
1
$ /lib/udev/check-cdrom.sh hdc CD-R;echo $?
0
$ /lib/udev/check-cdrom.sh hdc DVD;echo $?
0
$ /lib/udev/check-cdrom.sh hdc DVD-R;echo $?
0
$ /lib/udev/check-cdrom.sh sr0 CD-R;echo $?
0
$ /lib/udev/check-cdrom.sh sr0 DVD;echo $?
0
$ /lib/udev/check-cdrom.sh sr0 DVD-R;echo $?
0
$ /lib/udev/check-cdrom.sh sr1 DVD-R;echo $?
1

--
giulioo@pobox.com


Reply to: