LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2012-01-11 12:34:45
Modified files:
. : WHATS_NEW_DM
libdm : libdevmapper.h libdm-common.c
Log message:
Add dm_device_get_name to get map name or block device name for given devno.
This is accomplished by reading associated sysfs information. For a dm device, this is /sys/dev/block/major:minor/dm/name (supported in kernel version >= 2.6.29, for older kernels, the behaviour is the same as for non-dm devices).
For a non-dm device, this is a readlink on /sys/dev/block/major:minor, e.g. /sys/dev/block/253:0 --> ../../devices/virtual/block/dm-0.
The last component of the path is a proper kernel name (block device name).
One can request to read only kernel names by setting the 'prefer_kernel_name' argument if needed.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.529&r2=1.530
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.174&r2=1.175
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132
WHATS_NEW_DM +1 -0
@@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Add dm_device_get_name to get map name or block device name for given devno. Remove empty devices when clearing left-over inactive tables in deptree. Add dm_uuid_prefix/dm_set_uuid_prefix to override hard-coded LVM- prefix. Improve dmsetup man page about readahead parameter.
libdm/libdevmapper.h +15 -0
@@ -300,6 +300,21 @@int dm_is_dm_major (uint32_t major);/* +* Get associated device name for given major and minor number by reading +* the sysfs content. If this is a dm device, get associated dm name, the one +* that appears in /dev/mapper. DM names could be resolved this way only if +* kernel used >= 2.6.29, kernel name is found otherwise (e.g. dm-0). +* If prefer_kernel_name is set, the kernel name is always preferred over +* device-mapper name for dm devices no matter what the kernel version is. +* For non-dm devices, we always get associated kernel name, e.g sda, md0 etc. +* Returns 0 on error or if sysfs is not used (or configured incorrectly), +* otherwise returns 1 and the supplied buffer holds the device name. +*/ +int dm_device_get_name (uint32_t major,uint32_t minor, +int prefer_kernel_name, +char *buf,size_t buf_size); + +/* * Determine whether a device has any holders (devices * using this device). If sysfs is not used (or configured * incorrectly), returns 0.
libdm/libdm-common.c +129 -23
167 lines not on this page · raw message