Add string support for buffer_pattern
authorJens Axboe <axboe@fb.com>
Fri, 22 Aug 2014 19:02:02 +0000 (14:02 -0500)
committerJens Axboe <axboe@fb.com>
Fri, 22 Aug 2014 19:02:02 +0000 (14:02 -0500)
Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
fio.1
options.c

diff --git a/HOWTO b/HOWTO
index a0b89c8071d15b45aaef71222611625e38022178..73e58ff695c3384df30094d6c15ebe9ed615460f 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -569,6 +569,8 @@ buffer_pattern=str  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.
+               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 c61948bb52814a2a6bac248c5db0063406225a48..e3334bd2b4de0a6b8850d669bce8932a48409982 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -478,7 +478,8 @@ size, fio can alternate random and zeroed data throughout the IO buffer.
 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.
index 5f4a8ec2923040ed35c89aaecacb906867cda47d..bc07885d757259b19313f22eaf1a54c8f9809a4f 100644 (file)
--- a/options.c
+++ b/options.c
@@ -930,6 +930,29 @@ static int pattern_cb(char *pattern, unsigned int max_size,
        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 @@ static int pattern_cb(char *pattern, unsigned int max_size,
         * 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);