From 3d628a1a9cf060fc1242c2ba6115e4ab612a1b55 Mon Sep 17 00:00:00 2001 From: Ted Zlatanov Date: Sat, 1 Feb 2014 06:43:01 -0500 Subject: [PATCH] Redmine#4217: clarify readfile() size limit --- reference/functions/readfile.markdown | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/reference/functions/readfile.markdown b/reference/functions/readfile.markdown index 5d166e4a..1af1c515 100644 --- a/reference/functions/readfile.markdown +++ b/reference/functions/readfile.markdown @@ -9,7 +9,9 @@ tags: [reference, io functions, functions, readfile] [%CFEngine_function_prototype(filename, maxbytes)%] -**Description:** Returns the first `maxbytes` bytes from file `filename`. +**Description:** Returns the first `maxbytes` bytes from file +`filename`. When `maxbytes` is 0, the maximum possible bytes will be +read from the file (but see **Notes** below). [%CFEngine_function_attributes(filename, maxbytes)%] @@ -28,8 +30,19 @@ Output: [%CFEngine_include_snippet(readfile.cf, #\+begin_src\s+example_output\s*, .*end_src)%] **Notes:** -- At the moment, only the first 4096 bytes of the file can be retrieved. -- To reliably read files located within /proc or /sys directories, + +* To reliably read files located within /proc or /sys directories, `maxsize` has to be set to `0`. -**History:** 4096 bytes limit and special `0` value were introduced in 3.6.0 +* At the moment, only 4095 bytes can fit into a string variable. This +limitation may be removed in the future. If this should happen, a +warning will be printed. + +* If you request more bytes than CFEngine can read into a string +variable (e.g. `999999999`), a warning will also be printed. + +* If either because you specified a large value, or you specified `0`, +more bytes are read than will fit in a string, the string is +truncated to the maximum. + +**History:** Warnings about the size limit and the special `0` value were introduced in 3.6.0