LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 06-22-2007, 12:19 PM   #1
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Rep: Reputation: 35
Making udev create a /dev/floppy symlink


Hello,

I'm still quite dependent of the floppy drive in Dosemu, and with udev + hal, the floppy in Linux randomly appears as /dev/sdb1, /dev/sda1 or /dev/sdb2 etc..

While this is not a problem in Linux or KDE with HAL, it's a huge problem for dosemu, which needs a fixed location for the floppy drive.

I've done my share of udev rule programming, but the calling of the shell script floppy-extra-devs has me a bit confused.

What I'd like is to have a SYMLINK+=/dev/floppy which always points to the floppy device regardless of sdb1, sda1 or whatever regardless of which name it gets.

Preferably added as a local rule - type /etc/udev/rules.d/99-local.rules

Anyone?
 
Old 06-24-2007, 10:14 AM   #2
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 14
Posts: 530

Rep: Reputation: 30
I guess your floppy is a USB one.. so take care using a udev rule not affecting possible usage of other usb devices. So a rule like

KERNEL=="sd[a-z][0-9]*", NAME="%k", SYSTEM=={whatever_specific_of_the_device}, SYMLINK+="floppy", GROUP="floppy", OPTIONS+="last_rule"

should work.
The rule
OPTIONS+="last_rule"
will avoid possible overriding of the rule as it stops further reading for the device.
Also consider not naming your rule 99-udev.rules as they are parsed alfabetically in the rules.d directory. I'd use 01-udev.rules instead
Hope this helps
Ciao
 
Old 06-24-2007, 10:35 AM   #3
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Original Poster
Rep: Reputation: 35
Hi, and thanks much for answering!

The reason I called it 99-local was precisely to make sure it ran last, not overriding any of the other settings, as the default Slackware udev rules among others run the shell script floppy-extra-devs.sh which I unfortunately am unable to follow what exactly it does..

And for that reason I have to shamefully admit that I am also not fully capable of comprehending what to put in the SYSTEM=={whatever_specific_of_the_device} part either...

Any insight greatly appreciated :-)

-y1
 
Old 06-24-2007, 11:44 AM   #4
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 14
Posts: 530

Rep: Reputation: 30
I wouldn't be concerned about possible slack default rules overriding, as they are applied anyway. Custom rules must be read first if you want they to be applied and they should be purposely designed to be device-specific.
The parameter
OPTIONS+="last_rule"
will stop udev searching for further matches only regarding the specific device for which the custom rule is designed for. Other rules for any other device will be applied "untouched".
The command
udevinfo -a -p `udevinfo -q path -n /dev/xxx` (backtics)
will output a long list of parameters you can use as "matching" in your custom rules.
Here is my usb pendrive output (very long...)

elio@darkstar:~$ udevinfo -a -p `udevinfo -q path -n /dev/sda1`

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device '/block/sda/sda1':
KERNEL=="sda1"
SUBSYSTEM=="block"
DRIVER==""
SYSFS{stat}==" 30 240 0 0"
SYSFS{size}=="250592"
SYSFS{start}=="32"
SYSFS{dev}=="8:1"

looking at parent device '/block/sda':
ID=="sda"
BUS=="block"
DRIVER==""
SYSFS{stat}==" 30 9 312 577 0 0 0 0 0 353 577"
SYSFS{size}=="251904"
SYSFS{removable}=="1"
SYSFS{range}=="16"
SYSFS{dev}=="8:0"

looking at parent device '/devices/pci0000:00/0000:00:03.1/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0':
ID=="0:0:0:0"
BUS=="scsi"
DRIVER=="sd"
SYSFS{ioerr_cnt}=="0x1"
SYSFS{iodone_cnt}=="0x572"
SYSFS{iorequest_cnt}=="0x572"
SYSFS{iocounterbits}=="32"
SYSFS{timeout}=="30"
SYSFS{state}=="running"
SYSFS{rev}=="1.01"
SYSFS{model}=="JUMPDRIVE " -----> device specific
SYSFS{vendor}=="LEXAR " -----> device specific
SYSFS{scsi_level}=="2"
SYSFS{type}=="0"
SYSFS{queue_type}=="none"
SYSFS{queue_depth}=="1"
SYSFS{device_blocked}=="0"
SYSFS{max_sectors}=="240"

looking at parent device '/devices/pci0000:00/0000:00:03.1/usb2/2-2/2-2:1.0/host0/target0:0:0':
ID=="target0:0:0"
BUS==""
DRIVER==""

looking at parent device '/devices/pci0000:00/0000:00:03.1/usb2/2-2/2-2:1.0/host0':
ID=="host0"
BUS==""
DRIVER==""

