diff options
author | Khalid Aziz <khalid@gonehiking.org> | 2013-07-25 16:21:09 -0600 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-07-26 11:35:18 +0900 |
commit | 5f32e0d2d693f46825345f589ee11fa439a4ca12 (patch) | |
tree | a96be53ddce033980f05d6c7fe6a0f5c6104c02e | |
parent | 91e34163d316770930a1323d688e6b6fbca92fcd (diff) | |
download | kexec-tools-5f32e0d2d693f46825345f589ee11fa439a4ca12.tar.gz |
"kexec -p" fails to load kernels with version of the form x.y instead of
x.y.z with an error message similar to "Unsupported utsname.release:
3.10-1-amd64". Code in kernel_version() also checks the wrong variable
name for error return value from strtoul() for "minor" and "patch", and
hence possibly missing a real error.
These changes fix both of these problems.
Signed-off-by: Khalid Aziz <khalid@gonehiking.org>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/kernel_version.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/kexec/kernel_version.c b/kexec/kernel_version.c index 079312bc..21fb13ad 100644 --- a/kexec/kernel_version.c +++ b/kexec/kernel_version.c @@ -31,21 +31,20 @@ long kernel_version(void) } minor = strtoul(p, &p, 10); - if (major == ULONG_MAX) { + if (minor == ULONG_MAX) { fprintf(stderr, "strtoul failed: %s\n", strerror(errno)); return -1; } - if (*p++ != '.') { - fprintf(stderr, "Unsupported utsname.release: %s\n", - utsname.release); - return -1; - } - - patch = strtoul(p, &p, 10); - if (major == ULONG_MAX) { - fprintf(stderr, "strtoul failed: %s\n", strerror(errno)); - return -1; + /* There may or may not be a patch level for this kernel */ + if (*p++ == '.') { + patch = strtoul(p, &p, 10); + if (patch == ULONG_MAX) { + fprintf(stderr, "strtoul failed: %s\n",strerror(errno)); + return -1; + } + } else { + patch = 0; } if (major >= 256 || minor >= 256 || patch >= 256) { |