chiark / gitweb /
debian/changelog: Prepare for next release.
[rsync-backup] / fshash.1
1 .ie t .ds o \(bu
2 .el .ds o o
3 .de hP
4 .IP
5 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
6 ..
7 .TH fshash 1 "8 October 2012" rsync-backup
8 .SH SYNOPSIS
9 .B fshash
10 .RB [ \-a ]
11 .RB [ \-c
12 .IR cache ]
13 .RB [ \-f
14 .IR format ]
15 .RB [ \-C
16 .IR version ]
17 .RB [ \-H
18 .IR hash ]
19 .RI [ file
20 \&...]
21 .br
22 .B fshash
23 .RB \-u
24 .B \-c
25 .I cache
26 .RB [ \-H
27 .IR hash ]
28 .RI [ dir ]
29 .SH DESCRIPTION
30 The
31 .B fshash
32 program generates digests of filesystems.  It's similar in concept to
33 (but somewhat different from) Ian Jackson's
34 .BR summer (1)
35 tool.
36 .PP
37 The idea is to capture everything interesting about a filesystem in a
38 file with the following properties:
39 .TP
40 .I Completeness
41 The digest file describes everything `interesting' about the filesystem,
42 such that two filesystems which are interestingly different will have
43 distinct digests.
44 .TP
45 .I Canonicalness
46 If two filesystems aren't different in any interesting way, then their
47 digests should be identical.
48 .TP
49 .I Readability
50 Given two subtly different filesystems, it's easy for a human equipped
51 with digests for them and
52 .BR diff (1)
53 to work out what the differences actually are.
54 .SS Command-line processing
55 The following command-line arguments are accepted.
56 .TP
57 .B \-h, \-\-help
58 Show a summary of the command-line syntax, and exit successfully.
59 .TP
60 .B \-\-version
61 Show the program's version number, and exit successfully.
62 .TP
63 .B \-a, \-\-all
64 Clear the cache of information about all files except those processed in
65 this run.
66 .TP
67 .B \-c, \-\-cache=\fIfile
68 Keep a cache of file hashes in the
69 .IR file .
70 The cache is keyed by inode and modification time: if a file has an
71 entry in the cache already then it won't be hashed again, which can
72 provide a valuable performance improvement on large filesystems.  If the
73 .I file
74 doesn't exist, then it will be created.
75 .TP
76 .B \-f, \-\-files=\fIformat
77 Read a list of filenames on standard input in the given
78 .I format
79 and write digest lines for them.  The
80 .I format
81 may be:
82 .B find0
83 for simple null-terminated names, as produced by
84 .BR "find \-\-print0" ;
85 or
86 .B rsync
87 for file data as produced by
88 .BR rsync (1).
89 The latter is useful, since
90 .B rsync
91 has powerful file inclusion and exclusion capabilities \(en and a common
92 use case is generating a digest for a collection of files copied using
93 .BR rsync .
94 (The
95 .B find0
96 format doesn't work well: see
97 .B BUGS
98 below.)
99 .TP
100 .B \-C, \-\-compat=\fIversion
101 Produce a manifest with the given compatibility
102 .IR version .
103 Alas,
104 .B fshash
105 has bugs in the way it produces manifests.  Fixing the bugs makes the
106 output better, but now it can't be compared with old manifests which
107 were made with the bugs.  By default,
108 .B fshash
109 produces manifests in the most recent format, but this option will force
110 it to be compatible with old versions.  The original version was 1; all
111 later versions print a comment reporting the version number at the start
112 of the manifest.  The current version is 3.
113 .TP
114 .B \-H, \-\-hash=\fIhash
115 Use the
116 .I hash
117 function, which can be any hash function supported by Python's
118 .BR hashlib .
119 This option may be omitted: if it is, then the hash is read from the
120 cache file; if there is no cache file either, then an error is reported.
121 .TP
122 .B \-u, \-\-udiff
123 Rather than produce a manifest, read a unified
124 .BR diff (1)
125 from standard input, and clear from the cache all files mentioned as
126 being different.  Filenames in the diff are considered relative to
127 .I dir ,
128 defaulting to the current working directory.
129 .PP
130 Positional arguments are interpreted as files and directories to be
131 processed, in order.  A directory name which ends in
132 .RB ` / '
133 is treated specially:
134 .B fshash
135 writes filenames relative to the given directory.
136 .SS Output format
137 For each filesystem object,
138 .B fshash
139 writes a summary line, followed by zero or more additional lines.
140 A summary line can be quite long, and consists of a number of
141 fields:
142 .hP 1.
143 For regular files, a cryptographic hash of the file's content, in
144 hexadecimal.  For other kinds of filesystem object, a description of the
145 object type and any special information about it, in square brackets,
146 and padded with spaces so as to take the same width as a hash; see
147 below for details.
148 .hP 2.
149 A `virtual inode identifier': a string which will be the same in two
150 lines if and only if they represent hard links to the same underlying
151 inode.  Some care is taken so that files are assigned the same
152 identifier even if other parts of the filesystem are different, so as to
153 avoid spurious differences.
154 .hP 3.
155 The object's permissions and mode bits, in octal.
156 .hP 4.
157 The file's owner and group, in decimal, separated by a colon.
158 .hP 5.
159 The file's last-modified time, in UTC, in ISO8601 format, i.e.,
160 .IB yyyy \(en mm \(en dd T hh : mm : ss Z \fR.
161 .hP 6.
162 The file's size in bytes, in decimal.
163 .hP 7.
164 The file's name (relative to some appropriate parent directory).
165 Characters which
166 would cause ambiguity are escaped: tab, linefeed and carriage return are
167 printed as
168 .RB ` \et ',
169 .RB ` \en ',
170 and
171 .RB ` \er ',
172 respectively;
173 .RB ` ' '
174 is printed as
175 .RB ` \e' ';
176 .RB ` \e '
177 is printed as
178 .RB ` \e\e ';
179 and other codes outside the range 32\(en127 are printed as hex escaped,
180 in the form
181 .RB ` \ex\fIxx '.
182 Finally, the sequence
183 .RB ` \~\->\~ '
184 is printed as
185 .RB ` \~\e\->\~ '
186 so that symlink targets are presented unambiguously (see below).
187 .PP
188 For non-regular file objects, the first field is an information field
189 enclosed in square brackets, and some of the other fields provide other
190 information or are suppressed, follows.
191 .TP
192 .I Errors
193 If there was an error reading the object's metadata then the information
194 field shows
195 .BI E nn
196 .IR message ,
197 and the other fields, except the name, are printed as
198 .B error
199 rather than having any useful information.
200 .TP
201 .I Sockets
202 The information field shows
203 .BR socket .
204 .TP
205 .I Named pipes
206 The information field shows
207 .BR fifo .
208 .TP
209 .I Symbolic links
210 The information field shows
211 .BR symbolic-link .
212 The name is followed by
213 .RB ` \~\->\~ '
214 and the link target (or
215 .BI <E nn \~ message >
216 if there was an error reading the link destination).
217 .TP
218 .I Directories
219 The information field shows
220 .BR directory ,
221 and the size field shows
222 .B dir
223 (since directory sizes are not consistent across filesystem
224 implementations).  The name is followed by
225 .RB ` / '.
226 .TP
227 .I Block and character devices
228 The information field shows
229 .B block-device
230 or
231 .BR character-device ,
232 as appropriate, followed by the major and minor device numbers in
233 decimal, and separated by a colon.
234 .PP
235 Additional lines begin with a tab character.  The possible lines are as
236 follows.
237 .TP
238 .I POSIX ACLs
239 .RS
240 If an object has nontrivial POSIX ACLs, then they are printed as additional
241 lines of the form
242 .IP
243 .BI "acl posix-access " acl
244 .PP
245 or
246 .IP
247 .BI "acl posix-default " acl
248 .PP
249 for access and default ACLs respectively.  The
250 .I acl
251 is the ACL in short text format, with numeric IDs, and with the entries
252 sorted into a canonical order (owner, other users, mask, file group, other
253 groups, others), or
254 .BI <E nn \~ message >
255 if there was an error retrieving the ACL.
256 .PP
257 An access ACL is nontrivial if it contains entries for
258 other users, other groups, or a mask, i.e., it is not completely described by
259 the file's traditional permissions.  A default ACL is nontrivial if it is not
260 empty.
261 .PP
262 POSIX ACLs are recognized at compatibility level 3 and above.  ACL
263 support requires the
264 .B pylibacl
265 library.
266 .RE
267 .TP
268 .I Extended attributes
269 .RS
270 If a file has extended attributes then they are printed as additional lines
271 of the form
272 .IP
273 .BI "xattr " name " " hash
274 .PP
275 where
276 .I name
277 is the attribute name, escaped in the same manner as filenames, and
278 .I hash
279 is the hash of the attribute's contents.  Extended attribute hashes are not
280 currently cached, because they're usually too small for it to be worthwhile.
281 If errors occur, then
282 .BI <E nn \~ message >
283 is printed in place of the
284 .I hash
285 if the error occurred when trying to retrieve the attribute value,
286 or in place of both
287 .I name
288 and
289 .I hash
290 if the error occurred when trying to list the attributes.
291 .PP
292 The
293 .B fshash
294 program does not print lines for extended attributes which are used to
295 implement features which
296 .B fshash
297 handles explicitly: for example, on Linux, POSIX ACLs are stored in extended
298 attributes named
299 .B system.posix_acl_access
300 and
301 .BR system.posix_acl_default ,
302 so these attributes are ignored if ACL support is available.
303 .PP
304 Extended attributes are recognized at compatibility level 3 and above.
305 Extended attribute support requires the
306 .B pyxattr
307 or
308 .B xattr
309 library, or Python 3.3.
310 .RE
311 .SH BUGS
312 No attempt is made to sort filenames read in
313 .B find0
314 format, so they're not very likely to match digests produced any other
315 way.  Indeed, they're not very likely to match digests produced by
316 .B find0
317 on other machines either.
318 .SH SEE ALSO
319 .BR find (1),
320 .BR rsync (1),
321 .BR sha256sum (1)
322 etc.
323 .SH AUTHOR
324 Mark Wooding, <mdw@distorted.org.uk>