looking at parent device '/devices/pci0000:00/0000:00:03.1/usb2/2-2/2-2:1.0':
ID=="2-2:1.0"
BUS=="usb"
DRIVER=="usb-storage"
SYSFS{interface}=="LEXR PLUG DRIVE"
SYSFS{modalias}=="usb:v05DCp0080d0001dc00dsc00dp00ic08isc06ip50"
SYSFS{bInterfaceProtocol}=="50"
SYSFS{bInterfaceSubClass}=="06"
SYSFS{bInterfaceClass}=="08"
SYSFS{bNumEndpoints}=="02"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceNumber}=="00"

looking at parent device '/devices/pci0000:00/0000:00:03.1/usb2/2-2':
ID=="2-2"
BUS=="usb"
DRIVER=="usb"
SYSFS{serial}=="000000105071405266050000000000000000000000000" ---> also
SYSFS{product}=="LEXR PLUG DRIVE"
SYSFS{manufacturer}=="LEXR PLUG DRIVE"
SYSFS{quirks}=="0x0"
SYSFS{maxchild}=="0"
SYSFS{version}==" 1.10"
SYSFS{devnum}=="2"
SYSFS{speed}=="12"
SYSFS{bMaxPacketSize0}=="8"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="00"
SYSFS{bcdDevice}=="0001"
SYSFS{idProduct}=="0080"
SYSFS{idVendor}=="05dc"
SYSFS{bMaxPower}==" 90mA"
SYSFS{bmAttributes}=="80"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{configuration}==""

looking at parent device '/devices/pci0000:00/0000:00:03.1/usb2':
ID=="usb2"
BUS=="usb"
DRIVER=="usb"
SYSFS{serial}=="0000:00:03.1"
SYSFS{product}=="OHCI Host Controller"
SYSFS{manufacturer}=="Linux 2.6.21.1 ohci_hcd"
SYSFS{quirks}=="0x0"
SYSFS{maxchild}=="3"
SYSFS{version}==" 1.10"
SYSFS{devnum}=="1"
SYSFS{speed}=="12"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="09"
SYSFS{bcdDevice}=="0206"
SYSFS{idProduct}=="0000"
SYSFS{idVendor}=="0000"
SYSFS{bMaxPower}==" 0mA"
SYSFS{bmAttributes}=="e0"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{configuration}==""

looking at parent device '/devices/pci0000:00/0000:00:03.1':
ID=="0000:00:03.1"
BUS=="pci"
DRIVER=="ohci_hcd"
SYSFS{msi_bus}==""
SYSFS{broken_parity_status}=="0"
SYSFS{modalias}=="pci:v00001039d00007001sv00001043sd0000810Ebc0Csc03i10"
SYSFS{local_cpus}=="ffffffff"
SYSFS{irq}=="19"
SYSFS{class}=="0x0c0310"
SYSFS{subsystem_device}=="0x810e"
SYSFS{subsystem_vendor}=="0x1043"
SYSFS{device}=="0x7001"
SYSFS{vendor}=="0x1039"

looking at parent device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""

Just remember only parameters within a block can be used

Sorry if it is not completely clear, English is not my native language
Hope this helps
Ciao
 
