linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mdadm: Linux 3.x version change
@ 2011-06-10 14:30 Namhyung Kim
  2011-06-17 12:18 ` Milan Broz
  2011-06-17 14:07 ` David Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Namhyung Kim @ 2011-06-10 14:30 UTC (permalink / raw)
  To: NeilBrown; +Cc: linux-raid

As Linux 3.x changes its versioning scheme, we have to deal with
the 2-digit version number also.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 util.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/util.c b/util.c
index e92be4f..9db9ee6 100644
--- a/util.c
+++ b/util.c
@@ -154,8 +154,15 @@ int get_linux_version()
 	a = strtoul(cp, &cp, 10);
 	if (*cp != '.') return -1;
 	b = strtoul(cp+1, &cp, 10);
-	if (*cp != '.') return -1;
-	c = strtoul(cp+1, NULL, 10);
+	/* deal with 3.x version change */
+	if (*cp != '.') {
+		if (a >= 3)
+			c = 0;
+		else
+			return -1;
+	} else {
+		c = strtoul(cp+1, NULL, 10);
+	}
 
 	return (a*1000000)+(b*1000)+c;
 }
-- 
1.7.5.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mdadm: Linux 3.x version change
  2011-06-10 14:30 [PATCH] mdadm: Linux 3.x version change Namhyung Kim
@ 2011-06-17 12:18 ` Milan Broz
  2011-06-17 12:54   ` NeilBrown
  2011-06-17 14:07 ` David Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Milan Broz @ 2011-06-17 12:18 UTC (permalink / raw)
  To: NeilBrown; +Cc: Namhyung Kim, linux-raid

On 06/10/2011 04:30 PM, Namhyung Kim wrote:
> As Linux 3.x changes its versioning scheme, we have to deal with
> the 2-digit version number also.
FYI: we have patch below currently in Fedora rawhide
(which already switched to 3.0-rc numbering scheme).

Without it is system unable to assembly RAID during boot
("mdadm -As --auto=yes --run" fails because of wrong version detected).

It seems that 3.2.2 still have the same problem.

Milan

--- mdadm-3.2.1.old/util.c	2011-03-28 04:31:20.000000000 +0200
+++ mdadm-3.2.1/util.c	2011-06-05 07:59:03.741904751 +0200
@@ -154,8 +154,8 @@ int get_linux_version()
 	a = strtoul(cp, &cp, 10);
 	if (*cp != '.') return -1;
 	b = strtoul(cp+1, &cp, 10);
-	if (*cp != '.') return -1;
-	c = strtoul(cp+1, NULL, 10);
+	if (*cp != '.' && a <= 2) return -1;
+	c = (*cp == '.') ? strtoul(cp+1, NULL, 10) : 0;
 
 	return (a*1000000)+(b*1000)+c;
 }



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mdadm: Linux 3.x version change
  2011-06-17 12:18 ` Milan Broz
@ 2011-06-17 12:54   ` NeilBrown
  0 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2011-06-17 12:54 UTC (permalink / raw)
  To: Milan Broz; +Cc: Namhyung Kim, linux-raid

On Fri, 17 Jun 2011 14:18:47 +0200 Milan Broz <mbroz@redhat.com> wrote:

> On 06/10/2011 04:30 PM, Namhyung Kim wrote:
> > As Linux 3.x changes its versioning scheme, we have to deal with
> > the 2-digit version number also.
> FYI: we have patch below currently in Fedora rawhide
> (which already switched to 3.0-rc numbering scheme).
> 
> Without it is system unable to assembly RAID during boot
> ("mdadm -As --auto=yes --run" fails because of wrong version detected).
> 
> It seems that 3.2.2 still have the same problem.
> 
> Milan
> 
> --- mdadm-3.2.1.old/util.c	2011-03-28 04:31:20.000000000 +0200
> +++ mdadm-3.2.1/util.c	2011-06-05 07:59:03.741904751 +0200
> @@ -154,8 +154,8 @@ int get_linux_version()
>  	a = strtoul(cp, &cp, 10);
>  	if (*cp != '.') return -1;
>  	b = strtoul(cp+1, &cp, 10);
> -	if (*cp != '.') return -1;
> -	c = strtoul(cp+1, NULL, 10);
> +	if (*cp != '.' && a <= 2) return -1;
> +	c = (*cp == '.') ? strtoul(cp+1, NULL, 10) : 0;
>  
>  	return (a*1000000)+(b*1000)+c;
>  }
> 

Bother - I always seem to miss something :-(

I have added the following (which is different yet again) to git.

According to https://lwn.net/Articles/447572/ it seems it isn't yet 100%
certain that the next version will be 3.0 rather than 3.0.0....  So I might
not need to push out a new version too quickly.

Thanks,
NeilBrown

From f161d047eed634b3380262767f955eb888502e88 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Fri, 17 Jun 2011 22:49:24 +1000
Subject: [PATCH] util: correctly parse shorter linux version numbers.

The next version of Linux might be 3.0.  If it is, get_linux_version
will fail.
So make it more robust.

Reported-by: Namhyung Kim <namhyung@gmail.com>
Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
---
 util.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/util.c b/util.c
index 10bbe56..55d171a 100644
--- a/util.c
+++ b/util.c
@@ -146,16 +146,16 @@ int get_linux_version()
 {
 	struct utsname name;
 	char *cp;
-	int a,b,c;
+	int a = 0, b = 0,c = 0;
 	if (uname(&name) <0)
 		return -1;
 
 	cp = name.release;
 	a = strtoul(cp, &cp, 10);
-	if (*cp != '.') return -1;
-	b = strtoul(cp+1, &cp, 10);
-	if (*cp != '.') return -1;
-	c = strtoul(cp+1, NULL, 10);
+	if (*cp == '.')
+		b = strtoul(cp+1, &cp, 10);
+	if (*cp == '.')
+		c = strtoul(cp+1, &cp, 10);
 
 	return (a*1000000)+(b*1000)+c;
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mdadm: Linux 3.x version change
  2011-06-10 14:30 [PATCH] mdadm: Linux 3.x version change Namhyung Kim
  2011-06-17 12:18 ` Milan Broz
@ 2011-06-17 14:07 ` David Brown
  1 sibling, 0 replies; 4+ messages in thread
From: David Brown @ 2011-06-17 14:07 UTC (permalink / raw)
  To: linux-raid

On 10/06/2011 16:30, Namhyung Kim wrote:
> As Linux 3.x changes its versioning scheme, we have to deal with
> the 2-digit version number also.
>


I don't know what mdadm uses the version number for, but Linus Torvalds 
has had a rant about this sort of thing:

<https://lkml.org/lkml/2011/6/14/293>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-17 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-10 14:30 [PATCH] mdadm: Linux 3.x version change Namhyung Kim
2011-06-17 12:18 ` Milan Broz
2011-06-17 12:54   ` NeilBrown
2011-06-17 14:07 ` David Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).