X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Fovsdb-tool.c;h=61aea75dc57809dc6f44c7eecfe816ec70e20d7a;hb=1e68c0730d0753e9a796a0d6d4b95933f7cdfbd2;hp=5169653d81e88f622a3b429556fc50796a5a421a;hpb=f85f8ebbfac946c19b3c6eb0f4170f579d0a4d25;p=openvswitch diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index 5169653d..61aea75d 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -25,6 +25,7 @@ #include "command-line.h" #include "compiler.h" #include "file.h" +#include "log.h" #include "json.h" #include "ovsdb.h" #include "ovsdb-error.h" @@ -144,7 +145,7 @@ do_create(int argc UNUSED, char *argv[]) const char *db_file_name = argv[1]; const char *schema_file_name = argv[2]; struct ovsdb_schema *schema; - struct ovsdb_file *db_file; + struct ovsdb_log *log; struct json *json; /* Read schema from file and convert to JSON. */ @@ -152,22 +153,22 @@ do_create(int argc UNUSED, char *argv[]) json = ovsdb_schema_to_json(schema); /* Create database file. */ - check_ovsdb_error(ovsdb_file_open(db_file_name, O_RDWR | O_CREAT | O_EXCL, - &db_file)); - check_ovsdb_error(ovsdb_file_write(db_file, json)); - check_ovsdb_error(ovsdb_file_commit(db_file)); - ovsdb_file_close(db_file); + check_ovsdb_error(ovsdb_log_open(db_file_name, O_RDWR | O_CREAT | O_EXCL, + &log)); + check_ovsdb_error(ovsdb_log_write(log, json)); + check_ovsdb_error(ovsdb_log_commit(log)); + ovsdb_log_close(log); json_destroy(json); } static void -transact(int flags, const char *db_file_name, const char *transaction) +transact(bool read_only, const char *db_file_name, const char *transaction) { struct json *request, *result; struct ovsdb *db; - check_ovsdb_error(ovsdb_open(db_file_name, flags, &db)); + check_ovsdb_error(ovsdb_file_open(db_file_name, read_only, &db)); request = parse_json(transaction); result = ovsdb_execute(db, request, 0, NULL); @@ -180,13 +181,13 @@ transact(int flags, const char *db_file_name, const char *transaction) static void do_query(int argc UNUSED, char *argv[]) { - transact(O_RDONLY, argv[1], argv[2]); + transact(true, argv[1], argv[2]); } static void do_transact(int argc UNUSED, char *argv[]) { - transact(O_RDWR, argv[1], argv[2]); + transact(false, argv[1], argv[2]); } static void