source: trunk/essentials/sys-apps/findutils/locate/locatedb.5

Last change on this file was 3170, checked in by bird, 18 years ago

findutils 4.3.2

File size: 4.7 KB
Line 
1.TH LOCATEDB 5 \" -*- nroff -*-
2.SH NAME
3locatedb \- front-compressed file name database
4.SH DESCRIPTION
5This manual page documents the format of file name databases for the
6GNU version of
7.BR locate .
8The file name databases contain lists of files that were in
9particular directory trees when the databases were last updated.
10.P
11There can be multiple databases. Users can select which databases
12\fBlocate\fP searches using an environment variable or command line
13option; see \fBlocate\fP(1). The system administrator can choose the
14file name of the default database, the frequency with which the
15databases are updated, and the directories for which they contain
16entries. Normally, file name databases are updated by running the
17\fBupdatedb\fP program periodically, typically nightly; see
18\fBupdatedb\fP(1).
19.P
20\fBupdatedb\fP runs a program called \fBfrcode\fP to compress the list
21of file names using front-compression, which reduces
22the database size by a factor of 4 to 5. Front-compression (also
23known as incremental encoding) works as follows.
24.P
25The database entries are a sorted list (case-insensitively, for users'
26convenience). Since the list is sorted, each entry is likely to share
27a prefix (initial string) with the previous entry. Each database
28entry begins with an offset-differential count byte, which is the
29additional number of characters of prefix of the preceding entry to
30use beyond the number that the preceding entry is using of its
31predecessor. (The counts can be negative.) Following the count is a
32null-terminated ASCII remainder \(em the part of the name that follows
33the shared prefix.
34.P
35If the offset-differential count is larger than can be stored in a
36byte (+/\-127), the byte has the value 0x80 and the count follows in a
372-byte word, with the high byte first (network byte order).
38.P
39Every database begins with a dummy entry for a file called `LOCATE02',
40which \fBlocate\fP checks for to ensure that the database file has the
41correct format; it ignores the entry in doing the search.
42.P
43Databases can not be concatenated together, even if the first
44(dummy) entry is trimmed from all but the first database. This
45is because the offset-differential count in the first entry of the
46second and following databases will be wrong.
47.P
48There is also an old database format, used by Unix
49.B locate
50and
51.B find
52programs and earlier releases of the GNU ones. \fBupdatedb\fP runs
53programs called \fBbigram\fP and \fBcode\fP to produce old-format
54databases. The old format differs from the above description in the
55following ways. Instead of each entry starting with an
56offset-differential count byte and ending with a null, byte values
57from 0 through 28 indicate offset-differential counts from -14 through
5814. The byte value indicating that a long offset-differential count
59follows is 0x1e (30), not 0x80. The long counts are stored in host
60byte order, which is not necessarily network byte order, and host
61integer word size, which is usually 4 bytes. They also represent a
62count 14 less than their value. The database lines have no
63termination byte; the start of the next line is indicated by its first
64byte having a value <= 30.
65.P
66In addition, instead of starting with a dummy entry, the old database
67format starts with a 256 byte table containing the 128 most common
68bigrams in the file list. A bigram is a pair of adjacent bytes.
69Bytes in the database that have the high bit set are indexes (with the
70high bit cleared) into the bigram table. The bigram and
71offset-differential count coding makes these databases 20-25% smaller
72than the new format, but makes them not 8-bit clean. Any byte in a
73file name that is in the ranges used for the special codes is replaced
74in the database by a question mark, which not coincidentally is the
75shell wildcard to match a single character.
76.SH EXAMPLE
77.nf
78
79Input to \fBfrcode\fP:
80.\" with nulls changed to newlines:
81/usr/src
82/usr/src/cmd/aardvark.c
83/usr/src/cmd/armadillo.c
84/usr/tmp/zoo
85
86Length of the longest prefix of the preceding entry to share:
870 /usr/src
888 /cmd/aardvark.c
8914 rmadillo.c
905 tmp/zoo
91
92.fi
93Output from \fBfrcode\fP, with trailing nulls changed to newlines
94and count bytes made printable:
95.nf
960 LOCATE02
970 /usr/src
988 /cmd/aardvark.c
996 rmadillo.c
100\-9 tmp/zoo
101
102(6 = 14 \- 8, and \-9 = 5 \- 14)
103.fi
104.SH "SEE ALSO"
105\fBfind\fP(1), \fBlocate\fP(1), \fBlocatedb\fP(5), \fBxargs\fP(1)
106\fBFinding Files\fP (on-line in Info, or printed)
107.SH "BUGS"
108.P
109The best way to report a bug is to use the form at
110http://savannah.gnu.org/bugs/?group=findutils.
111The reason for this is that you will then be able to track progress in
112fixing the problem. Other comments about \fBlocate\fP(1) and about
113the findutils package in general can be sent to the
114.I bug-findutils
115mailing list. To join the list, send email to
116.IR bug-findutils-request@gnu.org .
Note: See TracBrowser for help on using the repository browser.