From db44a9e35a9c115d69bca82014ceec4c5fc336dd Mon Sep 17 00:00:00 2001 From: Giuseppe Di Natale Date: Fri, 20 May 2016 08:01:35 -0700 Subject: [PATCH] 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 --- lustre/obdclass/lprocfs_status.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; -- 1.8.3.1