1 /* config.c - bdb backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
25 # define SLAP_BDB_ALLOW_DIRTY_READ
36 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
39 fprintf( stderr, "%s: line %d: "
40 "bdb database info is null!\n",
45 /* directory is the DB_HOME */
46 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
48 fprintf( stderr, "%s: line %d: "
49 "missing dir in \"directory <dir>\" line\n",
53 if ( bdb->bi_dbenv_home ) {
54 free( bdb->bi_dbenv_home );
56 bdb->bi_dbenv_home = ch_strdup( argv[1] );
58 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
59 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
60 bdb->bi_db_opflags |= DB_DIRTY_READ;
62 /* transaction logging configuration */
63 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
64 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
66 /* slapindex algorithm tuning */
67 } else if ( strcasecmp( argv[0], "linearindex" ) == 0 ) {
68 bdb->bi_linear_index = 1;
70 /* transaction checkpoint configuration */
71 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
73 fprintf( stderr, "%s: line %d: "
74 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
79 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
80 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
82 /* lock detect configuration */
83 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
85 fprintf( stderr, "%s: line %d: "
86 "missing parameters in \"lockDetect <policy>\" line\n",
91 if( strcasecmp( argv[1], "default" ) == 0 ) {
92 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
94 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
95 bdb->bi_lock_detect = DB_LOCK_OLDEST;
97 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
98 bdb->bi_lock_detect = DB_LOCK_RANDOM;
100 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
101 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
103 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
104 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
107 fprintf( stderr, "%s: line %d: "
108 "bad policy (%s) in \"lockDetect <policy>\" line\n",
109 fname, lineno, argv[1] );
113 /* mode with which to create new database files */
114 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
116 fprintf( stderr, "%s: line %d: "
117 "missing mode in \"mode <mode>\" line\n",
121 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
123 /* attribute to index */
124 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
127 fprintf( stderr, "%s: line %d: "
128 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
131 } else if ( argc > 3 ) {
132 fprintf( stderr, "%s: line %d: "
133 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
137 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
139 if( rc != LDAP_SUCCESS ) return 1;
141 /* unique key for shared memory regions */
142 } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) {
145 "%s: line %d: missing key in \"shm_key <key>\" line\n",
149 bdb->bi_shm_key = atoi( argv[1] );
151 /* size of the cache in entries */
152 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
155 "%s: line %d: missing size in \"cachesize <size>\" line\n",
159 bdb->bi_cache.c_maxsize = atoi( argv[1] );
161 /* depth of search stack cache in units of (IDL)s */
162 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
165 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
169 bdb->bi_search_stack_depth = atoi( argv[1] );
170 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
172 "%s: line %d: depth %d too small, using %d\n",
173 fname, lineno, bdb->bi_search_stack_depth,
174 MINIMUM_SEARCH_STACK_DEPTH );
175 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
178 /* size of the IDL cache in entries */
179 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
182 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
186 if ( !( slapMode & SLAP_TOOL_MODE ) )
187 bdb->bi_idl_cache_max_size = atoi( argv[1] );
191 return SLAP_CONF_UNKNOWN;