Locate databases with relative pathnames ============================================== 1. Purpose ---------- Assume an nfs server SERVER exporting /SERVERPATH, and some clients using mount SERVER:/SERVERPATH /CLIENTPATH1 as well as some other clients using mount SERVER:/SERVERPATH /CLIENTPATH2 where SERVERPATH, CLIENTPATH1, and CLIENTPATH2 may all differ. In such a situation it is desirable to (re-)build a locate database on SERVER for the files under /SERVERPATH (for reasons of efficiency as well as access permissions). If that database is located under /SERVERPATH and contains only the filename parts relative to /SERVERPATH, the locate command on the server or clients could prepend /SERVERPATH, /CLIENTPATH1, resp. /CLIENTPATH2 to these filename parts, thereby producing results that are correct for the respective hosts. 2. Basic Idea ------------- 2.0 Only implemented for new (LOCATE02) database format, since support for the old format will be discontinued in the near(?) future. 2.1 The database format is not modified but slightly reinterpreted as follows: The current implementation cannot contain an empty filename. Thus, adding a dummy empty filename as first database entry can signal to locate that a database contains relative filenames. We require that the database is a file in the top-level directory (/SERVERPATH, /CLIENTPATH1, resp. /CLIENTPATH2) and thus locate can deduce the required filename prefix from the directory part of the database name. 2.2 A new commandline option for updatedb (e.g., --relpath=PREFIX) causes the creation of databases with relative filenames. This option would be incompatible with --old-format and --netpaths, and would require that --output=DBFILE and --localpaths='DIR1 DIR2...' specify explicitly relative paths. The option --relpath=PREFIX would imply --changecwd=PREFIX and an explicit --changecwd would be either ignored or be an error. 3. Implementation ----------------- 3.1 locate: The required modifications are almost entirly in visit_locate02_format(): detect the presence of a database with relative paths, initialize the path prefix with dirname(procdata->dbfile), and set prefix_len=len=count to the length of this prefix. 3.2 updatedb: Apart from parsing the arguments and checking them for consistency, all updatedb has to do is passing the option "-r" to frcode. The filenames passed to frcode are either "." or start with "./". 3.3 frcode: For a database with relative paths frcode outputs an empty string as first filename and removes the mandatory leading "." from all filenames read from stdin. ==================== 2006-10-15 Peter Breitenlohner