1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 06:52:22 +03:00
Commit Graph

44 Commits

Author SHA1 Message Date
Kay Sievers
15328d84d2 rules: set polling value only if it is disabled 2011-06-28 00:17:55 +02:00
Kay Sievers
ffb187faf9 rules: move polling rule above 'block' match 2011-06-18 23:05:20 +02:00
Kay Sievers
c5a41da949 rules: enable in-kernel media-presence polling 2011-06-18 21:01:33 +02:00
Keshav P.R
693b6344e1 rules: support for gpt partition uuid/label 2011-06-11 13:41:34 +02:00
Martin Pitt
55eb500cc5 Avoid spinning up CD on pressing eject button
When the CD tray door is locked and the hardware eject button is pressed, newer
kernels (2.6.38+) will send out a change event with a DISK_EJECT_REQUEST==1
property. Do not run cdrom_id and blkid in this case, as the media state and
contents does not change, and this only needlessly spins up the drive again
right before ejection.
2011-04-04 11:47:54 +02:00
David Zeuthen
42b9482ab2 Run ata_id on non-removable USB devices
If a USB device is marked as removable, it is often a SATA/PATA disk
in an enclosure (note that flash card readers and usb storage sticks
are always marked as removable). In this case, try running ata_id
(which sends ATA commands wrapped in SCSI ATA PASS THROUGH commands)
to get information about the disk. If this fails, just fall back to
running usb_id since it could be the device isn't an ATA device at
all or the device doesn't have a SAT layer.

This extra information is nice to have as it indicates if it is
suitable to send e.g. SMART commands to the disk, whether the disk
supports power management and so on. Additionally, the VPD and serial
number returned by ata_id is usually more accurate as it stems from
the disk itself instead of the enclosure.

Note that udisks has been doing this for a while

 KERNEL=="sd*[!0-9]", ATTR{removable}=="0", ENV{ID_BUS}=="usb", ENV{DEVTYPE}=="disk", IMPORT{program}="udisks-probe-ata-smart $tempnode"

so this change shouldn't be too disruptive (udisks-probe-ata-smart
also sends ATA commands via the ATA PASS THROUGH command).

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-03-30 10:28:24 -04:00
Kay Sievers
a31d76b186 rules: run ata_id only on SPC-3 or later optical drives 2011-03-23 12:11:38 +01:00
Kay Sievers
310f99d335 rules: revert bsg use until the event ordering problem is sorted out
The bsg devices node are created after the LUN, so we fail in the
hotplug case, but succeed at coldplug, and create inconsistent data
that way.

The bsg device event order will need to be sorted out, by changing the
kernel.
2010-11-30 11:48:08 +01:00
David Zeuthen
560de57514 Use ata_id, not scsi_id, on ATAPI devices
The major benefit here, is that we get the ATAPI device serial
number. With SCSI ID we didn't get this since it's not part of the
SCSI INQUIRY command. Specifically this means that we get symlinks to
empty optical drives, e.g.

 /dev/disk/by-id/ata-VBOX_CD-ROM_VB2-01700376

which we didn't get earlier. So this is a major win.

Also make ata_id work on CD-ROM devices when using /dev/bsg nodes so
this works on both the scsi_device as well as the block device. We do
this, basically, by issuing the ATA IDENTIFY PACKET DEVICE command
instead of the ATA IDENTIFY command. We also use 16-byte pass-through
ATA passthrough instead of 12-byte passthrough to avoid clashing with
the MMC BLANK command.

This means that we get this output

 # udevadm info -q all -p /sys/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0
 P: /devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0
 E: UDEV_LOG=3
 E: DEVPATH=/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0
 E: DEVTYPE=scsi_device
 E: DRIVER=sr
 E: MODALIAS=scsi:t-0x05
 E: SUBSYSTEM=scsi
 E: ID_ATA=1
 E: ID_TYPE=cd
 E: ID_BUS=ata
 E: ID_MODEL=VBOX_CD-ROM
 E: ID_MODEL_ENC=VBOX\x20CD-ROM\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x 20\x20\x20\x20\x20\x20\x20
 E: ID_REVISION=1.0
 E: ID_SERIAL=VBOX_CD-ROM_VB2-01700376
 E: ID_SERIAL_SHORT=VB2-01700376

