1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Replace strncmp kernel version number checks with proper ones

This commit is contained in:
Alasdair Kergon 2010-05-24 23:11:34 +00:00
parent ed122a962d
commit ba61f84874
4 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.67 -
===============================
Replace strncmp kernel version number checks with proper ones.
Avoid selecting names under /dev/block if there is an alternative.
Update clustered log kernel module name to log-userspace for 2.6.31 onwards.
Activate only first head of Replicator for vgchange -ay.

View File

@ -474,6 +474,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,
unsigned maj2, min2, patchlevel2;
char vsn[80];
struct utsname uts;
unsigned kmaj, kmin, krel;
if (!_mirrored_checked) {
_mirrored_present = target_present(cmd, "mirror", 1);
@ -511,8 +512,9 @@ static int _mirrored_target_present(struct cmd_context *cmd,
* The dm-log-userspace module was added to the
* 2.6.31 kernel.
*/
/* FIXME Replace the broken string comparison! */
if (!uname(&uts) && strncmp(uts.release, "2.6.31", 6) < 0) {
if (!uname(&uts) &&
(sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) == 3) &&
KERNEL_VERSION(kmaj, kmin, krel) < KERNEL_VERSION(2, 6, 31)) {
if (module_present(cmd, "log-clustered"))
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
} else if (module_present(cmd, "log-userspace"))

View File

@ -27,4 +27,6 @@
#define uninitialized_var(x) x = x
#define KERNEL_VERSION(major, minor, release) (((major) << 16) + ((minor) << 8) + (release))
#endif

View File

@ -1540,9 +1540,9 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, uint32_t major,
int pos = 0;
char logbuf[DM_FORMAT_DEV_BUFSIZE];
const char *logtype;
unsigned kmaj, kmin, krel;
r = uname(&uts);
if (r)
if (!uname(&uts) || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3)
return_0;
if ((seg->flags & DM_BLOCK_ON_ERROR)) {
@ -1556,7 +1556,7 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, uint32_t major,
* "handle_errors" by the dm-mirror module's version
* number (>= 1.12) or by the kernel version (>= 2.6.22).
*/
if (strncmp(uts.release, "2.6.22", 6) >= 0)
if (KERNEL_VERSION(kmaj, kmin, krel) >= KERNEL_VERSION(2, 6, 22))
handle_errors = 1;
else
block_on_error = 1;
@ -1575,8 +1575,7 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, uint32_t major,
* The dm-log-userspace module was added to the
* 2.6.31 kernel.
*/
/* FIXME Replace the broken string comparison! */
if (strncmp(uts.release, "2.6.31", 6) >= 0)
if (KERNEL_VERSION(kmaj, kmin, krel) >= KERNEL_VERSION(2, 6, 31))
dm_log_userspace = 1;
}