1.Dd March 31, 2006
2.Dt FSWATCH.CONF 5
3.Os
4.Sh NAME
5.Nm fswatch.conf
6.Nd fswatch configuration file syntax
7.Sh DESCRIPTION
8you can set which files (and directories) should be checked and what kind
9of information should be collected. you can define any settings on any level
10in a file tree regardless wether you define other settings on a higher or a lower
11level. it works because fswatch traverses an entrie file system but checks
12only selected part.
13.Pp
14a syntax of configuration file was designed in such a way that it is possible
15to meet this need.
16.Sh A FILE STRUCTURE
17a configuration file is built from <nodes>. a <node> defines path to directory.
18each <node> is built from <entries>. each
19<entry> defines which files (in a directory specified in a <node>)
20should be checked and what information
21should be collected.
22.Pp
23fswbuild traverses the whole file system and for every file it searches an <entry>.
24<entries> are being checked from the beginning to the
25end and checking is stopped when the first matching entry is found. so the
26order of entries matters.
27.Pp
28empty lines, lines beginning with a space (' '), a
29tabulator (' '), a hash sign ('#'), a semicolon (';')  are ignored.
30a config file structure is as follows:
31.Pp
32.nf
33--begin--
34node_1
35entry_1
36entry_2
37 ...
38entry_n1
39.Pp
40node_2
41entry_1
42entry_2
43 ...
44entry_n2
45.Pp
46 ...
47.Pp
48node_N
49entry_1
50entry_2
51 ...
52entry_nN
53--end--
54.fi
55.Pp
56.Sh NODES
57in <nodes> you define a directory (a full path) and then you can define
58<entries>
59for this directory. in <nodes> you can define inheritance type. a <node> syntax is
60as follows:
61.Pp
62.nf
63@_INHERITANCE_:_DIRECTORY_
64.fi
65.Pp
66where _INHERITANCE_ is one of three words NO, PRE, POST and _DIRECTORY_ is
67a full path to a directory. entries can be inherited only from a nearest node
68on a lower level in a directory tree. NO means without any inheritance. PRE or
69POST means inheritance by adding inherited entries to begin or to end a node
70respectively.
71.Pp
72.Sh ENTRIES
73<entries> define which files (and directiories) should be checked and what information
74should be collected. an <entry> syntax in a configuration file is as follows:
75.Pp
76.nf
77+_MASK_:_OPTIONS_
78name:_NAME_
79namere:_NAMERE_
80uid:_UID_
81gid:_GID_
82type:_TYPE_
83.fi
84.Pp
85_MASK_ defines what information should be collected. it
86can consist of the following signs: i, l, u, g, m, s, f, t, c, N, F, C ;
87i (inode), m (mode), l (links), u (uid), g (gid), t (ctime), s (size),
88f (flags), c (checksum). N means NOT to check anything. F means to check
89everything. C is equivalent to the following signs: imlugf ;
90.Pp
91_OPTIONS_ can consist of the following signs: I, S ; entries marked with "I"
92sign can be inherited. S functions only within a directory and means NOT to
93traverse inside. you can use it to speed up work if a directory is a network
94file system or a directory with a huge number of files and subdirectories which
95you do NOT want to check.
96.Pp
97lines beginning with key words: name, namere, uid, gid, type ; define which
98files (and directories) should be matched. you don`t have to use all these key
99words. each key word can be used more than once. there is logical "or"
100between the same type key words. there is logical
101"and" between different type key words. key words: name, namere ; are the
102same type.
103.Pp
104_NAME_ is a file name. you can use a very simple regular expression (see below).
105.Pp
106_NAMRE_ is an extended regular expression which defines a file name. the
107syntax is the same as in
108.Xr grep 1 . (it is available only if you compile it with --enable-regex
109option).
110.Pp
111_UID_, _GID_ define uid (owner) and gid (group) of a file respectively. you
112can use a simple regular expression (see below).
113.Pp
114_TYPE_ defines file types. you can set the following signs: f, c, d, b, r, l,
115s ; f (fifo), c (special character),
116d (directory), b (block special), r (regular), l (symbolic link), s (socket).
117.Pp
118.Sh SIMPLE REGULAR EXRESSION (NAME)
119you can use simple regular expressions in lines beginning with name key word. besides
120all letters and signs used in path names you can use: *, ? ; (an asterisk and
121a question mark).
122a question mark means any letter (or sign), an asterisk means zero or more letters
123(or signs). '?' (a question mark) can stand before '*' (asterisk) but it can NOT stand
124after '*'. there can NOT be two or more '*' next to each other. you can set one or
125more '?' next to each other, though.
126.Pp
127.nf
128e.g.:
129abc
130abc*
131*abc?
132a*b*c
133a?*b??*c*
134.fi
135.Pp
136if you do NOT comply with these rules entry matching will be working indefinitely.
137.Pp
138.Sh SIMPLE REGULAR EXRESSION (UID, GID)
139there are four types of regular expressions. they are the same for uid and
140gid.
141.Pp
142* a simple number id
143.nf
144id
145.Pp
146e.g.:
147uid:1010
148gid:1010
149.Pp
150* id <= numbers
151id-
152.Pp
153.e.g.:
154uid:1000-
155gid:1000-
156.Pp
157* numbers <= id
158-id
159.e.g.:
160uid:-1000
161gid:-1000
162.Pp
163* id1 <= numbers <= id2
164id1-id2
165.Pp
166e.g.:
167uid:1000-2000
168gid:1000-2000
169.fi
170.Pp
171.Sh INHERITACE BY NODES
172you can set which entries should be inherited by next nodes (the nearest node at a higher
173level in a file
174tree). you have to do two things. firstly, you have to mark entries you want to be
175inherited as "I" (options "I"). secondly, in an inheriting node you have to set what kind of
176inheritance you want to use (PRE or POST). PRE adds inherited entries at the beginning
177and POST at the end respectively. NO means without any inheritance.
178.Pp
179e.g.:
180.nf
181--begin--
182@NO:/dira
183+N
184name:file1
185name:file2
186+F:I
187name:file3
188+N
189uid:1500-
190+F:I
191type:r
192.Pp
193@PRE:/dira/dirb/dirc
194+ugfm
195name:file4
196--end--
197.fi
198.Pp
199the second <node> inherits ("PRE") from a <node> (on a lower level in a directory
200tree). result (for /dira/dirb/dirc):
201.Pp
202.nf
203+F:I
204name:file3
205+F:I
206type:r
207+ugfm
208name:file4
209.fi
210.Pp
211.Sh INHERITANCE BY SUBDIRECTORIES
212it goes without saying you don`t want to define node settings for each directory in
213your file system because most settings for directories are the same. for directories
214you didn`t create, node settings are inherited from the nearest node
215(entries with "I" option) on a lower level in
216a file tree.
217.Pp
218.Xr fswbuild 1
219works in a following way: it traverses a file system (directories). it
220enters a directory and checks:
221.Pp
222if <node> (for a directory) exists then; for every file
223in that directory fswbuild searches a matching <entry> (from all <entries> in
224that <node>).
225.Pp
226if <node> (for a directory) doesn`t exist then: fswbuild
227searches the nearest <node> (the nearest in a directory tree) and then: for
228every file in that directory fswbuild searches a matching <entry> (from all
229<entries> with option "I" in a found <node>).
230.Pp
231.Sh EXAMPLES
232.Pp
233example 1
234.Pp
235.nf
236 --begin--
237@NO:/
238+F
239name:*
240 --end--
241.fi
242.Pp
243it matches all files in "/" which fulfill ALL conditions:
244.nf
245* file name is "*" (all names)
246.fi
247fswbuild will collect information ("F" means: inode, links, uid, gid,
248mode, size, flags, ctime, checksum) for all matched files.
249.Pp
250example 2
251.Pp
252.nf
253 --begin--
254@NO:/
255+F
256name:a
257name:b
258 --end--
259.fi
260.Pp
261it matches all files in "/" which fulfill ALL conditions:
262.nf
263* file name is "a" or "b"
264.fi
265fswbuild will collect information ("F" means: inode, links, uid, gid,
266mode, size, flags, ctime, checksum) for all matched files.
267.Pp
268example 3
269.Pp
270.nf
271 --begin--
272@NO:/
273+F
274name:a
275name:b
276name:c
277type:r
278 --end--
279.fi
280.Pp
281it matches all files in "/" which fulfill ALL conditions:
282.nf
283* file name is "a" or "b" or "c"
284* file type is "r" (regular)
285.fi
286fswbuild will collect information ("F" means: inode, links, uid, gid,
287mode, size, flags, ctime, checksum) for all matched files.
288.Pp
289example 4
290.Pp
291.nf
292 --begin--
293@NO:/
294+ugmtc
295name:a
296name:b
297name:c
298uid:1001
299uid:2000-4000
300type:rd
301 --end--
302.fi
303.Pp
304it matches all files in "/" which fulfill ALL conditions:
305.nf
306* file name is "a" or "b" or "c"
307* uid (file owner id) is "1001" or in "2000-4000"
308* file type is "r" (regular) or "d" (directory)
309.fi
310fswbuild will collect information ("ugmtc" means: uid, gid,
311mode, ctime, checksum) for all matched files.
312.Pp
313example 5
314.Pp
315.nf
316 --begin--
317@NO:/
318+N
319uid:2000-4000
320+F
321name:*
322 --end--
323.fi
324.Pp
325there are two entries. the first entry matches all files in
326"/" which fulfill ALL conditions:
327.nf
328* uid (file owner id) is in "2000-4000"
329.fi
330fswbuild will collect information ("N" means: no information)
331for all matched files.
332.Pp
333if file doesn`t match the first entry then the second entry
334is checked.
335.Pp
336the second entry matches all files in "/" which fulfill ALL
337conditions:
338.nf
339* file name is "*" (all names)
340.fi
341fswbuild will collect information ("F" means: inode, links, uid, gid,
342mode, size, flags, ctime, checksum) for all matched files.
343.Pp
344example 6
345.Pp
346.nf
347 --begin--
348@NO:/
349+N
350uid:2000-4000
351+C
352name:tmp
353name:run
354type:d
355+F
356name:*
357 --end--
358.fi
359.Pp
360there are three entries. the first entry matches all files in
361"/" which fulfill ALL conditions:
362.nf
363* uid (file owner id) is in "2000-4000"
364.fi
365fswbuild will collect information ("N" means: no information)
366for all matched files.
367.Pp
368if file doesn`t match the first entry then the second entry
369is checked.
370.Pp
371the second entry matches all files in "/" which fulfill ALL
372conditions:
373.nf
374* name is "tmp" or "run"
375* type is "d" (directory)
376.fi
377fswbuild will collect information ("C" means: inode, links,
378uid, gid, mode, flags) for all matched files.
379.Pp
380if file doesn`t match the second entry then the third entry
381is checked.
382.Pp
383the third entry matches all files in "/" which fulfill ALL
384conditions:
385.nf
386* file name is "*" (all names)
387.fi
388fswbuild will collect information ("F" means: inode, links, uid, gid,
389mode, size, flags, ctime, checksum) for all matched files.
390.Pp
391example 7
392.Pp
393.nf
394 --begin--
395@NO:/
396+F
397name:???
398type:d
399 --end--
400.fi
401.Pp
402it matches all files in "/" which fulfill ALL conditions:
403.nf
404* file name is "???" (it contains exactly three signs)
405* file type is "d" (directory)
406.fi
407fswbuild will collect information ("F" means: inode, links, uid, gid,
408mode, size, flags, ctime, checksum) for all matched files.
409.Pp
410example 8
411.Pp
412.nf
413 --begin--
414@NO:/
415+F
416name:???
417+F
418type:d
419 --end--
420.fi
421.Pp
422there are two entries. the first entry matches all files in
423"/" which fulfill ALL conditions:
424.nf
425* file name is "???" (it contains exactly three signs)
426.fi
427fswbuild will collect information ("F" means: inode, links, uid, gid,
428mode, size, flags, ctime, checksum) for all matched files.
429.Pp
430if file doesn`t match the first entry then the second entry
431is checked.
432.Pp
433the second entry matches all files in "/" which fulfill ALL conditions:
434.nf
435* file type is "d" (directory)
436.fi
437fswbuild will collect information ("F" means: inode, links, uid, gid,
438mode, size, flags, ctime, checksum) for all matched files.
439.Pp
440example 9
441.Pp
442.nf
443 --begin--
444@NO:/dir1/dir2
445+F
446name:*
447 --end--
448.fi
449.Pp
450it matches all files in "/dir1/dir2" which fulfill ALL conditions:
451.nf
452* file name is "*" (all names)
453.fi
454fswbuild will collect information ("F" means: inode, links, uid, gid,
455mode, size, flags, ctime, checksum) for all matched files.
456.Pp
457example 10
458.Pp
459.nf
460 --begin--
461@NO:/dir1/dir2
462+F:I
463name:*
464 --end--
465.fi
466.Pp
467it matches all files in "/dir1/dir2" and all subdirectories (
468because of "I" options - inheritance by subdirectories) which
469fulfill ALL conditions:
470.nf
471* file name is "*" (all names)
472.fi
473fswbuild will collect information ("F" means: inode, links, uid, gid,
474mode, size, flags, ctime, checksum) for all matched files.
475.Pp
476example 11
477.Pp
478.nf
479 --begin--
480@NO:/dir1/dir2
481+N
482name:tmp
483+F:I
484name:*
485 --end--
486.fi
487.Pp
488there are two entries. the first can match files only in
489"/dir1/dir2". the second (because of "I" option) can match
490files in "/dir1/dir2" and all subdirectories (inheratance
491by subdirectories).
492.Pp
493example 12
494.Pp
495.nf
496 --begin--
497@NO:/dir1
498+F
499name:dir2
500.Pp
501@NO:/dir1/dir2
502+F:I
503name:*
504 --end--
505.fi
506.Pp
507there are two nodes. the first node sets that all information
508("F") should be collected for file "/dir1/dir2". the second
509node sets that all information ("F") should be collected for
510files in "/dir1/dir2" directory and in its subdirectories
511(because of "I" option).
512.Pp
513example 13
514.Pp
515.nf
516 --begin--
517@NO:/
518+N:S
519name:dir1
520name:dir2
521+F:I
522name:*
523 --end--
524.fi
525.Pp
526the first entry has "S" option. it means fswbuild will NOT go into
527"/dir1" and "/dir2" directories and all its subdirectories. it
528means fswbuild will NOT collect any information for files in this
529directories. because of "N" it will NOT collect any information
530for file "/dir1" and "/dir2". for other files in "/" fswbuild will
531collect all information ("F") and because of "I" option it will
532collect all information for all files in its subdirectories.
533.Pp
534there is an equivalent example below:
535.Pp
536.nf
537 --begin--
538@NO:/
539+N
540name:dir1
541name:dir2
542+F:I
543name:*
544.Pp
545@NO:/dir1
546+N:I
547name:*
548.Pp
549@NO:/dir2
550+N:I
551name:*
552 --end--
553.fi
554.Pp
555.Sh SEE ALSO
556.Xr fswbuild 1 ,
557.Xr fswcmp 1 ,
558.Xr fswshow 1 ,
559.Xr fswconf 1