1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DB_ENV->set_intermediate_dir_mode()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="env.html" title="Chapter��5.�� The DB_ENV Handle" /> 11 <link rel="prev" href="envset_flags.html" title="DB_ENV->set_flags()" /> 12 <link rel="next" href="envset_isalive.html" title="DB_ENV->set_isalive()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->set_intermediate_dir_mode()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_flags.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��5.�� 23 The DB_ENV Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="envset_isalive.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envset_intermediate_dir_mode"></a>DB_ENV->set_intermediate_dir_mode()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->set_intermediate_dir_mode(DB_ENV *dbenv, const char *mode); </pre> 42 <p> 43 By default, Berkeley DB does not create intermediate directories 44 needed for recovery, that is, if the file <span class="bold"><strong>/a/b/c/mydatabase</strong></span> is being recovered, and the 45 directory path <span class="bold"><strong>b/c</strong></span> does not exist, 46 recovery will fail. This default behavior is because Berkeley DB 47 does not know what permissions are appropriate for intermediate 48 directory creation, and creating the directory might result in a 49 security problem. 50 </p> 51 <p> 52 The <code class="methodname">DB_ENV->set_intermediate_dir_mode()</code> method causes Berkeley DB to 53 create any intermediate directories needed during recovery, using the 54 specified permissions. 55 </p> 56 <p> 57 On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, 58 created directories are owned by the process owner; the group 59 ownership of created directories is based on the system and directory 60 defaults, and is not further specified by Berkeley DB. 61 </p> 62 <p> 63 The database environment's intermediate directory permissions may also 64 be configured using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 65 syntax of the entry in that file is a single line with the string 66 "set_intermediate_dir_mode", one or more whitespace characters, and 67 the directory permissions. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 68 read when the database environment is opened, it will silently 69 overrule configuration done before that time. 70 </p> 71 <p> 72 The <code class="methodname">DB_ENV->set_intermediate_dir_mode()</code> method configures operations 73 performed using the specified 74 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> handle, not all 75 operations performed on the underlying database environment. 76 </p> 77 <p> 78 The <code class="methodname">DB_ENV->set_intermediate_dir_mode()</code> method may not be called 79 after the <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 80 method is called. 81 </p> 82 <p> 83 The <code class="methodname">DB_ENV->set_intermediate_dir_mode()</code> <span> 84 <span> 85 method returns a non-zero error value on failure and 0 on success. 86 </span> 87 88 </span> 89 </p> 90 <div class="sect2" lang="en" xml:lang="en"> 91 <div class="titlepage"> 92 <div> 93 <div> 94 <h3 class="title"><a id="id1669157"></a>Parameters</h3> 95 </div> 96 </div> 97 </div> 98 <div class="sect3" lang="en" xml:lang="en"> 99 <div class="titlepage"> 100 <div> 101 <div> 102 <h4 class="title"><a id="id1670671"></a>mode</h4> 103 </div> 104 </div> 105 </div> 106 <p> 107 The <span class="bold"><strong>mode</strong></span> parameter specifies the 108 directory permissions. 109 </p> 110 <p> 111 Directory permissions are interpreted as a string of nine characters, 112 using the character set <span class="bold"><strong>r</strong></span> (read), 113 <span class="bold"><strong>w</strong></span> (write), <span class="bold"><strong>x</strong></span> (execute or search), and <span class="bold"><strong>-</strong></span> (none). The first character is the read 114 permissions for the directory owner (set to either <span class="bold"><strong>r</strong></span> or <span class="bold"><strong>-</strong></span>). The 115 second character is the write permissions for the directory owner (set 116 to either <span class="bold"><strong>w</strong></span> or <span class="bold"><strong>-</strong></span>). The third character is the execute 117 permissions for the directory owner (set to either <span class="bold"><strong>x</strong></span> or <span class="bold"><strong>-</strong></span>). 118 </p> 119 <p> 120 Similarly, the second set of three characters are the read, write and 121 execute/search permissions for the directory group, and the third set 122 of three characters are the read, write and execute/search permissions 123 for all others. For example, the string <span class="bold"><strong>rwx------</strong></span> would configure read, write and 124 execute/search access for the owner only. The string <span class="bold"><strong>rwxrwx---</strong></span> would configure read, write and 125 execute/search access for both the owner and the group. The string 126 <span class="bold"><strong>rwxr-----</strong></span> would configure read, write 127 and execute/search access for the directory owner and read-only access 128 for the directory group. 129 </p> 130 </div> 131 </div> 132 <div class="sect2" lang="en" xml:lang="en"> 133 <div class="titlepage"> 134 <div> 135 <div> 136 <h3 class="title"><a id="id1670660"></a>Errors</h3> 137 </div> 138 </div> 139 </div> 140 <p> 141 The <code class="methodname">DB_ENV->set_intermediate_dir_mode()</code> 142 <span> 143 <span> 144 method may fail and return one of the following non-zero errors: 145 </span> 146 147 </span> 148 </p> 149 <div class="sect3" lang="en" xml:lang="en"> 150 <div class="titlepage"> 151 <div> 152 <div> 153 <h4 class="title"><a id="id1670748"></a>EINVAL</h4> 154 </div> 155 </div> 156 </div> 157 <p> 158 If the method was called after <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 159 was called; or if an invalid flag value or parameter was specified. 160 </p> 161 </div> 162 </div> 163 <div class="sect2" lang="en" xml:lang="en"> 164 <div class="titlepage"> 165 <div> 166 <div> 167 <h3 class="title"><a id="id1670662"></a>Class</h3> 168 </div> 169 </div> 170 </div> 171 <p> 172 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 173 </p> 174 </div> 175 <div class="sect2" lang="en" xml:lang="en"> 176 <div class="titlepage"> 177 <div> 178 <div> 179 <h3 class="title"><a id="id1670706"></a>See Also</h3> 180 </div> 181 </div> 182 </div> 183 <p> 184 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 185 </p> 186 </div> 187 </div> 188 <div class="navfooter"> 189 <hr /> 190 <table width="100%" summary="Navigation footer"> 191 <tr> 192 <td width="40%" align="left"><a accesskey="p" href="envset_flags.html">Prev</a>��</td> 193 <td width="20%" align="center"> 194 <a accesskey="u" href="env.html">Up</a> 195 </td> 196 <td width="40%" align="right">��<a accesskey="n" href="envset_isalive.html">Next</a></td> 197 </tr> 198 <tr> 199 <td width="40%" align="left" valign="top">DB_ENV->set_flags()��</td> 200 <td width="20%" align="center"> 201 <a accesskey="h" href="index.html">Home</a> 202 </td> 203 <td width="40%" align="right" valign="top">��DB_ENV->set_isalive()</td> 204 </tr> 205 </table> 206 </div> 207 </body> 208</html> 209