Re: device name (symlink) stability

2017-04-25 Thread Michael Biebl
Am 25.04.2017 um 16:09 schrieb Vincent Lefevre:
> Hi,
> 
> On 2017-04-25 12:14:30 +0200, Michael Biebl wrote:
>> Am 25.04.2017 um 10:53 schrieb Vincent Lefevre:
> [...]
>>> In particular, it is strange that all the symlinks point to sr0
>>> except cdrw, which now points to sr1.
>>
>> The udev rules responsible for creating those symlinks is
>> /lib/udev/rules.d/80-debian-compat.rules or
>>
>> https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/extra/rules/80-debian-compat.rules#n18
>>
>> See the comment in there:
>>
>> # These rules will create symlinks for CD/DVD drives, to help old
>> # programs which are unable to automatically discover the devices.
>> # The first detected device gets the symlink, but this is not stable across
>> # reboots.
>>
>> So, yes, what you see can happen depending on the order devices are
>> discovered.
> 
> OK, but if sr0 is discovered first, then it should have all the
> symlinks, and if sr1 is discovered first, then it should have all
> the symlinks. But why do I get sr1 for only one of them?
> 
> lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 cdrom -> sr0
> lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 cdrw -> sr1
> lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 dvd -> sr0
> lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 dvdrw -> sr0
> 
> And why isn't there the same rule for cdrom?

I guess every sr0 can be considered a cdrom, but it's not necessarily a
dvd/cd writer.

> /lib/udev/rules.d/80-debian-compat.rules contains:
> 
> # These rules will create symlinks for CD/DVD drives, to help old
> # programs which are unable to automatically discover the devices.
> # The first detected device gets the symlink, but this is not stable across
> # reboots.
> ENV{ID_CDROM_CD_RW}=="?*", \
>   PROGRAM="/bin/sh -c 'ln -s %k /run/udev/link.cdrw 2>/dev/null; [ `readlink 
> /run/udev/link.cdrw` = %k ]", \
>   SYMLINK+="cdrw", OPTIONS+="link_priority=-100"
> ENV{ID_CDROM_DVD}=="?*", \
>   PROGRAM="/bin/sh -c 'ln -s %k /run/udev/link.dvd 2>/dev/null; [ `readlink 
> /run/udev/link.dvd` = %k ]", \
>   SYMLINK+="dvd", OPTIONS+="link_priority=-100"
> ENV{ID_CDROM_DVD_RW}=="?*", \
>   PROGRAM="/bin/sh -c 'ln -s %k /run/udev/link.dvdrw 2>/dev/null; [ `readlink 
> /run/udev/link.dvdrw` = %k ]", \
>   SYMLINK+="dvdrw", OPTIONS+="link_priority=-100"
> 
> but /lib/udev/rules.d/60-cdrom_id.rules contains:
> 
> KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100"


60-cdrom_id.rules is a rules provided by upstream,
80-debian-compat.rules a Debian specific file which we provide for
compat reasons.

I don't remember the details of 80-debian-compat.rules, but it's rather
ugly and it's maybe time to drop that hack early in the buster release
cycle.

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Re: device name (symlink) stability

2017-04-25 Thread Vincent Lefevre
Hi,

On 2017-04-25 12:14:30 +0200, Michael Biebl wrote:
> Am 25.04.2017 um 10:53 schrieb Vincent Lefevre:
[...]
> > In particular, it is strange that all the symlinks point to sr0
> > except cdrw, which now points to sr1.
> 
> The udev rules responsible for creating those symlinks is
> /lib/udev/rules.d/80-debian-compat.rules or
> 
> https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/extra/rules/80-debian-compat.rules#n18
> 
> See the comment in there:
> 
> # These rules will create symlinks for CD/DVD drives, to help old
> # programs which are unable to automatically discover the devices.
> # The first detected device gets the symlink, but this is not stable across
> # reboots.
> 
> So, yes, what you see can happen depending on the order devices are
> discovered.

OK, but if sr0 is discovered first, then it should have all the
symlinks, and if sr1 is discovered first, then it should have all
the symlinks. But why do I get sr1 for only one of them?

lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 cdrom -> sr0
lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 cdrw -> sr1
lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 dvd -> sr0
lrwxrwxrwx  1 root root   3 2017-04-24 10:05:16 dvdrw -> sr0

And why isn't there the same rule for cdrom?

/lib/udev/rules.d/80-debian-compat.rules contains:

# These rules will create symlinks for CD/DVD drives, to help old
# programs which are unable to automatically discover the devices.
# The first detected device gets the symlink, but this is not stable across
# reboots.
ENV{ID_CDROM_CD_RW}=="?*", \
  PROGRAM="/bin/sh -c 'ln -s %k /run/udev/link.cdrw 2>/dev/null; [ `readlink 
