DbEnv::set_intermediate_dir_mode()
Prev | Chapter 5. The DbEnv Handle | Next

## DbEnv::set_intermediate_dir_mode()

    #include <db_cxx.h>

    int
    DbEnv::set_intermediate_dir_mode(u_int32_t mode);

By default, Berkeley DB does not create intermediate directories needed for recovery, that is, if the file /a/b/c/mydatabase is being recovered, and the directory path b/c 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.

The `DbEnv::set_intermediate_dir_mode()` method causes Berkeley DB to create any intermediate directories needed during recovery, using the specified permissions.

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.

The database environment's intermediate directory permissions may also be configured using the environment's DB_CONFIG 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 DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

The `DbEnv::set_intermediate_dir_mode()` method configures operations performed using the specified DbEnv handle, not all operations performed on the underlying database environment.

The `DbEnv::set_intermediate_dir_mode()` method may not be called after the DbEnv::open() method is called.

The `DbEnv::set_intermediate_dir_mode()` method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Parameters

#### mode

The mode parameter specifies the directory permissions.

Directory permissions are interpreted as a string of nine characters, using the character set r (read), w (write), x (execute or search), and - (none). The first character is the read permissions for the directory owner (set to either r or -). The second character is the write permissions for the directory owner (set to either w or -). The third character is the execute permissions for the directory owner (set to either x or -).

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 rwx------ would configure read, write and execute/search access for the owner only. The string rwxrwx--- would configure read, write and execute/search access for both the owner and the group. The string rwxr----- would configure read, write and execute/search access for the directory owner and read-only access for the directory group.

### Errors

The `DbEnv::set_intermediate_dir_mode()` method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

#### EINVAL

If the method was called after DbEnv::open() was called; or if an invalid flag value or parameter was specified.

### Class

DbEnv

### See Also

Database Environments and Related Methods

Prev | Up | Next
DbEnv::set_flags() | Home | DbEnv::set_isalive()