Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / cksum.1
blob5884bf210584cdbf2fca2528bfd878b05f687ff1
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Portions Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
45 .\"
46 .TH CKSUM 1 "Feb 1, 1995"
47 .SH NAME
48 cksum \- write file checksums and sizes
49 .SH SYNOPSIS
50 .LP
51 .nf
52 \fBcksum\fR [\fIfile\fR]...
53 .fi
55 .SH DESCRIPTION
56 .sp
57 .LP
58 The \fBcksum\fR command calculates and writes to standard output a cyclic
59 redundancy check (CRC) for each input file, and also writes to standard output
60 the number of octets in each file.
61 .sp
62 .LP
63 For each file processed successfully, \fBcksum\fR will write in the following
64 format:
65 .sp
66 .LP
67 \fB"%u %d %s\en"\fR <\fIchecksum\fR>, <\fI# of octets\fR>, <\fIpath name\fR>
68 .sp
69 .LP
70 If no \fIfile\fR operand was specified, the path name and its leading space
71 will be omitted.
72 .sp
73 .LP
74 The CRC used is based on the polynomial used for CRC error checking in the
75 referenced Ethernet standard.
76 .sp
77 .LP
78 The encoding for the CRC checksum is defined by the generating polynomial:
79 .sp
80 .LP
81 \fIG\|\fR(\fIx\fR) = \fIx\fR^32 + \fIx\fR^26 + \fIx\fR^23 + \fIx\fR^22 +
82 \fIx\fR^16 + \fIx\fR^12 + \fIx\fR^11 + \fIx\fR^10 + \fIx\fR^8 + \fIx\fR^7 +
83 \fIx\fR^5 + \fIx\fR^4 + \fIx\fR^2 + \fIx\fR + 1
84 .sp
85 .LP
86 Mathematically, the CRC value corresponding to a given file is defined by the
87 following procedure:
88 .RS +4
89 .TP
91 The \fIn\fR bits to be evaluated are considered to be the coefficients of a
92 mod 2 polynomial \fIM\fR(\fIx\fR) of degree \fIn\fR\(mi\fI1.\fR These \fIn\fR
93 bits are the bits from the file, with the most significant bit being the most
94 significant bit of the first octet of the file and the last bit being the least
95 significant bit of the last octet, padded with zero bits (if necessary) to
96 achieve an integral number of octets, followed by one or more octets
97 representing the length of the file as a binary value, least significant octet
98 first. The smallest number of octets capable of representing this integer is
99 used.
101 .RS +4
104 \fIM\fR(\fIx\fR) is multiplied by \fIx\fR ^\fI32\fR (that is, shifted left
105 32 bits) and divided by \fIG\fR(\fIx\fR) using mod 2 division, producing a
106 remainder \fIR\fR(\fIx\fR) of degree \(<= 31.
108 .RS +4
111 The coefficients of \fIR\fR(\fIx\fR) are considered to be a 32-bit sequence.
113 .RS +4
116 The bit sequence is complemented and the result is the CRC.
118 .SH OPERANDS
121 The following operand is supported:
123 .ne 2
125 \fB\fIfile\fR\fR
127 .RS 8n
128 A path name of a file to be checked. If no \fIfile\fR operands are specified,
129 the standard input is used.
132 .SH USAGE
135 The \fBcksum\fR command is typically used to quickly compare a suspect file
136 against a trusted version of the same, such as to ensure that files transmitted
137 over noisy media arrive intact. However, this comparison cannot be considered
138 cryptographically secure. The chances of a damaged file producing the same CRC
139 as the original are astronomically small; deliberate deception is difficult,
140 but probably not impossible.
143 Although input files to \fBcksum\fR can be any type, the results need not be
144 what would be expected on character special device files. Since this document
145 does not specify the block size used when doing input, checksums of character
146 special files need not process all of the data in those files.
149 The algorithm is expressed in terms of a bitstream divided into octets. If a
150 file is transmitted between two systems and undergoes any data transformation
151 (such as moving 8-bit characters into 9-bit bytes or changing "Little Endian"
152 byte ordering to "Big Endian"), identical CRC values cannot be expected.
153 Implementations performing such transformations may extend \fBcksum\fR to
154 handle such situations.
155 .SH ENVIRONMENT VARIABLES
158 See \fBenviron\fR(5) for descriptions of the following environment variables
159 that affect the execution of \fBcksum\fR: \fBLANG\fR, \fBLC_ALL\fR,
160 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
161 .SH EXIT STATUS
164 The following exit values are returned:
166 .ne 2
168 \fB\fB0\fR\fR
170 .RS 6n
171 All files were processed successfully.
175 .ne 2
177 \fB\fB>0\fR\fR
179 .RS 6n
180 An error occurred.
183 .SH ATTRIBUTES
186 See \fBattributes\fR(5) for descriptions of the following attributes:
191 box;
192 c | c
193 l | l .
194 ATTRIBUTE TYPE  ATTRIBUTE VALUE
196 Interface Stability     Standard
199 .SH SEE ALSO
202 \fBdigest\fR(1), \fBsum\fR(1), \fBbart\fR(8), \fBattributes\fR(5),
203 \fBenviron\fR(5), \fBstandards\fR(5)