All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: fix kernel version parsing on some versions past 3.0
@ 2018-09-03 10:14 Adam Borowski
  2018-09-03 10:14 ` [PATCH 2/2] btrfs-progs: defrag: open files RO on new enough kernels or if root Adam Borowski
  0 siblings, 1 reply; 9+ messages in thread
From: Adam Borowski @ 2018-09-03 10:14 UTC (permalink / raw)
  To: David Sterba, linux-btrfs, Mark Fasheh; +Cc: Adam Borowski

The code fails if the third section is missing (like "4.18") or is followed
by anything but "." or "-".  This happens for example if we're not exactly
at a tag and CONFIG_LOCALVERSION_AUTO=n (which results in "4.18.5+").

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
 fsfeatures.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fsfeatures.c b/fsfeatures.c
index 7d85d60f..66111bf4 100644
--- a/fsfeatures.c
+++ b/fsfeatures.c
@@ -216,11 +216,8 @@ u32 get_running_kernel_version(void)
 		return (u32)-1;
 	version |= atoi(tmp) << 8;
 	tmp = strtok_r(NULL, ".", &saveptr);
-	if (tmp) {
-		if (!string_is_numerical(tmp))
-			return (u32)-1;
+	if (tmp && string_is_numerical(tmp))
 		version |= atoi(tmp);
-	}
 
 	return version;
 }
-- 
2.19.0.rc1

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

end of thread, other threads:[~2018-09-03 16:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-03 10:14 [PATCH 1/2] btrfs-progs: fix kernel version parsing on some versions past 3.0 Adam Borowski
2018-09-03 10:14 ` [PATCH 2/2] btrfs-progs: defrag: open files RO on new enough kernels or if root Adam Borowski
2018-09-03 11:01   ` Nikolay Borisov
2018-09-03 11:12     ` Adam Borowski
2018-09-03 11:31     ` [PATCH v2] btrfs-progs: defrag: open files RO on new enough kernels Adam Borowski
2018-09-03 11:41       ` Nikolay Borisov
2018-09-03 11:46         ` [PATCH v3] " Adam Borowski
2018-09-03 11:04   ` [PATCH 2/2] btrfs-progs: defrag: open files RO on new enough kernels or if root Nikolay Borisov
2018-09-03 11:28     ` Adam Borowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.