will exit after the first pass.
.TP
.BI \-t " test_pattern"
-Specify a test pattern. A value of -1 uses a random bit pattern.
-All other values are used to fill the test buffer.
+Specify a test pattern to be read (and written) to disk blocks. The
+.I test_pattern
+may either be a numeric value between 0 and ULONG_MAX-1 inclusive, or the word
+"random", which specifies that the block should be filled with a random
+bit pattern.
For read/write (\fB-w\fR) and non-destructive (\fB-n\fR) modes,
-multiple test patterns may be specified. For
-read-only mode only a single byte pattern may be used and it may not be
-the random value -1. Read-only testing with a pattern assumes that the
-same pattern has previously been written to the disk - if not, large
+one or more test patterns may be specified by specifiying the
+.B -t
+option for each test pattern desired. For
+read-only mode only a single pattern may be specified and it may not be
+"random". Read-only testing with a pattern assumes that the
+specified pattern has previously been written to the disk - if not, large
numbers of blocks will fail verification.
If multiple patterns
-are specified then all blocks will be tested with an earlier pattern
+are specified then all blocks will be tested with an one pattern
before proceeding to the next pattern.
.TP
.B \-n
static int force = 0; /* force check of mounted device */
static int t_flag = 0; /* number of test patterns */
static int t_max = 0; /* allocated test patterns */
-static long *t_patts = NULL; /* test patterns */
+static unsigned long *t_patts = NULL; /* test patterns */
#define T_INC 32
static void usage(void)
signal (SIGUSR2, SIG_DFL);
}
-static void pattern_fill(unsigned char *buffer, int pattern, size_t n)
+static void pattern_fill(unsigned char *buffer, unsigned long pattern,
+ size_t n)
{
int i, nb;
- unsigned char bpattern[4], *ptr;
+ unsigned char bpattern[sizeof(pattern)], *ptr;
- if (pattern == -1) {
+ if (pattern == ~0) {
for (ptr = buffer; ptr < buffer + n; ptr++) {
(*ptr) = random() % (1 << (8 * sizeof(char)));
}
if (i < 0)
i = nb;
}
- if (s_flag | v_flag)
- fprintf(stderr, _("Testing with pattern 0x%02x%02x%02x%02x: "),
- buffer[0], buffer[1], buffer[2], buffer[3]);
+ if (s_flag | v_flag) {
+ fprintf(stderr, _("Testing with pattern 0x"));
+ for (i = 0; i <= nb; i++)
+ fprintf(stderr, "%02x", buffer[i]);
+ fprintf(stderr, ": ");
+ }
}
}
unsigned long blocks_at_once)
{
char * buffer;
- const long patterns[] = {0xaa, 0x55, 0xff, 0x00};
- const long *pattern;
+ const unsigned long patterns[] = {0xaa, 0x55, 0xff, 0x00};
+ const unsigned long *pattern;
int nr_pattern, pat_idx;
unsigned int bb_count = 0;
{
char *blkbuf, *save_ptr, *test_ptr, *read_ptr;
int try, i;
- const long patterns[] = {-1};
- const long *pattern;
+ const unsigned long patterns[] = { ~0 };
+ const unsigned long *pattern;
int nr_pattern, pat_idx;
long got, used2, written, save_currently_testing;
struct saved_blk_record *test_record;
int passes_clean = 0;
int dev;
errcode_t errcode;
- long pattern;
+ unsigned long pattern;
unsigned int (*test_func)(int, unsigned long,
int, unsigned long,
unsigned long);
t_patts = t_patts_new;
t_max += T_INC;
}
- pattern = strtol(optarg, &tmp, 0);
- if (*tmp) {
- com_err(program_name, 0,
+ if (!strcmp(optarg, "r") || !strcmp(optarg,"random")) {
+ t_patts[t_flag++] = ~0;
+ } else {
+ pattern = strtoul(optarg, &tmp, 0);
+ if (*tmp) {
+ com_err(program_name, 0,
_("invalid test_pattern: %s\n"),
- optarg);
- exit(1);
+ optarg);
+ exit(1);
+ }
+ if (pattern == ~0)
+ pattern = 0xffff;
+ t_patts[t_flag++] = pattern;
}
- t_patts[t_flag++] = pattern;
break;
default:
usage();
"in read-only mode"));
exit(1);
}
- if (t_patts && (t_patts[0] == -1)) {
+ if (t_patts && (t_patts[0] == ~0)) {
com_err(program_name, 0,
_("Random test_pattern is not allowed "
"in read-only mode"));