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>DbEnv::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 DbEnv Handle" /> 11 <link rel="prev" href="envset_flags.html" title="DbEnv::set_flags()" /> 12 <link rel="next" href="envset_isalive.html" title="DbEnv::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">DbEnv::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 DbEnv 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>DbEnv::set_intermediate_dir_mode()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_intermediate_dir_mode(u_int32_t 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">DbEnv::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">DbEnv::set_intermediate_dir_mode()</code> method configures operations 73 performed using the specified 74 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle, not all 75 operations performed on the underlying database environment. 76 </p> 77 <p> 78 The <code class="methodname">DbEnv::set_intermediate_dir_mode()</code> method may not be called 79 after the <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 80 method is called. 81 </p> 82 <p> 83 The <code class="methodname">DbEnv::set_intermediate_dir_mode()</code> <span> 84 85 <span> 86 method either returns a non-zero error value or throws an 87 exception that encapsulates a non-zero error value on 88 failure, and returns 0 on success. 89 </span> 90 </span> 91 </p> 92 <div class="sect2" lang="en" xml:lang="en"> 93 <div class="titlepage"> 94 <div> 95 <div> 96 <h3 class="title"><a id="id1673294"></a>Parameters</h3> 97 </div> 98 </div> 99 </div> 100 <div class="sect3" lang="en" xml:lang="en"> 101 <div class="titlepage"> 102 <div> 103 <div> 104 <h4 class="title"><a id="id1673324"></a>mode</h4> 105 </div> 106 </div> 107 </div> 108 <p> 109 The <span class="bold"><strong>mode</strong></span> parameter specifies the 110 directory permissions. 111 </p> 112 <p> 113 Directory permissions are interpreted as a string of nine characters, 114 using the character set <span class="bold"><strong>r</strong></span> (read), 115 <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 116 permissions for the directory owner (set to either <span class="bold"><strong>r</strong></span> or <span class="bold"><strong>-</strong></span>). The 117 second character is the write permissions for the directory owner (set 118 to either <span class="bold"><strong>w</strong></span> or <span class="bold"><strong>-</strong></span>). The third character is the execute 119 permissions for the directory owner (set to either <span class="bold"><strong>x</strong></span> or <span class="bold"><strong>-</strong></span>). 120 </p> 121 <p> 122 Similarly, the second set of three characters are the read, write and 123 execute/search permissions for the directory group, and the third set 124 of three characters are the read, write and execute/search permissions 125 for all others. For example, the string <span class="bold"><strong>rwx------</strong></span> would configure read, write and 126 execute/search access for the owner only. The string <span class="bold"><strong>rwxrwx---</strong></span> would configure read, write and 127 execute/search access for both the owner and the group. The string 128 <span class="bold"><strong>rwxr-----</strong></span> would configure read, write 129 and execute/search access for the directory owner and read-only access 130 for the directory group. 131 </p> 132 </div> 133 </div> 134 <div class="sect2" lang="en" xml:lang="en"> 135 <div class="titlepage"> 136 <div> 137 <div> 138 <h3 class="title"><a id="id1673316"></a>Errors</h3> 139 </div> 140 </div> 141 </div> 142 <p> 143 The <code class="methodname">DbEnv::set_intermediate_dir_mode()</code> 144 <span> 145 146 <span> 147 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 148 exception, encapsulating one of the following non-zero errors, or return one 149 of the following non-zero errors: 150 </span> 151 </span> 152 </p> 153 <div class="sect3" lang="en" xml:lang="en"> 154 <div class="titlepage"> 155 <div> 156 <div> 157 <h4 class="title"><a id="id1673395"></a>EINVAL</h4> 158 </div> 159 </div> 160 </div> 161 <p> 162 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 163 was called; or if an invalid flag value or parameter was specified. 164 </p> 165 </div> 166 </div> 167 <div class="sect2" lang="en" xml:lang="en"> 168 <div class="titlepage"> 169 <div> 170 <div> 171 <h3 class="title"><a id="id1673361"></a>Class</h3> 172 </div> 173 </div> 174 </div> 175 <p> 176 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 177 </p> 178 </div> 179 <div class="sect2" lang="en" xml:lang="en"> 180 <div class="titlepage"> 181 <div> 182 <div> 183 <h3 class="title"><a id="id1673403"></a>See Also</h3> 184 </div> 185 </div> 186 </div> 187 <p> 188 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 189 </p> 190 </div> 191 </div> 192 <div class="navfooter"> 193 <hr /> 194 <table width="100%" summary="Navigation footer"> 195 <tr> 196 <td width="40%" align="left"><a accesskey="p" href="envset_flags.html">Prev</a> </td> 197 <td width="20%" align="center"> 198 <a accesskey="u" href="env.html">Up</a> 199 </td> 200 <td width="40%" align="right"> <a accesskey="n" href="envset_isalive.html">Next</a></td> 201 </tr> 202 <tr> 203 <td width="40%" align="left" valign="top">DbEnv::set_flags() </td> 204 <td width="20%" align="center"> 205 <a accesskey="h" href="index.html">Home</a> 206 </td> 207 <td width="40%" align="right" valign="top"> DbEnv::set_isalive()</td> 208 </tr> 209 </table> 210 </div> 211 </body> 212</html> 213