From: Andreas Dilger Date: Wed, 8 Feb 2017 12:11:32 +0000 (-0700) Subject: LU-5969 lustreapi: allow "version" without "lustre:" X-Git-Tag: 2.9.54~56 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d89191163324200d1f57a095faef1253c7d9fe11;p=fs%2Flustre-release.git LU-5969 lustreapi: allow "version" without "lustre:" The upstream kernel /sys/fs/lustre/version file does not have the "lustre:" prefix in it, only the version string. Since we no longer have multiple version strings in this file, if "lustre:" is not found then just assume the whole string is the version, otherwise continue to strip out the "lustre:" prefix as we did before. Signed-off-by: Andreas Dilger Change-Id: Ife50f83ad422a8e3c9ae857f519a5cf4ca3ebbe5 Reviewed-on: https://review.whamcloud.com/25324 Tested-by: Jenkins Reviewed-by: Patrick Farrell Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/liblustreapi_util.c b/lustre/utils/liblustreapi_util.c index db84f98..44eeb31 100644 --- a/lustre/utils/liblustreapi_util.c +++ b/lustre/utils/liblustreapi_util.c @@ -124,21 +124,24 @@ int llapi_get_version_string(char *version, unsigned int version_size) } ptr = strstr(buffer, "lustre:"); - if (ptr != NULL) { - llapi_chomp_string(ptr); + if (ptr) { ptr += strlen("lustre:"); while (*ptr == ' ' || *ptr == '\t') ptr++; - - if (strlcpy(version, ptr, version_size) >= version_size) { - errno = EOVERFLOW; - return -1; - } } else { + ptr = buffer; + } + llapi_chomp_string(ptr); + + if (ptr[0] == '\0') { errno = ENODATA; return -1; } + if (strlcpy(version, ptr, version_size) >= version_size) { + errno = EOVERFLOW; + return -1; + } return 0; }