Divergefs is a user level file server which layers arbitrary number of directory trees on top of the base directory mountpoint based on user specified rules from rulefile. Its uses include, but are not limited to, temporarily modifying a few files on read-only media or speeding up compilation by storing object files locally instead of on a distant file server.
defaultpath/files all<>
which means that defaultpath/files will be layered on top of mountpoint. defaultpath and defaultpath/files will be automatically created if they do not exist. (default /tmp if both rulefile and holefile are not specified).
Note: any relative paths supplied either through command line arguments or inside the rule file will be relative to the current directory when divergefs is invoked.
If divergefs is invoked with default path, it will automatically output a rule file to defaultpath/rules, in this case /tmp/rules, which can be modified later to suit different needs.
Default path is easy to use but is limited to layering only one directory on top of the mountpoint if the supplied default rule file is used. For more advanced usage, writing your own config file may be necessary. The following is an example avoiding write-back to remote server to speed up the compilation:
After mounting, writing to /sys/src/*/*.8 will be redirected to /n/junk/*/*.8 while writing to other files will be redirected to /tmp/pcbuild/*.
Note: the first rule ext<8> will be on the top of the layered directory tree while the last rule all<> will be on the bottom just above the mountpoint.
Therefore, a more robust approach is to supply the holefile argument while mounting which defaults to /tmp/holes. Hole file is necessary for the file system to keep track of which files were removed and should not be used. In the case of read-only media, the files will not be actually removed, but the file system has to simulate the effect of removing by "covering up" the filenames through the use of a hole file.
It is suggested that you supply the holefile argument if you are not using the default path invocation, so that holefile can be reused from a previous session to recover the state on that mountpoint. If no holefile is specified, and there are two running instances of divergefs, then they will be racing for the hole file at /tmp/holes and the result is undefined. Therefore, it is important that you make sure the hole file from an entirely different session is not reused.
In the case of default path invocation, if no holefile is specified, it defaults to defaultpath/holes. If such file exists, it will be picked up to resume a previous session, so it is ok not to specify a hole file when supplying the -p defaultpath argument.
rule = path complex_rule
path = absolute_path | relative_path
complex_rule = simple_rule (("||" | "&&") complex_rule)?
simple_rule = concrete_rule '<' setting '>' | '(' complex_rule ')'
Concrete rules and corresponding setting syntax are described in the next section. Note: relative_path is relative to the current path at the time of invocation.
The rule syntax is experimental (contact author with suggestions).