1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-19 14:04:17 +03:00

cleanup: add dev-ext-udev-constants.h with constants/names of the properties/values used from udev db

This commit is contained in:
Peter Rajnoha 2015-01-29 16:44:34 +01:00
parent 1c7a509bed
commit 28ba0450e9
7 changed files with 68 additions and 10 deletions

View File

@ -13,6 +13,7 @@
@top_srcdir@/lib/datastruct/btree.h
@top_srcdir@/lib/datastruct/str_list.h
@top_srcdir@/lib/device/dev-cache.h
@top_srcdir@/lib/device/dev-ext-udev-constants.h
@top_srcdir@/lib/device/dev-type.h
@top_srcdir@/lib/device/device.h
@top_srcdir@/lib/device/device-types.h

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*************************************************************************
* Properties saved in udev db and accesible via libudev and used by LVM *
*************************************************************************/
/*
* DEV_EXT_UDEV_BLKID_TYPE property with various DEV_EXT_UDEV_BLKID_TYPE_*
* values that is saved in udev db via blkid call in udev rules
*/
#define DEV_EXT_UDEV_BLKID_TYPE "ID_FS_TYPE"
/*
* mpath_member is forced by multipath - it's set in udev db via
* multipath call overwriting any existing ID_FS_TYPE value for
* a device which is a multipath component which prevents incorrect
* claim of the device by any other block device subsystem
*/
#define DEV_EXT_UDEV_BLKID_TYPE_MPATH "mpath_member"
/* FW RAIDs are all *_raid_member types except linux_raid_member which denotes SW RAID */
#define DEV_EXT_UDEV_BLKID_TYPE_RAID_SUFFIX "_raid_member"
#define DEV_EXT_UDEV_BLKID_TYPE_SW_RAID "linux_raid_member"
#define DEV_EXT_UDEV_BLKID_PART_TABLE_TYPE "ID_PART_TABLE_TYPE"
#define DEV_EXT_UDEV_BLKID_PART_ENTRY_DISK "ID_PART_ENTRY_DISK"
/*
* DEV_EXT_UDEV_MPATH_DEVICE_PATH is set by multipath in udev db
* with value either 0 or 1. The same functionality as
* DEV_EXT_UDEV_BLKID_TYPE_MPATH actually, but introduced later
* for some reason.
*/
#define DEV_EXT_UDEV_MPATH_DEVICE_PATH "DM_MULTIPATH_DEVICE_PATH"
/***********************************************************
* Sysfs attributes accessible via libudev and used by LVM *
***********************************************************/
/* the value of size sysfs attribute is size in bytes */
#define DEV_EXT_UDEV_SYSFS_ATTR_SIZE "size"

View File

@ -18,6 +18,7 @@
#include "xlate.h"
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h> /* for MD detection using udev db records */
#include "dev-ext-udev-constants.h"
#endif
#ifdef __linux__
@ -93,10 +94,10 @@ static int _udev_dev_is_md(struct device *dev)
if (!(ext = dev_ext_get(dev)))
return_0;
if (!(value = udev_device_get_property_value((struct udev_device *)ext->handle, "ID_FS_TYPE")))
if (!(value = udev_device_get_property_value((struct udev_device *)ext->handle, DEV_EXT_UDEV_BLKID_TYPE)))
return 0;
return !strcmp(value, "linux_raid_member");
return !strcmp(value, DEV_EXT_UDEV_BLKID_TYPE_SW_RAID);
}
#else
static int _udev_dev_is_md(struct device *dev)

View File

@ -27,6 +27,7 @@
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h>
#include "dev-ext-udev-constants.h"
#endif
#include "device-types.h"
@ -337,10 +338,10 @@ static int _udev_dev_is_partitioned(struct device *dev)
if (!(ext = dev_ext_get(dev)))
return_0;
if (!(value = udev_device_get_property_value((struct udev_device *)ext->handle, "ID_PART_TABLE_TYPE")))
if (!(value = udev_device_get_property_value((struct udev_device *)ext->handle, DEV_EXT_UDEV_BLKID_PART_TABLE_TYPE)))
return 0;
if ((value = udev_device_get_property_value((struct udev_device *)ext->handle, "ID_PART_ENTRY_DISK")))
if ((value = udev_device_get_property_value((struct udev_device *)ext->handle, DEV_EXT_UDEV_BLKID_PART_ENTRY_DISK)))
return 0;
return 1;

View File

@ -17,6 +17,7 @@
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h>
#include "dev-ext-udev-constants.h"
#endif
#ifdef __linux__
@ -26,8 +27,8 @@ static int _udev_dev_is_fwraid(struct device *dev)
{
const char *value;
value = udev_device_get_property_value((struct udev_device *)dev->ext.handle, "ID_FS_TYPE");
if (value && strcmp(value, "linux_raid_member") && strstr(value, "_raid_member"))
value = udev_device_get_property_value((struct udev_device *)dev->ext.handle, DEV_EXT_UDEV_BLKID_TYPE);
if (value && strcmp(value, DEV_EXT_UDEV_BLKID_TYPE_SW_RAID) && strstr(value, DEV_EXT_UDEV_BLKID_TYPE_RAID_SUFFIX))
return 1;
return 0;

View File

@ -17,6 +17,7 @@
#include "activate.h"
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h>
#include "dev-ext-udev-constants.h"
#endif
#ifdef __linux__
@ -153,11 +154,11 @@ static int _udev_dev_is_mpath(struct device *dev)
if (!(ext = dev_ext_get(dev)))
return_0;
value = udev_device_get_property_value((struct udev_device *)ext->handle, "ID_FS_TYPE");
if (value && !strcmp(value, "mpath_member"))
value = udev_device_get_property_value((struct udev_device *)ext->handle, DEV_EXT_UDEV_BLKID_TYPE);
if (value && !strcmp(value, DEV_EXT_UDEV_BLKID_TYPE_MPATH))
return 1;
value = udev_device_get_property_value((struct udev_device *)ext->handle, "DM_MULTIPATH_DEVICE_PATH");
value = udev_device_get_property_value((struct udev_device *)ext->handle, DEV_EXT_UDEV_MPATH_DEVICE_PATH);
if (value && !strcmp(value, "1"))
return 1;

View File

@ -17,6 +17,7 @@
#include "activate.h" /* device_is_usable */
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h>
#include "dev-ext-udev-constants.h"
#endif
static const char *_too_small_to_hold_pv_msg = "Too small to hold a PV";
@ -66,7 +67,7 @@ static int _udev_check_pv_min_size(struct device *dev)
if (!(ext = dev_ext_get(dev)))
return_0;
if (!(size_str = udev_device_get_sysattr_value((struct udev_device *)ext->handle, "size"))) {
if (!(size_str = udev_device_get_sysattr_value((struct udev_device *)ext->handle, DEV_EXT_UDEV_SYSFS_ATTR_SIZE))) {
log_debug_devs("%s: Skipping: failed to get size from sysfs [%s:%p]",
dev_name(dev), dev_ext_name(dev), dev->ext.handle);
return 0;