/run/udev/link.cdrw` = %k ]", \
  SYMLINK+="cdrw", OPTIONS+="link_priority=-100"
ENV{ID_CDROM_DVD}=="?*", \
  PROGRAM="/bin/sh -c 'ln -s %k /run/udev/link.dvd 2>/dev/null; [ `readlink 
/run/udev/link.dvd` = %k ]", \
  SYMLINK+="dvd", OPTIONS+="link_priority=-100"
ENV{ID_CDROM_DVD_RW}=="?*", \
  PROGRAM="/bin/sh -c 'ln -s %k /run/udev/link.dvdrw 2>/dev/null; [ `readlink 
/run/udev/link.dvdrw` = %k ]", \
  SYMLINK+="dvdrw", OPTIONS+="link_priority=-100"

but /lib/udev/rules.d/60-cdrom_id.rules contains:

KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100"

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Re: device name (symlink) stability

2017-04-25 Thread Michael Biebl
Hi

Am 25.04.2017 um 10:53 schrieb Vincent Lefevre:
> After a reboot of a Debian/unstable machine, I got:
> 
>   /dev/cdrw -> sr1
> 
> while it was
> 
>   /dev/cdrw -> sr0

[..]

> Is it normal that the device names are not stable?
> 
> In particular, it is strange that all the symlinks point to sr0
> except cdrw, which now points to sr1.

The udev rules responsible for creating those symlinks is
/lib/udev/rules.d/80-debian-compat.rules or

https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/extra/rules/80-debian-compat.rules#n18

See the comment in there:

# These rules will create symlinks for CD/DVD drives, to help old
# programs which are unable to automatically discover the devices.
# The first detected device gets the symlink, but this is not stable across
# reboots.

So, yes, what you see can happen depending on the order devices are
discovered.

Michael
-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


device name (symlink) stability

2017-04-25 Thread Vincent Lefevre
After a reboot of a Debian/unstable machine, I got:

  /dev/cdrw -> sr1

while it was

  /dev/cdrw -> sr0

before the reboot. More precisely, the change in the lshw output:

  *-scsi:0
   physical id: 8c
   logical name: scsi2
   capabilities: emulated
 *-cdrom
  description: DVD-RAM writer
  product: DVD+-RW GTA0N
  vendor: HL-DT-ST
  physical id: 0.0.0
  bus info: scsi@2:0.0.0
  logical name: /dev/cdrom
- logical name: /dev/cdrw
  logical name: /dev/dvd
  logical name: /dev/dvdrw
  logical name: /dev/sr0
  version: A1B0
  capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
  configuration: ansiversion=5 status=nodisc
  *-scsi:1
   physical id: 8d
   logical name: scsi3
   capabilities: emulated
 *-cdrom
  description: DVD-RAM writer
  product: DVD+-RW GHB0N
  vendor: HL-DT-ST
  physical id: 0.0.0
  bus info: scsi@3:0.0.0
+ logical name: /dev/cdrw
  logical name: /dev/sr1
  version: A1B1
  capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
  configuration: ansiversion=5 status=nodisc

Is it normal that the device names are not stable?

In particular, it is strange that all the symlinks point to sr0
except cdrw, which now points to sr1.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)