By default, Berkeley DB does not create intermediate directories
needed for recovery, that is, if the file <spanclass="bold"><strong>/a/b/c/mydatabase</strong></span> is being recovered, and the
directory path <spanclass="bold"><strong>b/c</strong></span> does not exist,
recovery will fail. This default behavior is because Berkeley DB
does not know what permissions are appropriate for intermediate
directory creation, and creating the directory might result in a
security problem.
</p>
<p>
The <codeclass="methodname">DB_ENV->set_intermediate_dir_mode()</code> method causes Berkeley DB to
create any intermediate directories needed during recovery, using the
specified permissions.
</p>
<p>
On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments,
created directories are owned by the process owner; the group
ownership of created directories is based on the system and directory
defaults, and is not further specified by Berkeley DB.
</p>
<p>
The database environment's intermediate directory permissions may
also be configured using the environment's <ahref="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG"class="olink">DB_CONFIG</a> file. The
syntax of the entry in that file is a single line with the string
"set_intermediate_dir_mode", one or more whitespace characters,
and the directory permissions. Because the <ahref="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG"class="olink">DB_CONFIG</a> file is
read when the database environment is opened, it will silently
overrule configuration done before that time.
</p>
<p>
The <codeclass="methodname">DB_ENV->set_intermediate_dir_mode()</code> method configures operations
performed using the specified
<aclass="link"href="env.html"title="Chapter5. The DB_ENV Handle">DB_ENV</a> handle, not all
operations performed on the underlying database environment.
</p>
<p>
The <codeclass="methodname">DB_ENV->set_intermediate_dir_mode()</code> method may not be called
after the <aclass="xref"href="envopen.html"title="DB_ENV->open()">DB_ENV->open()</a>
method is called.
</p>
<p>
The <codeclass="methodname">DB_ENV->set_intermediate_dir_mode()</code><span>
<span>
method returns a non-zero error value on failure and 0 on success.
The <spanclass="bold"><strong>mode</strong></span> parameter specifies the
directory permissions.
</p>
<p>
Directory permissions are interpreted as a string of nine characters,
using the character set <spanclass="bold"><strong>r</strong></span> (read),
<spanclass="bold"><strong>w</strong></span> (write), <spanclass="bold"><strong>x</strong></span> (execute or search), and <spanclass="bold"><strong>-</strong></span> (none). The first character is the read
permissions for the directory owner (set to either <spanclass="bold"><strong>r</strong></span> or <spanclass="bold"><strong>-</strong></span>). The
second character is the write permissions for the directory owner (set
to either <spanclass="bold"><strong>w</strong></span> or <spanclass="bold"><strong>-</strong></span>). The third character is the execute
permissions for the directory owner (set to either <spanclass="bold"><strong>x</strong></span> or <spanclass="bold"><strong>-</strong></span>).
</p>
<p>
Similarly, the second set of three characters are the read, write and
execute/search permissions for the directory group, and the third set
of three characters are the read, write and execute/search permissions
for all others. For example, the string <spanclass="bold"><strong>rwx------</strong></span> would configure read, write and
execute/search access for the owner only. The string <spanclass="bold"><strong>rwxrwx---</strong></span> would configure read, write and
execute/search access for both the owner and the group. The string
<spanclass="bold"><strong>rwxr-----</strong></span> would configure read, write
and execute/search access for the directory owner and read-only access