+ if (logp) {
+ *logp = log;
+ } else {
+ ovsdb_log_close(log);
+ }
+ if (schemap) {
+ *schemap = schema;
+ }
+ return NULL;
+
+error:
+ ovsdb_log_close(log);
+ json_destroy(json);
+ if (logp) {
+ *logp = NULL;
+ }
+ if (schemap) {
+ *schemap = NULL;
+ }
+ return error;
+}
+
+static struct ovsdb_error *
+ovsdb_file_open__(const char *file_name,
+ const struct ovsdb_schema *alternate_schema,
+ bool read_only, struct ovsdb **dbp,
+ struct ovsdb_file **filep)
+{
+ enum ovsdb_log_open_mode open_mode;
+ unsigned int n_transactions;
+ struct ovsdb_schema *schema = NULL;
+ struct ovsdb_error *error;
+ struct ovsdb_log *log;
+ struct json *json;
+ struct ovsdb *db = NULL;
+
+ /* In read-only mode there is no ovsdb_file so 'filep' must be null. */
+ ovs_assert(!(read_only && filep));
+
+ open_mode = read_only ? OVSDB_LOG_READ_ONLY : OVSDB_LOG_READ_WRITE;
+ error = ovsdb_file_open_log(file_name, open_mode, &log,
+ alternate_schema ? NULL : &schema);
+ if (error) {
+ goto error;
+ }
+
+ db = ovsdb_create(schema ? schema : ovsdb_schema_clone(alternate_schema));