dd.h revision 126667
11556Srgrimes/*-
21556Srgrimes * Copyright (c) 1991, 1993, 1994
31556Srgrimes *	The Regents of the University of California.  All rights reserved.
41556Srgrimes *
51556Srgrimes * This code is derived from software contributed to Berkeley by
61556Srgrimes * Keith Muller of the University of California, San Diego and Lance
71556Srgrimes * Visser of Convex Computer Corporation.
81556Srgrimes *
91556Srgrimes * Redistribution and use in source and binary forms, with or without
101556Srgrimes * modification, are permitted provided that the following conditions
111556Srgrimes * are met:
121556Srgrimes * 1. Redistributions of source code must retain the above copyright
131556Srgrimes *    notice, this list of conditions and the following disclaimer.
141556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
151556Srgrimes *    notice, this list of conditions and the following disclaimer in the
161556Srgrimes *    documentation and/or other materials provided with the distribution.
171556Srgrimes * 3. All advertising materials mentioning features or use of this software
181556Srgrimes *    must display the following acknowledgement:
191556Srgrimes *	This product includes software developed by the University of
201556Srgrimes *	California, Berkeley and its contributors.
211556Srgrimes * 4. Neither the name of the University nor the names of its contributors
221556Srgrimes *    may be used to endorse or promote products derived from this software
231556Srgrimes *    without specific prior written permission.
241556Srgrimes *
251556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
261556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
271556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
281556Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
291556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
301556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
311556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
321556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
331556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
341556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
351556Srgrimes * SUCH DAMAGE.
361556Srgrimes *
371556Srgrimes *	@(#)dd.h	8.3 (Berkeley) 4/2/94
3850471Speter * $FreeBSD: head/bin/dd/dd.h 126667 2004-03-05 19:35:51Z phk $
391556Srgrimes */
401556Srgrimes
411556Srgrimes/* Input/output stream state. */
421556Srgrimestypedef struct {
4351249Sgreen	u_char		*db;		/* buffer address */
4451249Sgreen	u_char		*dbp;		/* current buffer I/O address */
4551249Sgreen	/* XXX ssize_t? */
4651249Sgreen	size_t		dbcnt;		/* current buffer byte count */
4751249Sgreen	size_t		dbrcnt;		/* last read byte count */
4851249Sgreen	size_t		dbsz;		/* buffer size */
491556Srgrimes
501556Srgrimes#define	ISCHR		0x01		/* character device (warn on short) */
5162311Sgreen#define	ISPIPE		0x02		/* pipe-like (see position.c) */
5251249Sgreen#define	ISTAPE		0x04		/* tape */
5351212Sgreen#define	ISSEEK		0x08		/* valid to seek on */
5448802Sgreen#define	NOREAD		0x10		/* not readable */
5562311Sgreen#define	ISTRUNC		0x20		/* valid to ftruncate() */
5651249Sgreen	u_int		flags;
571556Srgrimes
5862311Sgreen	const char 	*name;		/* name */
5951249Sgreen	int		fd;		/* file descriptor */
6051249Sgreen	off_t		offset;		/* # of blocks to skip */
611556Srgrimes
621556Srgrimes} IO;
631556Srgrimes
641556Srgrimestypedef struct {
65111629Smarkm	uintmax_t	in_full;	/* # of full input blocks */
66111629Smarkm	uintmax_t	in_part;	/* # of partial input blocks */
67111629Smarkm	uintmax_t	out_full;	/* # of full output blocks */
68111629Smarkm	uintmax_t	out_part;	/* # of partial output blocks */
69111629Smarkm	uintmax_t	trunc;		/* # of truncated records */
70111629Smarkm	uintmax_t	swab;		/* # of odd-length swab blocks */
71111629Smarkm	uintmax_t	bytes;		/* # of bytes written */
7251249Sgreen	double		start; 			/* start time of dd */
731556Srgrimes} STAT;
741556Srgrimes
751556Srgrimes/* Flags (in ddflags). */
761556Srgrimes#define	C_ASCII		0x00001
771556Srgrimes#define	C_BLOCK		0x00002
781556Srgrimes#define	C_BS		0x00004
791556Srgrimes#define	C_CBS		0x00008
801556Srgrimes#define	C_COUNT		0x00010
811556Srgrimes#define	C_EBCDIC	0x00020
821556Srgrimes#define	C_FILES		0x00040
831556Srgrimes#define	C_IBS		0x00080
841556Srgrimes#define	C_IF		0x00100
851556Srgrimes#define	C_LCASE		0x00200
861556Srgrimes#define	C_NOERROR	0x00400
871556Srgrimes#define	C_NOTRUNC	0x00800
881556Srgrimes#define	C_OBS		0x01000
891556Srgrimes#define	C_OF		0x02000
901556Srgrimes#define	C_SEEK		0x04000
911556Srgrimes#define	C_SKIP		0x08000
921556Srgrimes#define	C_SWAB		0x10000
931556Srgrimes#define	C_SYNC		0x20000
941556Srgrimes#define	C_UCASE		0x40000
951556Srgrimes#define	C_UNBLOCK	0x80000
961556Srgrimes#define	C_OSYNC		0x100000
9730312Sjoerg#define	C_SPARSE	0x200000
98126667Sphk#define C_PAREVEN	0x400000
99126667Sphk#define C_PARODD	0x800000
100126667Sphk#define C_PARSET	0x1000000
101126667Sphk#define C_PARNONE	0x2000000
102126667Sphk
103126667Sphk#define C_PARITY	(C_PAREVEN|C_PARODD|C_PARSET|C_PARNONE)
104