cvsimport
[findutils.git] / locate / locatedb.5
bloba94905d5899bb6077411c242e8f06e94576233ea
1 .TH LOCATEDB 5 \" -*- nroff -*-
2 .SH NAME
3 locatedb \- front-compressed file name database
4 .SH DESCRIPTION
5 This manual page documents the format of file name databases for the
6 GNU version of
7 .BR locate .
8 The file name databases contain lists of files that were in
9 particular directory trees when the databases were last updated.
11 There can be multiple databases.  Users can select which databases
12 \fBlocate\fP searches using an environment variable or command line
13 option; see \fBlocate\fP(1).  The system administrator can choose the
14 file name of the default database, the frequency with which the
15 databases are updated, and the directories for which they contain
16 entries.  Normally, file name databases are updated by running the
17 \fBupdatedb\fP program periodically, typically nightly; see
18 \fBupdatedb\fP(1).
20 .SH GNU LOCATE02 database format
21 This is the default format of databases produced by 
22 .BR updatedb .
23 The 
24 .B updatedb 
25 program runs 
26 .B frcode
27 to compress the list of file names using front-compression, which
28 reduces the database size by a factor of 4 to 5.  Front-compression
29 (also known as incremental encoding) works as follows.
31 The database entries are a sorted list (case-insensitively, for users'
32 convenience).  Since the list is sorted, each entry is likely to share
33 a prefix (initial string) with the previous entry.  Each database
34 entry begins with an signed offset-differential count byte, which is
35 the additional number of characters of prefix of the preceding entry
36 to use beyond the number that the preceding entry is using of its
37 predecessor.  (The counts can be negative.)  Following the count is a
38 null-terminated ASCII remainder \(em the part of the name that follows
39 the shared prefix.
41 If the offset-differential count is larger than can be stored in a
42 signed byte (+/\-127), the byte has the value 0x80 (binary 10000000)
43 and the actual count follows in a 2-byte word, with the high byte
44 first (network byte order).  This count can also be negative (the sign
45 bit being in the first of the two bytes).
47 Every database begins with a dummy entry for a file called `LOCATE02',
48 which \fBlocate\fP checks for to ensure that the database file has the
49 correct format; it ignores the entry in doing the search.
51 Databases can not be concatenated together, even if the first
52 (dummy) entry is trimmed from all but the first database.  This
53 is because the offset-differential count in the first entry of the
54 second and following databases will be wrong.  
56 In the future, the data within the locate database may not be sorted
57 in any particular order.  To obtain sorted results, pipe the output of
58 .B locate 
59 through 
60 .BR "sort -f" .
61 .SH slocate database format
62 The 
63 .B slocate
64 program uses a database format similar to, but not quite the same as, 
65 GNU 
66 .BR locate .
67 The first byte of the database specifies its
68 .I security 
69 .IR level .
70 If the security level is 0, 
71 .B slocate
72 will read, match and print filenames on the basis of the information
73 in the database only.  However, if the security level byte is 1, 
74 .B slocate 
75 omits entries from its output if the invoking user is unable to access
76 them.  The second byte of the database is zero.  The second byte is
77 followed by the first database entry.  The first entry in the database
78 is not preceded by any differential count or dummy entry.  Instead
79 the differential count for the first item is assumed to be zero.
81 Starting with the second entry (if any) in the database, data is
82 interpreted as for the GNU LOCATE02 format.
84 .SH Old Locate Database format
85 There is also an old database format, used by Unix
86 .B locate
87 and
88 .B find
89 programs and earlier releases of the GNU ones.  \fBupdatedb\fP runs
90 programs called \fBbigram\fP and \fBcode\fP to produce old-format
91 databases.  The old format differs from the above description in the
92 following ways.  Instead of each entry starting with an
93 offset-differential count byte and ending with a null, byte values
94 from 0 through 28 indicate offset-differential counts from -14 through
95 14.  The byte value indicating that a long offset-differential count
96 follows is 0x1e (30), not 0x80.  The long counts are stored in host
97 byte order, which is not necessarily network byte order, and host
98 integer word size, which is usually 4 bytes.  They also represent a
99 count 14 less than their value.  The database lines have no
100 termination byte; the start of the next line is indicated by its first
101 byte having a value <= 30.
103 In addition, instead of starting with a dummy entry, the old database
104 format starts with a 256 byte table containing the 128 most common
105 bigrams in the file list.  A bigram is a pair of adjacent bytes.
106 Bytes in the database that have the high bit set are indexes (with the
107 high bit cleared) into the bigram table.  The bigram and
108 offset-differential count coding makes these databases 20-25% smaller
109 than the new format, but makes them not 8-bit clean.  Any byte in a
110 file name that is in the ranges used for the special codes is replaced
111 in the database by a question mark, which not coincidentally is the
112 shell wildcard to match a single character.
113 .SH EXAMPLE
116 Input to \fBfrcode\fP:
117 .\" with nulls changed to newlines:
118 /usr/src
119 /usr/src/cmd/aardvark.c
120 /usr/src/cmd/armadillo.c
121 /usr/tmp/zoo
123 Length of the longest prefix of the preceding entry to share:
124 0 /usr/src
125 8 /cmd/aardvark.c
126 14 rmadillo.c
127 5 tmp/zoo
130 Output from \fBfrcode\fP, with trailing nulls changed to newlines
131 and count bytes made printable:
133 0 LOCATE02
134 0 /usr/src
135 8 /cmd/aardvark.c
136 6 rmadillo.c
137 \-9 tmp/zoo
139 (6 = 14 \- 8, and \-9 = 5 \- 14)
141 .SH "SEE ALSO"
142 \fBfind\fP(1), \fBlocate\fP(1), \fBlocatedb\fP(5), \fBxargs\fP(1),
143 \fBFinding Files\fP (on-line in Info, or printed)
144 .SH "BUGS"
146 The best way to report a bug is to use the form at
147 http://savannah.gnu.org/bugs/?group=findutils.  
148 The reason for this is that you will then be able to track progress in
149 fixing the problem.   Other comments about \fBlocate\fP(1) and about
150 the findutils package in general can be sent to the 
151 .I bug-findutils
152 mailing list.  To join the list, send email to 
153 .IR bug-findutils-request@gnu.org .