From: Giuseppe Di Natale Date: Fri, 20 May 2016 15:01:35 +0000 (-0700) Subject: LU-7334 lprocfs: Allow a new line before null terminator X-Git-Tag: 2.8.55~27 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=db44a9e35a9c115d69bca82014ceec4c5fc336dd LU-7334 lprocfs: Allow a new line before null terminator Kernel string parsing functions support a single new line before the null terminator of a string. Our numeric string parsing should do the same. This allows strings to be echo'ed directly into proc files. Signed-off-by: Giuseppe Di Natale Change-Id: Ia9d36b4f4f6849547391115d31be34a14215fc2a Reviewed-on: http://review.whamcloud.com/20353 Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: Frank Zago Tested-by: Maloo --- diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index fce0bb1..c68bb31 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1708,6 +1708,17 @@ static int preprocess_numeric_str(char *buffer, __u64 *mult, __u64 def_mult, start = buffer; while (*buffer) { + /* allow for a single new line before the null terminator */ + if (*buffer == '\n') { + *buffer = '\0'; + buffer++; + + if (*buffer) + return -EINVAL; + + break; + } + /* any chars after our unit indicates a malformed string */ if (hit_unit) return -EINVAL;