instead of just

 # udevadm info -q all -p /sys/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0
 P: /devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0
 E: UDEV_LOG=3
 E: DEVPATH=/devices/pci0000:00/0000:00:01.1/host3/target3:0:0/3:0:0:0
 E: DEVTYPE=scsi_device
 E: DRIVER=sr
 E: MODALIAS=scsi:t-0x05
 E: SUBSYSTEM=scsi
 E: ID_SCSI=1
 E: ID_VENDOR=VBOX
 E: ID_VENDOR_ENC=VBOX\x20\x20\x20\x20
 E: ID_MODEL=CD-ROM
 E: ID_MODEL_ENC=CD-ROM\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
 E: ID_REVISION=1.0
 E: ID_TYPE=cd

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-11-04 13:29:38 -04:00
David Zeuthen
2938220037 Run scsi_id and ata_id on the scsi_device object
In a multi-initiator setup, the HBA may very well export a SCSI device
for a device that another initiator has already logged into. But since
another initiator has already logged in, the kernel will not create a
block device.

Note that this is also the case for some RAID HBAs - for example, the
LSI 1068 series cards will export a SCSI device for a disk that is in
use by the HBAs RAID engine (no block device will be created here).

Running scsi_id and ata_id on the actual SCSI device means that we can
inquire the capabilities of the device. For example, we can check
whether ID_ATA_FEATURE_SET_SMART and ID_ATA_FEATURE_SET_SMART_ENABLED
is set and, if so, periodically poll the SMART status of the
disk. Even when other initiators has claimed the disk and if the disk
is in use by the RAID engine of the HBA.

