MCPcopy Create free account
hub / github.com/apache/httpd / dav_propdb_open

Function dav_propdb_open

modules/dav/fs/dbm.c:415–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415static dav_error * dav_propdb_open(apr_pool_t *pool,
416 const dav_resource *resource, int ro,
417 dav_db **pdb)
418{
419 dav_db *db;
420 dav_error *err;
421 apr_datum_t key;
422 apr_datum_t value = { 0 };
423
424 *pdb = NULL;
425
426 /*
427 ** Return if an error occurred, or there is no database.
428 **
429 ** NOTE: db could be NULL if we attempted to open a readonly
430 ** database that doesn't exist. If we require read/write
431 ** access, then a database was created and opened.
432 */
433 if ((err = dav_dbm_open(pool, resource, ro, &db)) != NULL
434 || db == NULL)
435 return err;
436
437 db->uri_index = apr_hash_make(pool);
438
439 key.dptr = DAV_GDBM_NS_KEY;
440 key.dsize = DAV_GDBM_NS_KEY_LEN;
441 if ((err = dav_dbm_fetch(db, key, &value)) != NULL) {
442 /* ### push a higher-level description? */
443 return err;
444 }
445
446 if (value.dptr == NULL) {
447 dav_propdb_metadata m = {
448 DAV_DBVSN_MAJOR, DAV_DBVSN_MINOR, 0
449 };
450
451 /*
452 ** If there is no METADATA key, then the database may be
453 ** from versions 0.9.0 .. 0.9.4 (which would be incompatible).
454 ** These can be identified by the presence of an NS_TABLE entry.
455 */
456 key.dptr = "NS_TABLE";
457 key.dsize = 8;
458 if (dav_dbm_exists(db, key)) {
459 dav_dbm_close(db);
460
461 /* call it a major version error */
462 return dav_new_error(pool, HTTP_INTERNAL_SERVER_ERROR,
463 DAV_ERR_PROP_BAD_MAJOR, 0,
464 "Prop database has the wrong major "
465 "version number and cannot be used.");
466 }
467
468 /* initialize a new metadata structure */
469 dav_set_bufsize(pool, &db->ns_table, sizeof(m));
470 memcpy(db->ns_table.buf, &m, sizeof(m));
471 }
472 else {

Callers

nothing calls this directly

Calls 7

dav_dbm_openFunction · 0.85
dav_dbm_fetchFunction · 0.85
dav_dbm_existsFunction · 0.85
dav_dbm_closeFunction · 0.85
dav_new_errorFunction · 0.85
dav_set_bufsizeFunction · 0.85
dav_dbm_freedatumFunction · 0.85

Tested by

no test coverage detected