Old 07-05-2007, 02:21 PM   #5
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Original Poster
Rep: Reputation: 35
Thanks much for the long and thorough reply urka58 - much appreciated! (and sorry for the delay in getting back with you - Holiday season and didn't bring too many PCs)

I followed your advise and created the following udev rule called 99-local.rules:

Code:
DRIVERS=="usb", SUBSYSTEMS=="usb", ATTRS{product}=="TEAC FD-05PUB   ", SYMLINK+="floppy fd0"
This creates the required symlinks, but it links to the wrong device, ie the raw USB-device, and not the drive (which is mountable).

Hence I now have the following ls -l /dev/floppy
Code:
lrwxrwxrwx 1 root root 3 2007-07-05 21:11 floppy -> sg1
However - the real floppy is located at sdb
Code:
brw-rw---- 1 root plugdev 8, 16 2007-07-05 21:11 sdb
This is taken care of by hal. Now sdb works fine and is mountable. /dev/floppy and /dev/fd0 - the symlinks I created, are not mountable and as such do not respond very well to neither mdir nor dosemu.

I guess what I really need is a symlink from /dev/floppy to /dev/sdb (except sdb some times is sda and sometimes sdc, depending on the order of which the items are plugged into the USB hub...

For completeness, please find below the output of udevinfo -a -p `udevinfo -q path -n /dev/sdb`
Code:
Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/block/sdb':
    KERNEL=="sdb"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{capability}=="13"
    ATTR{stat}=="      43        6      220    14964        0        0        0        0        0    14964    14964"
    ATTR{size}=="2880"
    ATTR{removable}=="1"
    ATTR{range}=="16"
    ATTR{dev}=="8:16"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0/host4/target4:0:0/4:0:0:0':
    KERNELS=="4:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{ioerr_cnt}=="0x3"
    ATTRS{iodone_cnt}=="0x8e"
    ATTRS{iorequest_cnt}=="0x8e"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="30"
    ATTRS{state}=="running"
    ATTRS{rev}=="3200"
    ATTRS{model}=="FD-05PUB        "
    ATTRS{vendor}=="TEAC    "
    ATTRS{scsi_level}=="0"
    ATTRS{type}=="0"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"
    ATTRS{max_sectors}=="240"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0/host4/target4:0:0':
    KERNELS=="target4:0:0"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0/host4':
    KERNELS=="host4"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRS{modalias}=="usb:v0644p0000d0000dc00dsc00dp00ic08isc04ip00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bInterfaceSubClass}=="04"
    ATTRS{bInterfaceClass}=="08"
    ATTRS{bNumEndpoints}=="03"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{product}=="TEAC FD-05PUB   "
    ATTRS{manufacturer}=="TEAC    "
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="0"
    ATTRS{version}==" 2.00"
    ATTRS{devnum}=="6"
    ATTRS{busnum}=="1"
    ATTRS{speed}=="12"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bcdDevice}=="0000"
    ATTRS{idProduct}=="0000"
    ATTRS{idVendor}=="0644"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{bmAttributes}=="80"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""
    ATTRS{dev}=="189:5"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0000:00:1d.0"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{manufacturer}=="Linux 2.6.22-rc7 uhci_hcd"
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="2"
    ATTRS{version}==" 1.10"
    ATTRS{devnum}=="1"
    ATTRS{busnum}=="1"
    ATTRS{speed}=="12"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0206"
    ATTRS{idProduct}=="0000"
    ATTRS{idVendor}=="0000"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""
    ATTRS{dev}=="189:0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0':
    KERNELS=="0000:00:1d.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{modalias}=="pci:v00008086d000027C8sv000017AAsd0000200Abc0Csc03i00"
    ATTRS{local_cpus}=="f"
    ATTRS{irq}=="20"
    ATTRS{class}=="0x0c0300"
    ATTRS{subsystem_device}=="0x200a"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{device}=="0x27c8"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{uevent}==""
Any insight greatly appreciated!

-y1

Last edited by Yalla-One; 07-05-2007 at 02:24 PM.
 
Old 07-05-2007, 02:33 PM   #6
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Original Poster
Rep: Reputation: 35
Here we go - replying to my own posts...

Anyway - as I posted the last message I realized that I was addressing the USB subsystem rather than the SCSI one, and thus I changed the udev rule to the following:
Code:
SUBSYSTEMS=="scsi". DRIVERS=="sd", ATTRS{model}=="FD-05PUB        ", ATTRS{vendor}=="TEAC    ", SYMLINK+="floppy fd0"
Now I have the interesting situation that /dev/floppy links to /dev/sdb, while the real mountable floppy (as used by HAL) is /dev/sdc ...

sdb is unreadable both by mdir, mount and dosemu...

The following relevant devices are present in /dev:
Code:
lrwxrwxrwx 1 root root           3 2007-07-05 21:24 fd0 -> sdb
lrwxrwxrwx 1 root root           3 2007-07-05 21:24 floppy -> sdb
brw-rw---- 1 root plugdev   8,  16 2007-07-05 21:11 sdb
brw-rw---- 1 root plugdev   8,  32 2007-07-05 21:24 sdc
Does this make sense?
 
Old 07-05-2007, 04:58 PM   #7
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 14
Posts: 530

Rep: Reputation: 30
Hi, it's me again. It seems to me you did not define any /dev @ which your rule is applied
I'd try
KERNEL=="sd[a-z][0-9]*", NAME="%k", SUBSYSTEMS=="scsi", ATTRS{model}=="FD-05PUB ", ATTRS{vendor}=="TEAC ", SYMLINK+="floppy fd0"
I insist, you should name your rule as 01-udev.. not 99-udev..
Writing UDEV rules is a little confusing as it changes very often. As you get a little experienced, they change... bah..
Let me know if that works.
Ciao

Last edited by urka58; 07-05-2007 at 05:04 PM.
 
Old 07-06-2007, 08:37 AM   #8
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Original Poster
Rep: Reputation: 35
Ahh - I forgot to rename to 01-local instead of 99-local.. Now it's changed.. I tried your ruleset, and it only seems to work if there's already an sdb device present.

However, a new google search based on what I learned so far in this thread prompted me to try this one, which actually works excellent:

Code:
BUS=="usb", SYSFS{product}=="TEAC FD-05PUB*", SYMLINK+="floppy fd0"
Thanks again for your patient and accurate help - most appreciated!

-y1
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
udev sometimes does not create dev/hda3 vdemuth Slackware 5 01-23-2006 01:46 PM
udev takes long time to create /dev/usbhd symlink Yalla-One Slackware 4 04-04-2005 03:27 AM
udev doesn't create /dev/pktcdvd/0 logout_login Linux - Software 1 04-03-2005 11:29 PM
udev likes to delete /dev/sda* but not create them :( edman007 Linux - Software 2 01-18-2005 05:02 PM
udev not making /dev/sound right in Slackware 10 glennt11 Slackware 5 01-16-2005 11:23 PM


All times are GMT -5. The time now is 04:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration