1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
There's a better solution to this...
This commit is contained in:
Peter Rajnoha 2014-09-12 15:16:08 +02:00
parent ae08a3a294
commit 25ae9383bb
2 changed files with 11 additions and 30 deletions

View File

@ -1,6 +1,5 @@
Version 1.02.91 -
====================================
Use dm-mod autoloading during dm_is_dm_major call if needed (kernels>=2.6.36).
Version 1.02.90 - 1st September 2014
====================================

View File

@ -336,6 +336,17 @@ static int _create_dm_bitset(void)
#endif
}
int dm_is_dm_major(uint32_t major)
{
if (!_create_dm_bitset())
return 0;
if (_dm_multiple_major_support)
return dm_bit(_dm_bitset, major) ? 1 : 0;
else
return (major == _dm_device_major) ? 1 : 0;
}
static void _close_control_fd(void)
{
if (_control_fd != -1) {
@ -412,35 +423,6 @@ bad:
#endif
}
int dm_is_dm_major(uint32_t major)
{
/*
* If dm-mod module is not loaded yet during this call, we
* can make it to load automatically in kernels >= 2.6.36
* just by opening the dm control device. However, in older
* kernels, there's nothing else we can do here - dm_is_dm_major
* will fail as it can't determine this without the module
* being loaded first - there's an error message issued for
* this scenario deeper in this code.
*/
if (!_uname())
return 0;
if (KERNEL_VERSION(_kernel_major, _kernel_minor, _kernel_release) >=
KERNEL_VERSION(2, 6, 36)) {
if (_control_fd == -1 && !_open_control())
return 0;
}
if (!_create_dm_bitset())
return 0;
if (_dm_multiple_major_support)
return dm_bit(_dm_bitset, major) ? 1 : 0;
else
return (major == _dm_device_major) ? 1 : 0;
}
static void _dm_zfree_string(char *string)
{
if (string) {