From: Jens Axboe Date: Fri, 22 Aug 2014 19:02:02 +0000 (-0500) Subject: Add string support for buffer_pattern X-Git-Tag: fio-2.1.12~4 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=02975b649c986efbafdb76b3ddff998634610e3f;p=fio.git Add string support for buffer_pattern Signed-off-by: Jens Axboe --- diff --git a/HOWTO b/HOWTO index a0b89c80..73e58ff6 100644 --- 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 c61948bb..e3334bd2 100644 --- 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. diff --git a/options.c b/options.c index 5f4a8ec2..bc07885d 100644 --- 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);