Note that we run scsi_id and ata_id on /dev/bsg/* nodes - this is safe
to do because the scsi core guarantees that the bsg device has been
created before the actual add uevent for the scsi_device is emitted.

Since the block device is a direct child of the scsi_device we can
avoid running scsi_id and ata_id again by simply importing the
resulting ID_* properties from the parent.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-10-30 13:04:35 -04:00
Ryan Harper
2d000ed9d8 Add virtio-blk by-id rules based on 'serial' attribute
Using virtio-blk serial attributes add rules to extract drive serial numbers and
generate by-id links for the block device and partitions.

With these rules added, we now see the following symlinks in disk/by-id

% ls -al /dev/disk/by-id | grep vdb
lrwxrwxrwx. 1 root root   9 Jun  1 22:09 virtio-QM00001 -> ../../vda
lrwxrwxrwx. 1 root root  10 Jun  1 22:09 virtio-QM00001-part1 -> ../../vda1

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
2010-06-29 17:22:58 +02:00
Kay Sievers
484e1b2d11 rules: optical drives - use ID_CDROM_MEDIA_TRACK_COUNT_DATA
We should not access non-data optical media, ans skip things
like blkid. It will cause errors for some drives.

  https://bugzilla.kernel.org/show_bug.cgi?id=15757
2010-05-25 09:54:14 +02:00
Kay Sievers
4b06c40935 replace "add|change" with "!remove" 2010-04-12 16:52:41 +02:00
David Zeuthen
7f4954d040 Export ID_WWN_VENDOR_EXTENSION and ID_WWN_WITH_EXTENSION
Some SCSI devices use the same WWN and have a WWN extension that we
need to take into account when creating the /dev/disk/by-id/wwn
symlinks. Thus, introduce ID_WWN_WITH_EXTENSION. This property will
contain either the WWN (if no extension is present) or the WWN with
the vendor extension appended.

Example:

 # /lib/udev/ata_id/ata_id --export /dev/sda |grep WWN
 ID_WWN=0x5001517387d61905
 ID_WWN_WITH_EXTENSION=0x5001517387d61905

 # /lib/udev/scsi_id --whitelisted --export -d /dev/sdb |grep WWN
 ID_WWN=0x600508b400105df7
 ID_WWN_VENDOR_EXTENSION=0x0000e00000d80000
 ID_WWN_WITH_EXTENSION=0x600508b400105df70000e00000d80000

 # /lib/udev/scsi_id --whitelisted --export -d /dev/sdc |grep WWN
 ID_WWN=0x600508b400105df7
 ID_WWN_VENDOR_EXTENSION=0x0000e00000db0000
 ID_WWN_WITH_EXTENSION=0x600508b400105df70000e00000db0000

Signed-off-by: David Zeuthen <davidz@redhat.com>
2009-12-04 11:40:00 -05:00
David Zeuthen
d6b5571c12 Also create /dev/disk/by-id/wwn-0x..-part%n symlinks for partitions
# ls -l /dev/disk/by-id/wwn-0x500
 wwn-0x500000e01b83f360        wwn-0x50014ee25578924f-part1
 wwn-0x500000e01b83f440        wwn-0x50014ee25578924f-part2
 wwn-0x500000e01b83f520        wwn-0x50014ee2aabdc41b
 wwn-0x500000e01b843d90        wwn-0x50014ee2aabdc41b-part1
 wwn-0x5000c50016359fd1        wwn-0x50014ee2aabdc41b-part2
 wwn-0x50014ee0016eb4f5        wwn-0x5001517958cabd77
 wwn-0x50014ee0016eb572        wwn-0x5001517958cabd77-part1
 wwn-0x50014ee055d524e2        wwn-0x5001517958cabd77-part2
 wwn-0x50014ee055d524e2-part1  wwn-0x5001517958d6a74e
 wwn-0x50014ee055d524e2-part2  wwn-0x5001517958d6a74e-part1
 wwn-0x50014ee1003d9c50        wwn-0x5001517958d6a74e-part2
 wwn-0x50014ee1003d9c50-part1  wwn-0x50024e9200c0c693
 wwn-0x50014ee1003d9c50-part2  wwn-0x50024e9200c0c694
 wwn-0x50014ee1aac30d4e        wwn-0x50024e9200c0c6ae
 wwn-0x50014ee1aac30d4e-part1  wwn-0x50024e9200c0c6af
 wwn-0x50014ee1aac30d4e-part2  wwn-0x50024e9200c0c6b0
 wwn-0x50014ee25578924f        wwn-0x50024e9200c0c6b1

Signed-off-by: David Zeuthen <davidz@redhat.com>
2009-11-25 11:17:54 -05:00
David Zeuthen
28c7463999 Create /dev/disk/by-id/wwn-0x... symlinks
Now that both ata_id and scsi_id exports the World Wide Name in the
ID_WWN property, use this to create persistent symlinks. Example

 /dev/disk/by-id/wwn-0x500000e01b83f360 -> ../../sdn
 /dev/disk/by-id/wwn-0x500000e01b83f440 -> ../../sdm

Signed-off-by: David Zeuthen <davidz@redhat.com>
2009-11-25 11:10:47 -05:00
Kay Sievers
ecf61aa7fd rules: remove support for IDE (hd*) devices
The kernel IDE drivers get deprecated now:
  http://article.gmane.org/gmane.linux.ide/43151

Almost everybody has switched over to libata devices long ago.
Recent services do not work with the now deprecated IDE drivers
at all and require libata drivers and SCSI infrastructure.

Systems who care about the old stuff need to add the rules to the
compat rules.
2009-11-19 16:25:18 +01:00
Martin Pitt
6e1a152d1c fix previous commit for CD detection
Do not run blkid twice. *brown paperbag*
2009-09-20 19:21:04 +02:00
Martin Pitt
ce096702ec fix single-session CD detection
ID_CDROM_MEDIA_SESSION_LAST_OFFSET is not set for CDs with only a single
session (i. e. for the vast majority of CDs out there). The previous rules ran
blkid with invalid arguments for these, causing CD detection to fail in
DK-disks and gvfs.

Now check whether we actually have ID_CDROM_MEDIA_SESSION_LAST_OFFSET, and if
not, call blkid without -O for specifying the offset.

Many thanks to Maxim Levitsky for tracking this down!

https://launchpad.net/bugs/431055
2009-09-20 19:07:51 +02:00
Kay Sievers
8bbe3ca427 rules: make ata_id properties the default for all ATA block devices
We need to call ata_id as the default for libata sd* devices. We
want ID_BUS=ata, and the ATA device proeprties, and be independent
of the SCSI emulation with the truncated values. The links
in /dev/disk/by-id/{ata-*,scsi-*} are still the same.
2009-06-28 02:59:48 +02:00
Kay Sievers
fed0ad7694 ata_id: sync ID_SERIAL(_SHORT) with other *_id tools
ID_SERIAL is the full serial number used for the links, ID_SERIAL_SHORT
is the device serial number.
2009-06-28 02:58:12 +02:00
Kay Sievers
33a7615943 path_id: delete old shell script
Removed with this is SAS disk support which never really worked properly,
and legacy IDE disk support, which can be re-implemented if needed.
2009-06-08 16:51:13 +02:00
Kay Sievers
a2fe9450bb path_id: add iscsi support 2009-06-08 16:48:27 +02:00
Kay Sievers
7f011f6bf2 path_id: handle fibre channel 2009-06-08 14:56:49 +02:00
Kay Sievers
185ea6a76d path_id: implement in C using libudev 2009-06-06 16:07:06 +02:00
Kay Sievers
9fc643a414 rules: do not call path_id for virtual devices 2009-06-04 03:21:33 +02:00
Kay Sievers
f07996885d delete vol_id and require util-linux-ng's blkid 2009-05-11 04:12:23 +02:00
Kay Sievers
f907449eee cdrom_id: add and use ID_CDROM_MEDIA to decide if we run vol_id
Some broken mobile phones offer a faked cdrom drive with a media
without any tracks.
2009-04-21 03:27:14 +02:00
Kay Sievers
a0aa1d76d0 rules: replace IDE driver with media match 2009-03-25 13:40:55 +01:00
Kay Sievers
c4390e0711 rules: remove ram* from persisten disk links blacklist 2009-03-23 21:09:02 +01:00
David Brownell
684028b5be rules: exclude mtd* from persistent disk links 2009-03-23 21:03:00 +01:00
Borislav Petkov
c51446e893 rules: rename ide-floppy to ide-gd
The driver's name changed in the 2.6.28 timeframe.
2009-03-22 15:10:06 +01:00
Kay Sievers
dc9aa5e941 rules: include loop block devices in persistent links 2009-02-16 22:22:57 +01:00
Kay Sievers
88ec7bb754 rules: move OPTIONS to separate rule
A failing IMPORT+ match would prevent the OPTIONS+= action
from being applied.
2009-02-11 21:54:43 +01:00
Scott James Remnant
f24036d63b rules: update persistent storage rules to use inotify watches 2009-02-11 17:44:03 +00:00
Kay Sievers
18c969a12b rules: ATA_COMPAT do not try to match on sr*, it will never have vendor ATA 2008-12-02 17:33:11 +01:00
Kay Sievers
a4a2edb0ea rules: fix cciss disk/by-id/ links 2008-11-28 01:18:48 +01:00
Kay Sievers
b257afd0a2 rules: exclude "btibm" devices from vol_id calls 2008-11-25 17:25:14 +01:00
Harald Hoyer
15b3df5507 rules: add persistent rules for memory stick block devices
commit 5a9aed145ac0ffb3e29b1c8e0f19b34e277f9117
Author: Harald Hoyer <harald@redhat.com>
Date:   Wed Nov 19 11:22:30 2008 +0100

    added persistent rules for memory stick block devices
2008-11-19 17:29:50 +01:00
Kay Sievers
8e9c06be26 rules: remove DEVTYPE disk/partition 2008-11-13 07:45:58 +01:00
Kay Sievers
333b736fdc rules: ieee1394 - create both, by-id/scsi-* and by-id/ieee-* links 2008-10-01 14:42:58 +02:00
Kay Sievers
8eb4ab836c rules: optical drives - probe at last session offset, do not probe for raid 2008-08-22 10:11:34 +02:00
Kay Sievers
f755fd5657 rules: run vol_id on opticals only if media is found
Opening an optical drive device node without O_NONBLOCK autocloses the
tray, we run vol_id on every media change by kernel emitted "change"
events, which can make it hard to change the media when the tray closes
immediatey again.:) We check for cdrom_id to indicate an existing track,
if no media is found, we will not open the device with vol_id.

Thanks to Christian Krause and DavidZ for debugging and testing.
2008-08-02 10:26:48 +02:00
Kay Sievers
282988c4f8 move default rules from /etc/udev/rules.d/ to /lib/udev/rules.d/
None of these rules is supposed to be changed by users, so move
them out of /etc. Custom rules, and automatically generated rules
stay in /etc. All rules are still processed in lexical order,
regardless which directory they live in.
2008-07-18 15:56:03 +02:00