Skip to contentSkip to conversation

Workaround for kernel 3.0 & uname

PATCH New Milan Broz 2 participants 2 messages Jun 4, 2011 – Jun 9, 2011

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Workaround for kernel 3.0 & uname

With recent ernel 3.0 update sme distros
has uname in form "3.0-rc1".

This patch temporary workarounds uname detection
(because with the new release string libdevmapper
initialization fails.)

---
 libdm/ioctl/libdm-iface.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
libdm/ioctl/libdm-iface.c +11 -2
index f54cf1d..02b3470 100644
@@ -152,6 +152,7 @@ static int _uname(void)
 {
 	static int _uts_set = 0;
 	struct utsname _uts;
+	int parts;
 
 	if (_uts_set)
 		return 1;
@@ -160,10 +161,18 @@ static int _uname(void)
 		log_error("uname failed: %s", strerror(errno));
 		return 0;
 	}
-	if (sscanf(_uts.release, "%d.%d.%d",
+
+	parts = sscanf(_uts.release, "%d.%d.%d",
 			&_kernel_major,
 			&_kernel_minor,
-			&_kernel_release) != 3) {
+			&_kernel_release);
+
+	if (parts == 1 && _kernel_major >= 3) {
+		_kernel_minor = 0;
+		_kernel_release = 0;
+	} else if (parts == 2 && _kernel_major >= 3) {
+		_kernel_release = 0;
+	} else if (parts != 3) {
 		log_error("Could not determine kernel version used.");
 		return 0;
 	}
Signature · 1 line
1.7.5.3
#1 lore raw

PATCH 1/1 Workaround for kernel 3.0 & uname

Review

Quoted 1 line · Milan Broz
(quoted diff) +1 -0
+		_kernel_release = 0;

Let's move those (noops) out of the way to the initialisation,
static int _kernel_major = 0;

Then the if test can be simplified:

	/* Kernels with a major number of 2 always had 3 parts. */
	if (parts < 1 || (_kernel_major < 3 && parts < 3))

libdm/ioctl/libdm-iface.c static int _uname(void) · line 178

Quoted 3 lines
libdm/ioctl/libdm-iface.c +0 -0
 		log_error("Could not determine kernel version used.");
 		return 0;
 	}

Alasdair