Add string support for buffer_pattern
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/HOWTO b/HOWTO
index a0b89c8..73e58ff 100644
--- a/HOWTO
+++ b/HOWTO
@@ -569,6 +569,8 @@
If not set, the contents of io buffers is defined by the other
options related to buffer contents. The setting can be any
pattern of bytes, and can be prefixed with 0x for hex values.
+ It may also be a string, where the string must then be
+ wrapped with "".
nrfiles=int Number of files to use for this job. Defaults to 1.
diff --git a/fio.1 b/fio.1
index c61948b..e3334bd 100644
--- a/fio.1
+++ b/fio.1
@@ -478,7 +478,8 @@
If set, fio will fill the IO buffers with this pattern. If not set, the contents
of IO buffers is defined by the other options related to buffer contents. The
setting can be any pattern of bytes, and can be prefixed with 0x for hex
-values.
+values. It may also be a string, where the string must then be wrapped with
+"".
.TP
.BI nrfiles \fR=\fPint
Number of files to use for this job. Default: 1.
diff --git a/options.c b/options.c
index 5f4a8ec..bc07885 100644
--- a/options.c
+++ b/options.c
@@ -930,6 +930,29 @@
uint32_t pattern_length;
char *loc1, *loc2;
+ /*
+ * Check if it's a string input
+ */
+ loc1 = strchr(input, '\"');
+ if (loc1) {
+ do {
+ loc1++;
+ if (*loc1 == '\0' || *loc1 == '\"')
+ break;
+
+ pattern[i] = *loc1;
+ i++;
+ } while (i < max_size);
+
+ if (!i)
+ return 1;
+
+ goto fill;
+ }
+
+ /*
+ * No string, find out if it's decimal or hexidecimal
+ */
loc1 = strstr(input, "0x");
loc2 = strstr(input, "0X");
if (loc1 || loc2)
@@ -966,6 +989,7 @@
* Fill the pattern all the way to the end. This greatly reduces
* the number of memcpy's we have to do when verifying the IO.
*/
+fill:
pattern_length = i;
while (i > 1 && i * 2 <= max_size) {
memcpy(&pattern[i], &pattern[0], i);