📄 dt.c
字号:
if (pattern_file) { process_pfile (&pfd, pattern_file, O_RDONLY); } if (min_size && (max_size <= min_size)) { LogMsg (efp, logLevelCrit, 0, "Please specify max count > min count for record sizes.\n"); exit (FATAL_ERROR); } /* * Verify counts are large enough, to avoid false compare errors. */#if 0 if ( !bypass_flag && (iot_pattern || lbdata_flag) && ((block_size < sizeof(u_int32)) || (min_size && (min_size <= sizeof(u_int32)))) ) { LogMsg (efp, logLevelCrit, 0, "Please specify block sizes > %d for IOT or Lbdata options!\n", sizeof(u_int32)); exit (FATAL_ERROR); }#endif if ( (iot_pattern || lbdata_flag) && (block_size < lbdata_size) ) { LogMsg (efp, logLevelCrit, 0, "Please specify a block size >= %u (lbdata size) for IOT or Lbdata options!\n", lbdata_size); exit (FATAL_ERROR); } if ( ((io_mode == COPY_MODE) || (io_mode == VERIFY_MODE)) && (iot_pattern || lbdata_flag) ) { LogMsg (efp, logLevelCrit, 0, "IOT and Lbdata options disallowed with Copy/Verify options!\n"); exit (FATAL_ERROR); } if (iot_pattern) { size_t size = block_size; u_char *buffer = (u_char *) myalloc(size, 0); setup_pattern (buffer, size); pattern_string = "IOT Pattern"; /* IOT takes precedence! */ lbdata_flag = FALSE; user_lbdata = FALSE; } /* * Setup the pattern as a pattern string, so non-modulo * sizeof(u_int) read counts will data compare properly. */ if (!pattern_buffer) { size_t size = sizeof(u_int32); u_char *buffer = (u_char *) Malloc (size); copy_pattern (pattern, buffer); setup_pattern (buffer, size); }#if defined(TTY) /* * The following check was added for tty loopback to same port. * [ A future version may extend this support to other devices. ] */ if (input_file && output_file) { if (strcmp (input_file, output_file) == 0) { loopback = TRUE; /* Loopback to the same file. */ } } else if (loopback) { if (!input_file && output_file) input_file = output_file; if (input_file && !output_file) output_file = input_file; }#endif /* defined(TTY) */ /* * Setup the initial device information & validate options. */ if (input_file) { dip = setup_device_info (input_file, input_dtype); active_dinfo = input_dinfo = dip; dip->di_mode = READ_MODE; dip->di_ftype = INPUT_FILE; status = (*dip->di_funcs->tf_validate_opts)(dip); if (status == FAILURE) exit (FATAL_ERROR); } if (output_file) { dip = setup_device_info (output_file, output_dtype); active_dinfo = output_dinfo = dip; dip->di_mode = WRITE_MODE; dip->di_ftype = OUTPUT_FILE; status = (*dip->di_funcs->tf_validate_opts)(dip); if (status == FAILURE) exit (FATAL_ERROR); /* * The following problem was resolved by not switching patterns * when multiple processes are selected. So, this will go... */#if 0 /* * Sanity Check: Major source of problem reports due to folks * using multiple processes with multiple passes, and subsequent * passes overwriting the previous data pattern! */ if ( (pass_limit > 1) && (num_procs > 1) && !user_pattern && dip->di_random_access ) { LogMsg (ofp, logLevelWarn, 0, "Warning: Multiple passes with multiple processes can cause unpredictable\n"); LogMsg (ofp, logLevelWarn, 0, "results due to process scheduling, since each pass uses a different pattern!\n"); }#endif }#if defined(sun) && defined(TTY) /* * Soft carrier existed on the Sun/386i (Roadrunner) system. * Setting O_NDELAY was necessary to open the terminal line. * * Normally, O_NDELAY must NOT be set, otherwise the terminal * driver returns EWOULDBLOCK on reads if no data is available. * * Note: Without O_NDELAY, the open will hang on modem lines * (-CLOCAL) if carrier is not asserted. */ if (ttyport_flag) { open_flags = O_NDELAY; /* Incase no soft carrier. */ }#endif /* defined(sun) && defined(TTY) */ /* * Do multiple slices processing. */ if (num_slices) { if (input_file && output_file) { LogMsg (efp, logLevelCrit, 0, "Please specify only an input or output file, not both!\n"); exit (FATAL_ERROR); } /* * Create multiple slices (if requested). */ active_dinfo = dip = (input_file) ? input_dinfo : output_dinfo; if (!dip->di_random_access) { LogMsg (efp, logLevelCrit, 0, "Multiple slices is only supported on random access devices!\n"); exit (FATAL_ERROR); } if ((status = FindCapacity (dip)) == FAILURE) { exit (FATAL_ERROR); } /* * The remaining work is done when starting the processes. */ if (slice_num) { init_slice(active_dinfo, slice_num); num_slices = 0; /* Operate on a single slice. */ } else { if ( start_slices() ) { await_procs(); exit (exit_status); } } } /* * Create multiple processes (if requested). */ if (num_procs && !loopback && !ttyport_flag) { if ( start_procs() ) { await_procs(); exit (exit_status); } } /* * Open device / Setup system / device specific test information. */ if (input_file) { int open_mode = (ropen_mode | open_flags); dip = active_dinfo = input_dinfo; if ((*dip->di_funcs->tf_open)(dip, open_mode) == FAILURE) { exit (exit_status); } system_device_info (dip); input_dtype = dip->di_dtype; status = (*dip->di_funcs->tf_validate_opts)(dip); if (status == FAILURE) exit (FATAL_ERROR);#if defined(MUNSA) if (munsa_flag) { /* first we need to join a namespace */ l_stat = dlm_nsjoin( getuid(), &nsp, DLM_USER); if ((l_stat != DLM_SUCCESS) && (l_stat != DLM_ATTACHED)) { Fprintf ("Can't join namespace\n"); dlm_error(0, l_stat); } resnam = input_file; /* now let DLM know what signal to use for blocking routines */ dlm_set_signal(SIGIO, &i); resnlen = strlen(resnam); if (debug_flag) { Printf ("dlm_set_signal: i %d\n", i); Printf ("resnam %s\n", resnam); Printf ("grab a NL mode lock\n"); } l_stat = dlm_lock(nsp, (uchar_t *)resnam, resnlen, 0, &lkid, DLM_NLMODE, NULL, DLM_SYNCSTS, 0, 0, 0, 0); /* NL mode better be granted SYNC status */ if (l_stat != DLM_SYNCH) { if (debug_flag) { Fprintf ("dlm_lock failed\n"); } dlm_error(&lkid, l_stat); } } /* end if(munsa_flag)... */#endif /* defined(MUNSA) */ /* * If disk device and random I/O selected, attempt to get * device / partition capacity to limit random I/O seeks. */ if ( user_capacity || ( ((io_dir == REVERSE) || (io_type == RANDOM_IO)) && (dip->di_random_access && !num_slices) ) ) { if ((status = FindCapacity (dip)) == FAILURE) { exit (exit_status); } } if (!record_limit) { record_limit = INFINITY; /* Read until EOF on reads. */ } } /* * Process the output device/file. */ if (output_file) { int open_mode; dip = active_dinfo = output_dinfo; /* * If a skip count was specified, open output file for R/W, * since skips are accomplished via read()'s. (for pelle) */ if (skip_count || raw_flag) { open_mode = (O_RDWR | wopen_flags | open_flags); } else { open_mode = (wopen_mode | wopen_flags | open_flags); } /* * Don't create files in the /dev directory (presume the file * should exist instead of creating file & misleading user). */ if ( (NEL (output_file, DEV_PREFIX, DEV_LEN)) && (NEL (output_file, ADEV_PREFIX, ADEV_LEN)) ) { open_mode |= O_CREAT; /* For creating test files. */ } /* * If verify mode, the output device is open for reads. */ if (io_mode == VERIFY_MODE) { open_mode = (ropen_mode | open_flags); dip->di_mode = READ_MODE; } if ((*dip->di_funcs->tf_open)(dip, open_mode) == FAILURE) { exit (exit_status); }#if defined(MUNSA) if (munsa_flag) { /* first we need to join a namespace */ l_stat = dlm_nsjoin( getuid(), &nsp, DLM_USER); if ((l_stat != DLM_SUCCESS) && (l_stat != DLM_ATTACHED)) { Fprintf ("Can't join namespace\n"); dlm_error(0, l_stat); } resnam = output_file; /* now let DLM know what signal to use for blocking routines */ dlm_set_signal(SIGIO, &i); /* do we need this ????? */ resnlen = strlen(resnam); if (debug_flag) { Printf ("dlm_set_signal: i %d\n", i); Printf ("resnam %s\n", resnam); Printf ("grab a NL mode lock\n"); } l_stat = dlm_lock(nsp, (uchar_t *)resnam, resnlen, 0, &lkid, DLM_NLMODE, NULL, DLM_SYNCSTS, 0, 0, 0, 0); /* NL mode better be granted SYNC status */ if (l_stat != DLM_SYNCH) { Fprintf ("dlm_lock failed\n"); dlm_error(&lkid, l_stat); } } /* end if (munsa_flag)... */#endif /* defined(MUNSA) */ system_device_info (dip); output_dtype = dip->di_dtype; open_flags &= ~O_CREAT; /* Only create on first open. */ status = (*dip->di_funcs->tf_validate_opts)(dip); if (status == FAILURE) exit (FATAL_ERROR); /* * If disk device and random I/O selected, attempt to get * device / partition capacity to limit random I/O seeks. */ if ( user_capacity || ( ((io_dir == REVERSE) || (io_type == RANDOM_IO)) && (dip->di_random_access && !num_slices) ) ) { if ((status = FindCapacity (dip)) == FAILURE) { exit (exit_status); } } /* * For disks and tapes, default writing until EOF is reached. */ if ( !record_limit && ((dip->di_dtype->dt_dtype == DT_DISK) || (dip->di_dtype->dt_dtype == DT_BLOCK) || (dip->di_dtype->dt_dtype == DT_TAPE)) ) { record_limit = INFINITY; } } /* * Set the default lbdata size, if not setup by the system * dependent functions above. Delaying this check to this * point allows the device sector size to be setup, instead * of forcing it to 512 byte blocks. At least this is true * on Tru64 Unix, where this disk information is available. */ if (!lbdata_size) lbdata_size = BLOCK_SIZE; /* * This is to catch me (dah!) as much as anyone else :-) */ if ( (rdata_limit || random_align) && ((io_dir != REVERSE) && (io_type != RANDOM_IO)) ) { Printf ("Warning, random options have no effect without iotype=random!\n"); } /* * If random I/O was selected, and a data limit isn't available, * inform the user we need one, and don't allow testing. */ if (rdata_limit == 0UL) rdata_limit = data_limit; if ( (rdata_limit == 0) && (io_type == RANDOM_IO) ) { LogMsg (efp, logLevelCrit, 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -