]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: check existence of property before use
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 May 2023 17:25:53 +0000 (02:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 20 May 2023 05:26:05 +0000 (14:26 +0900)
rules.d/60-persistent-storage-tape.rules

index 8c00cc76d92005854dacd149c720a713bed45afa..803f82c583e73b29f5af8966817a6c5aaa1a6e42 100644 (file)
@@ -6,16 +6,22 @@ ACTION=="remove", GOTO="persistent_storage_tape_end"
 ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1", GOTO="persistent_storage_tape_end"
 
 # type 8 devices are "Medium Changers"
-SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", IMPORT{program}="scsi_id --sg-version=3 --export --allowlisted -d $devnode", \
-  SYMLINK+="tape/by-id/scsi-$env{ID_SERIAL} tape/by-id/scsi-$env{ID_SERIAL}-changer"
+SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", GOTO="medium_changer_begin"
+GOTO="medium_changer_end"
+
+LABEL="medium_changer_begin"
+
+IMPORT{program}="scsi_id --sg-version=3 --export --allowlisted -d $devnode"
+ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/scsi-$env{ID_SERIAL} tape/by-id/scsi-$env{ID_SERIAL}-changer"
 
 # iSCSI devices from the same host have all the same ID_SERIAL,
 # but additionally a property named ID_SCSI_SERIAL.
-SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", ENV{ID_SCSI_SERIAL}=="?*", \
-  SYMLINK+="tape/by-id/scsi-$env{ID_SCSI_SERIAL}"
+ENV{ID_SCSI_SERIAL}=="?*", SYMLINK+="tape/by-id/scsi-$env{ID_SCSI_SERIAL}"
+
+IMPORT{builtin}="path_id"
+ENV{ID_PATH}=="?*", SYMLINK+="tape/by-path/$env{ID_PATH}-changer"
 
-SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", IMPORT{builtin}="path_id", \
-  SYMLINK+="tape/by-path/$env{ID_PATH}-changer"
+LABEL="medium_changer_end"
 
 SUBSYSTEM!="scsi_tape", GOTO="persistent_storage_tape_end"