📄 dt.c
字号:
* July 22, 1995 by Robin Miller. * Add additional checking on "pattern=string" to avoid ambiguity * with 4-byte hex data pattern strings... which is misleading). * * July 15, 1995 by Robin Miller. * Add "oncerr=action" option to control child process * error processing. * * July 7, 1995 by Robin Miller. * Add "dlimit=value" option to override default dump limit. * * July 6, 1995 by Robin Miller. * Enable dumping of data bytes on compare errors by default, * since this program is used mainly as a diagnostic tool, and * we now limit the number of bytes dumped. * * November 5, 1994 by Robin Miller. * Don't set SIGCHLD signal to SIG_IGN (set to SIG_DFL) or else * waitpid() won't detect any child processes (OSF R1.3 and QNX). * * September 23, 1994 by Robin Miller. * Make changes necessary to build on QNX 4.21 release. This * required changing O_DSYNCH to O_DSYNC, and O_FSYNCH to O_SYNC. * * November 11, 1993 by Robin Miller. * Removed code which was inadvertantly disabling data compares * when there was no output file and verify was disabled. This * caused data comparisions to be disabled for terminal devices, * now that the code has been rewritten/restructured (shit!!!). * * October 31, 1993 by Robin Miller. * Enhance device type setup and honor user specified device type. * * October 28, 1993 by Robin Miller. * Correct problem during loopback testing, where the device info * structure fd's were not marked closed due to two places where * close() was called directly (oops, missed a couple changes). * After forking, display which process is the reader and writer. * * October 11, 1993 by Robin Miller. * Conditionalize SunOS code (4.1.2 used) to avoid using strerror() * function for obtaining error messages (return to perror() method). * * October 7, 1993 by Robin Miller. * Add appropriate casting to block size checking, use ssize_t to * prevent negative block sizes which don't work with read & write * system calls (even though the count arg is declared as size_t). * * September 16, 1993 by Robin Miller. * Properly report write pass count when read verify is disabled. * Only update data pattern when writing files or loopback enabled * when multiple passes specified (pattern cannot change for reads). * Support "enable=loop" to enable loopback operation, rather than * requiring both the same input & output devices (need only one). * Added "oflags={append,sync}" for DEC OSF/1 systems (write opts). * * September 15, 1993 by Robin Miller. * Added additional check for FIFO's prior to opening the device * since O_NONBLOCK flag must be set to keep open() from blocking. * * September 8, 1993 by Robin Miller. * Moved generic test functions into file dtgen.c. * * September 7, 1993 by Robin Miller. * Moved tty specific code into dttty.c. This code is dispatched * to automatically after being setup in the device info structure. * * September 4, 1993 by Robin Miller. * Lots of restructuring & code cleanup. Nearly all testing is * now appropriately parameterized (helps speed & new tests). * * September 3, 1993 by Robin Miller. * Dispatch to test functions via function lookup table in * preparation for device specific tests. * * September 1, 1993 by Robin Miller. * Added "min=value", "max=value", and "incr=value" options for * testing variable length records (mainly for tape devices). * * August 31, 1993 by Robin Miller. * Added "align=rotate" option to rotate the starting data buffer * address through sizeof(ptr) to force unaligned buffer accesses. * This feature tests special handling of unaligned DMA addresses. * Added "pattern=incr" option to use incrementing data pattern. * * August 27, 1993 by Robin MIller. * Added support for DEC OSF/1 POSIX Asynchronous I/O (AIO). * * August 20, 1993 by Robin Miller. * Added handling of reading & writing multiple tape files. * * August 18, 1993 by Robin Miller. * Added "step=" option to specify a step offset for seeks. * This is the number of bytes stepped after an I/O request. * * August 17, 1993 by Robin Miller. * Added reporting of start & end times, time of errors, and * added "runtime=" option to specify how long to run. * * August 13, 1993 by Robin Miller. * Added alternate data patterns to use with multiple passes. * * August 5, 1993 by Robin Miller. * Added "files=value" option for processing tape files. * * August 3, 1993 by Robin Miller. * Added "procs=value" option to create multiple processes. * * September 19, 1992 by Robin Miller. * Initialize flush_flag to TRUE so flushing of tty I/O queues * gets done by default to discard any left over junk. * * September 18, 1992 by Robin Miller. * Added calls to save & restore terminal characteristics. * * September 17, 1992 by Robin Miller. * Added parsing for "pattern=string" to allow ASCII string. * * September 12, 1992 by Robin Miller. * Ensure the stderr stream is fully buffered, so the total time * is not affected by flushing previous statistics. * * September 11, 1992 by Robin Miller. * Added "oflags={cache,dsync,fsync,temp}" options to allow testing * the affect of these open flags on QNX systems. * * September 10, 1992 by Robin Miller. * Added parsing of MARK & SPACE parity for QNX Operating System. * * September 9, 1992 by Robin Miller. * Allow loopback to same tty port (avoid exclusive open). * * September 5, 1992 by Robin Miller. * Initial port to QNX 4.1 Operating System. * * September 3, 1992 by Robin Miller. * Make changes necessary to remove BSD dependencies. * * August 19, 1992 by Robin Miller. * Added support for testing tty modem control. * * May 25, 1992 by Robin Miller. * Don't set exclusive open mode for terminal device if debug is * enabled, so "stty -a" can be done on terminal under test. * * May 22, 1992 by Robin Miller. * Control / force kernel address data exception via flag. * Added option "enable=ade" (address data exception). * * April 24, 1992 by Robin Miller. * Inform user that either a record count or a data limit must be * specified. Added flags to determine if we are reading stdin or * writing to stdout streams. * * March 11, 1992 by Robin Miller. * Changes necessary for port to 64-bit Alpha architecture. * * October 16, 1990 by Robin Miller. * Added "align=offset" option to align memory buffers at a specific * offset. The default is page aligned. * * October 9, 1990 by Robin Miller. * Added "hz=ticks" option to allow the ticks per second value to * be specified. On VAX systems, this is consistent (100), but on * MIPS systems it various and is setup at boot time in the machine * dependent code. * * August 21, 1990 by Robin Miller. * Changed exit status so scripts can detect and handle errors * based on the exit code. If not success, fatal error, or end * of file/tape, the exit code is the error number (errno). * * August 21, 1990 by Robin Miller. * Added "position=offset" option to position to specified offset * before starting test. * * August 16, 1990 by Robin Miller. * Added "enable=coredump" option so if exiting with error status, * we'll generate a core dump for analysis purposes. * * August 8, 1990 by Robin Miller. * Changed malloc() to valloc() to align buffer on page boundry. * On some archetectures, this results on better performance to * raw devices since the DMA is done directly to the users' buffer. * * August 2, 1990 by Robin Miller. * Added "pf=file" to specify a pattern file to use. In this * case, the contents of the specified file are used for the * data pattern. * * April 11, 1990 by Robin Miller. * Added "enable=mmap" option to enable memory mapped I/O. * * March 22, 1990 by Robin Miller. * Added "dispose={delete|keep}" option to control deleting the * output file at the end of testing. "delete" is the default * action, to avoid leaving test files around. * * Novemeber 9, 1989 by Robin Miller. * Add additional delay commands (cdelay=, rdelay=, wdelay=) to * help with testing and debugging various devices. These aren't * normally enabled and don't appear in the help section. * * Novemeber 6, 1989 by Robin Miller. * Allow start delay (sdelay=) and end delay (edelay=) to be used * with any device, not just terminals. The parallel output device * needs an end delay to allow the parallel input device to reopen * during multiple passes (can't disable cycle request). * * November 3, 1989 by Robin Miller. * Change open mode for output files from read/write (O_RDWR) to * write only (O_WRONLY) so write only devices can be tested. * * October 16, 1989 by Robin Miller. * Made flushing of input queue before testing optional via * the "enable=flush" command. This caused a timing problem * where occasionally the writer started before the reader. * * October 4, 1989 by Robin Miller. * Added fsync() system call to force in-core buffers to disk * before reporting statistics after writing the file. * * September 27, 1989 by Robin Miller. * Display statistics at end of each read/write pass by default. * Added enable/disable=pstats to control end of pass statistics. * Added enable/disable=compare to control data comparisions. * * September 18, 1989 by Robin Miller. * Allow both an input and an output device to be specified. * This was done mainly for terminal devices so a child could * be forked to allow proper synchronization. * * July 25, 1989 by Robin Miller. * Added support for testing terminal ports. New options are: * speed=, timeout=, parity=, flow=, sdelay=, edelay= * * January 25, 1989 by Robin Miller. * Added reporting of pass statistics if debugging is enabled * so write/read elapsed times can be determined. * * December 8, 1988 by Robin Miller. * Added catching of software terminate signal (SIGTERM) so the * final statistics will be displayed before exiting. */#if defined(ultrix) || defined(sun)extern int sys_nerr;extern char *sys_errlist[];#endif /* defined(sun) *//* * Forward References: */static u_long number(int base); /* Numeric conversion function. */static large_t large_number(int base); /* Large numeric conversions. */void parse_args(int argc, char **argv);static time_t time_value(void); /* Time conversion function. *//* * Variable Declarations: */#if !defined(AIO)int aio_bufs = 0; /* Normally declared in dtaio.c, but for parsing. */#endif /* !defined(AIO) */#if defined(MUNSA)bool munsa_flag = FALSE; /* if TRUE enable MUNSA features*/dlm_lock_mode_t munsa_lock_type = DLM_NLMODE; /* default munsa lock type*/dlm_lock_mode_t input_munsa_lock_type = DLM_PRMODE; /* lock for input file*/dlm_lock_mode_t output_munsa_lock_type = DLM_PWMODE; /* lock for output file*/char *resnam;int resnlen, i;dlm_lkid_t lkid;dlm_status_t l_stat;dlm_nsp_t nsp;#endif /* defined(MUNSA) */u_int32 pattern = DEFAULT_PATTERN; /* Default data pattern. */bool user_pattern = FALSE; /* Flags user specified pattern */bool unique_pattern = TRUE; /* Unique pattern per process. */char *pattern_string; /* Pointer to pattern string. */char *prefix_string; /* User defined prefix string. */bool aio_flag = FALSE; /* Asynchronous I/O (AIO) flag. */int align_offset = 0; /* Align buffer at this offset. */#if defined(TTY)speed_t baud_rate; /* The user selected baud rate. */#endif /* defined(TTY) */size_t block_size = BLOCK_SIZE; /* Default block size to use. */size_t data_size; /* Data buffer size + pad bytes */size_t dump_limit = 64; /* The dump buffer data limit. */u_int32 device_size = 0; /* Default device block size. */pid_t child_pid; /* For the child process ID. */bool bypass_flag = FALSE; /* Bypass (some) sanity checks. */bool cerrors_flag = TRUE; /* Report device close errors. */bool compare_flag = TRUE; /* Controls data comparisions. */bool core_dump = FALSE; /* Generate core dump on errors */bool debug_flag = FALSE; /* Enable debug output flag. */bool Debug_flag = FALSE; /* Verbose debug output flag. */bool eDebugFlag = FALSE; /* End of file debug flag. */bool rDebugFlag = FALSE; /* Random (seek) debug flag. */bool dump_flag = TRUE; /* Dump data buffer on errors. */#if defined(EEI)bool eei_flag = TRUE; /* Extended Error Information. */bool eei_resets = FALSE; /* Handle device reset errors. */#endif /* defined(EEI) */v_bool end_of_file = FALSE; /* End of file detected. */#if defined(_NT_SOURCE)/* * This workaround is being added for our Tcl/Tk test scripts. * The Windows TclX wait{} procedure, isn't returning exit status! */bool eof_status = FALSE; /* Controls EOF exit status. */#else /* !defined(_NT_SOURCE) */bool eof_status = TRUE; /* Controls EOF exit status. */#endif /* defined(_NT_SOURCE) */vu_long error_count; /* Number of errors detected. */u_long error_limit = 1; /* Number of errors tolerated. */int exit_status = SUCCESS; /* Normal success exit status. */u_long file_limit; /* # of tape files to process. */bool forked_flag = FALSE; /* Forked child process flag. */bool fsync_flag = UNINITIALIZED; /* fsync() after writes flag. */off_t file_position; /* File position to lseek to. */off_t last_position; /* Last position lseeked to. */off_t step_offset; /* Step offset for disk seeks. */bool flush_flag = TRUE; /* Flush tty input/output queue */bool keep_existing = TRUE; /* Don't delete existing files. */bool header_flag = TRUE; /* The log file header flag. */bool hazard_flag = FALSE; /* Emit Hazard RPCLOGn: prefix. */bool user_incr = FALSE; /* User specified incr count. */bool user_min = FALSE; /* User specified min size. */bool user_max = FALSE; /* User specified max size. */size_t incr_count; /* Record increment byte count. */size_t min_size; /* The minimum record size. */size_t max_size; /* The maximum record size. */bool lbdata_flag = FALSE; /* Logical block data flag. */u_int32 lbdata_addr = 0; /* Starting logical block addr. */size_t lbdata_size = 0; /* Logical block data size. */bool user_lbdata = FALSE; /* User specified starting lba. */bool user_lbsize = FALSE; /* User specified lbdata size. */bool user_position = FALSE; /* User specified file position.*/bool incr_pattern = FALSE; /* Incrementing data pattern. */bool iot_pattern = FALSE; /* IOT test pattern selected. */bool logdiag_flag = FALSE; /* Log diagnostic messages. */bool loopback = FALSE; /* Loopback to the same device. */bool micro_flag = FALSE; /* Controls micro-second delay. */bool mmap_flag = FALSE; /* Do memory mapped file I/O. */#if defined(TTY)bool modem_flag = FALSE; /* Testing tty modem control. */#endif /* defined(TTY) */bool media_changed = FALSE; /* Shows when media changed. */bool multi_flag = FALSE; /* Multi-volume media flag. */v_int multi_volume = 1; /* Multi-volume media count. */int open_flags = 0; /* Common file open flags. */int wopen_flags = 0; /* Additional write open flags. */int ropen_mode = O_RDONLY; /* The read open mode to use. */int wopen_mode = O_WRONLY; /* The write open mode to use. */bool pad_check = TRUE; /* Check data buffer pad bytes. */bool spad_check = FALSE; /* Check short record pad bytes.*/u_long pass_count; /* Number of passes completed. */u_long pass_limit = 1UL; /* Default number of passes. */u_long skip_count; /* # of input record to skip. */u_long seek_count; /* # of output records to seek. */large_t record_limit; /* Max # of records to process. */vu_long records_processed; /* # of full records processed. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -