-unsigned long fill_random_buf_percentage(struct frand_state *fs, void *buf,
- unsigned int percentage,
- unsigned int segment, unsigned int len)
+void fill_pattern(void *p, unsigned int len, char *pattern,
+ unsigned int pattern_bytes)
+{
+ switch (pattern_bytes) {
+ case 0:
+ assert(0);
+ break;
+ case 1:
+ memset(p, pattern[0], len);
+ break;
+ default: {
+ unsigned int i = 0, size = 0;
+ unsigned char *b = p;
+
+ while (i < len) {
+ size = pattern_bytes;
+ if (size > (len - i))
+ size = len - i;
+ memcpy(b+i, pattern, size);
+ i += size;
+ }
+ break;
+ }
+ }
+}
+
+void __fill_random_buf_percentage(unsigned long seed, void *buf,
+ unsigned int percentage,
+ unsigned int segment, unsigned int len,
+ char *pattern, unsigned int pbytes)