Skip to contentSkip to conversation

kpartx: partitions of mapped devices cannot be created in redhat OS

PATCH New [email protected] 1 participant 1 message Aug 29, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kpartx: partitions of mapped devices cannot be created in redhat OS

From: "tang.junhui" <[email protected]>

Environment variables such as DM_TABLE_STATE are used in kpartx.rules which exported by "dmsetup export" in previous udev rules in SuSE OS, however, there is no such command "dmsetup export" in redhat OS, so these environment variables are not initialized and
partitions cannot be created. This patch replace "dmsetup export" with "dmsetup info" to get the status of mapped device, which can work well both in SuSE and redhat OS.

---
 kpartx/kpartx.rules | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
kpartx/kpartx.rules +7 -3
index 1713f3c..8c8b836 100644
@@ -7,8 +7,12 @@
 KERNEL!="dm-*", GOTO="kpartx_end"
 ACTION=="remove", GOTO="kpartx_end"
 
-ENV{DM_TABLE_STATE}!="LIVE", GOTO="kpartx_end"
-ENV{DM_DEPS}=="0", GOTO="kpartx_end"
+ENV{DMSETUP_SBIN_PATH}="/sbin"
+TEST!="$env{DMSETUP_SBIN_PATH}/dmsetup", ENV{DMSETUP_SBIN_PATH}="/usr/sbin"
+IMPORT{program}="$env{DMSETUP_SBIN_PATH}/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o tables_loaded,device_count"
+
+ENV{DM_TABLES_LOADED}!="Live", GOTO="kpartx_end"
+ENV{DM_DEVICE_COUNT}=="0", GOTO="kpartx_end"
 
 ENV{DM_UUID}=="?*", IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
 
@@ -37,7 +41,7 @@ ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", \
 # Create dm tables for partitions
 ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", GOTO="kpartx_end"
 ENV{DM_NR_VALID_PATHS}=="0", GOTO="kpartx_end"
-ENV{DM_STATE}!="SUSPENDED", ENV{DM_UUID}=="mpath-*", \
+ENV{DM_SUSPENDED}!="Suspended", ENV{DM_UUID}=="mpath-*", \
 	RUN+="/sbin/kpartx -u -p -part /dev/$name"
 
 LABEL="kpartx_end"
Signature · 1 line
2.8.1.windows.1