VLOG_MODULE(openflowd)
VLOG_MODULE(ovsdb)
VLOG_MODULE(ovsdb_client)
-VLOG_MODULE(ovsdb_file)
+VLOG_MODULE(ovsdb_log)
VLOG_MODULE(ovsdb_jsonrpc_server)
VLOG_MODULE(ovsdb_server)
VLOG_MODULE(ovsdb_tool)
ovsdb/condition.c \
ovsdb/condition.h \
ovsdb/execution.c \
- ovsdb/file.c \
- ovsdb/file.h \
ovsdb/jsonrpc-server.c \
ovsdb/jsonrpc-server.h \
+ ovsdb/log.c \
+ ovsdb/log.h \
ovsdb/ovsdb-server.c \
ovsdb/ovsdb.c \
ovsdb/ovsdb.h \
#include "column.h"
#include "condition.h"
-#include "file.h"
#include "json.h"
+#include "log.h"
#include "ovsdb-data.h"
#include "ovsdb-error.h"
#include "ovsdb-parser.h"
static struct ovsdb_error *
do_commit(struct ovsdb_execution *x)
{
- if (x->db->file) {
+ if (x->db->log) {
struct ovsdb_error *error;
struct json *json;
return NULL;
}
- error = ovsdb_file_write(x->db->file, json);
+ error = ovsdb_log_write(x->db->log, json);
json_destroy(json);
if (error) {
return ovsdb_wrap_error(error, "writing transaction failed");
}
if (x->durable) {
- error = ovsdb_file_commit(x->db->file);
+ error = ovsdb_log_commit(x->db->log);
if (error) {
return ovsdb_wrap_error(error,
"committing transaction failed");
#include <config.h>
-#include "file.h"
+#include "log.h"
#include <assert.h>
#include <errno.h>
#include "json.h"
#include "lockfile.h"
+#include "ovsdb.h"
#include "ovsdb-error.h"
#include "sha1.h"
+#include "transaction.h"
#include "util.h"
-#define THIS_MODULE VLM_ovsdb_file
+#define THIS_MODULE VLM_ovsdb_log
#include "vlog.h"
-enum ovsdb_file_mode {
- OVSDB_FILE_READ,
- OVSDB_FILE_WRITE
+enum ovsdb_log_mode {
+ OVSDB_LOG_READ,
+ OVSDB_LOG_WRITE
};
-struct ovsdb_file {
+struct ovsdb_log {
off_t offset;
char *name;
struct lockfile *lockfile;
FILE *stream;
struct ovsdb_error *read_error;
struct ovsdb_error *write_error;
- enum ovsdb_file_mode mode;
+ enum ovsdb_log_mode mode;
};
struct ovsdb_error *
-ovsdb_file_open(const char *name, int flags, struct ovsdb_file **filep)
+ovsdb_log_open(const char *name, int flags, struct ovsdb_log **filep)
{
struct lockfile *lockfile;
struct ovsdb_error *error;
- struct ovsdb_file *file;
+ struct ovsdb_log *file;
struct stat s;
FILE *stream;
int accmode;
file->offset = 0;
file->read_error = NULL;
file->write_error = NULL;
- file->mode = OVSDB_FILE_READ;
+ file->mode = OVSDB_LOG_READ;
*filep = file;
return NULL;
}
void
-ovsdb_file_close(struct ovsdb_file *file)
+ovsdb_log_close(struct ovsdb_log *file)
{
if (file) {
free(file->name);
return true;
}
-struct ovsdb_file_read_cbdata {
+struct ovsdb_log_read_cbdata {
char input[4096];
- struct ovsdb_file *file;
+ struct ovsdb_log *file;
int error;
unsigned long length;
};
static struct ovsdb_error *
-parse_body(struct ovsdb_file *file, off_t offset, unsigned long int length,
+parse_body(struct ovsdb_log *file, off_t offset, unsigned long int length,
uint8_t sha1[SHA1_DIGEST_SIZE], struct json **jsonp)
{
unsigned long int bytes_left;
}
struct ovsdb_error *
-ovsdb_file_read(struct ovsdb_file *file, struct json **jsonp)
+ovsdb_log_read(struct ovsdb_log *file, struct json **jsonp)
{
uint8_t expected_sha1[SHA1_DIGEST_SIZE];
uint8_t actual_sha1[SHA1_DIGEST_SIZE];
if (file->read_error) {
return ovsdb_error_clone(file->read_error);
- } else if (file->mode == OVSDB_FILE_WRITE) {
+ } else if (file->mode == OVSDB_LOG_WRITE) {
return OVSDB_BUG("reading file in write mode");
}
}
struct ovsdb_error *
-ovsdb_file_write(struct ovsdb_file *file, struct json *json)
+ovsdb_log_write(struct ovsdb_log *file, struct json *json)
{
uint8_t sha1[SHA1_DIGEST_SIZE];
struct ovsdb_error *error;
if (file->write_error) {
return ovsdb_error_clone(file->write_error);
- } else if (file->mode == OVSDB_FILE_READ) {
- file->mode = OVSDB_FILE_WRITE;
+ } else if (file->mode == OVSDB_LOG_READ) {
+ file->mode = OVSDB_LOG_WRITE;
if (fseeko(file->stream, file->offset, SEEK_SET)) {
error = ovsdb_io_error(errno, "%s: cannot seek to offset %lld",
file->name, (long long int) file->offset);
}
struct ovsdb_error *
-ovsdb_file_commit(struct ovsdb_file *file)
+ovsdb_log_commit(struct ovsdb_log *file)
{
if (fsync(fileno(file->stream))) {
return ovsdb_io_error(errno, "%s: fsync failed", file->name);
}
return 0;
}
+
* limitations under the License.
*/
-#ifndef OVSDB_FILE_H
-#define OVSDB_FILE_H 1
+#ifndef OVSDB_LOG_H
+#define OVSDB_LOG_H 1
#include <sys/types.h>
#include "compiler.h"
struct json;
-struct ovsdb_file;
+struct ovsdb_log;
-struct ovsdb_error *ovsdb_file_open(const char *name, int flags,
- struct ovsdb_file **) WARN_UNUSED_RESULT;
-void ovsdb_file_close(struct ovsdb_file *);
+struct ovsdb_error *ovsdb_log_open(const char *name, int flags,
+ struct ovsdb_log **) WARN_UNUSED_RESULT;
+void ovsdb_log_close(struct ovsdb_log *);
-struct ovsdb_error *ovsdb_file_read(struct ovsdb_file *, struct json **)
+struct ovsdb_error *ovsdb_log_read(struct ovsdb_log *, struct json **)
WARN_UNUSED_RESULT;
-struct ovsdb_error *ovsdb_file_write(struct ovsdb_file *, struct json *)
+struct ovsdb_error *ovsdb_log_write(struct ovsdb_log *, struct json *)
WARN_UNUSED_RESULT;
-struct ovsdb_error *ovsdb_file_commit(struct ovsdb_file *)
+struct ovsdb_error *ovsdb_log_commit(struct ovsdb_log *)
WARN_UNUSED_RESULT;
-#endif /* ovsdb/file.h */
+#endif /* ovsdb/log.h */
#include "command-line.h"
#include "compiler.h"
-#include "file.h"
+#include "log.h"
#include "json.h"
#include "ovsdb.h"
#include "ovsdb-error.h"
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. */
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);
}
#include <fcntl.h>
-#include "file.h"
+#include "log.h"
#include "json.h"
#include "ovsdb-error.h"
#include "ovsdb-parser.h"
}
\f
struct ovsdb *
-ovsdb_create(struct ovsdb_file *file, struct ovsdb_schema *schema)
+ovsdb_create(struct ovsdb_log *log, struct ovsdb_schema *schema)
{
struct shash_node *node;
struct ovsdb *db;
db = xmalloc(sizeof *db);
db->schema = schema;
- db->file = file;
+ db->log = log;
list_init(&db->triggers);
db->run_triggers = false;
{
struct ovsdb_schema *schema;
struct ovsdb_error *error;
- struct ovsdb_file *file;
+ struct ovsdb_log *log;
struct json *json;
struct ovsdb *db;
- error = ovsdb_file_open(file_name, read_only ? O_RDONLY : O_RDWR, &file);
+ error = ovsdb_log_open(file_name, read_only ? O_RDONLY : O_RDWR, &log);
if (error) {
return error;
}
- error = ovsdb_file_read(file, &json);
+ error = ovsdb_log_read(log, &json);
if (error) {
return error;
} else if (!json) {
}
json_destroy(json);
- db = ovsdb_create(read_only ? NULL : file, schema);
- while ((error = ovsdb_file_read(file, &json)) == NULL && json) {
+ db = ovsdb_create(read_only ? NULL : log, schema);
+ while ((error = ovsdb_log_read(log, &json)) == NULL && json) {
struct ovsdb_txn *txn;
error = ovsdb_txn_from_json(db, json, &txn);
}
if (read_only) {
- ovsdb_file_close(file);
+ ovsdb_log_close(log);
}
*dbp = db;
shash_clear(&db->schema->tables);
ovsdb_schema_destroy(db->schema);
- ovsdb_file_close(db->file);
+ ovsdb_log_close(db->log);
free(db);
}
}
/* Database. */
struct ovsdb {
struct ovsdb_schema *schema;
- struct ovsdb_file *file; /* Disk file (null for in-memory db). */
+ struct ovsdb_log *log; /* Disk log (null for in-memory db). */
struct shash tables; /* Contains "struct ovsdb_table *"s. */
/* Triggers. */
bool run_triggers;
};
-struct ovsdb *ovsdb_create(struct ovsdb_file *, struct ovsdb_schema *);
+struct ovsdb *ovsdb_create(struct ovsdb_log *, struct ovsdb_schema *);
struct ovsdb_error *ovsdb_open(const char *file_name, bool read_only,
struct ovsdb **)
WARN_UNUSED_RESULT;
tests/lockfile.at \
tests/reconnect.at \
tests/ovsdb.at \
- tests/ovsdb-file.at \
+ tests/ovsdb-log.at \
tests/ovsdb-types.at \
tests/ovsdb-data.at \
tests/ovsdb-column.at \
-AT_BANNER([OVSDB -- file I/O])
+AT_BANNER([OVSDB -- logging])
AT_SETUP([create empty, reread])
-AT_KEYWORDS([ovsdb file])
-AT_CAPTURE_FILE([file])
+AT_KEYWORDS([ovsdb log])
+AT_CAPTURE_FILE([log])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_CREAT|O_RDWR'], [0],
+ [test-ovsdb log-io file 'O_CREAT|O_RDWR'], [0],
[file: open successful
], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read], [0],
[file: open successful
-file: read: end of file
+file: read: end of log
], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write one, reread])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]']], [0],
[[file: open successful
file: write:[0] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read], [0],
[[file: open successful
file: read: [0]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([check that O_EXCL works])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[1]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[1]']], [0],
[[file: open successful
file: write:[1] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read], [0],
[[file: open successful
file: read: [1]
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_CREAT|O_RDWR|O_EXCL' read], [1],
+ [test-ovsdb log-io file 'O_CREAT|O_RDWR|O_EXCL' read], [1],
[], [test-ovsdb: I/O error: create: file failed (File exists)
])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write one, reread])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
file: write:[2] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write one, reread, append])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
file: write:[2] successful
]], [ignore])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read 'write:["append"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read 'write:["append"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: write:["append"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
file: read: ["append"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, reread one, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
file: write:[2] successful
]], [ignore])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read 'write:["more data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read 'write:["more data"]']], [0],
[[file: open successful
file: read: [0]
file: write:["more data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read], [0],
[[file: open successful
file: read: [0]
file: read: ["more data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, add corrupted data, read])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
]], [ignore])
AT_CHECK([echo 'xxx' >> file])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
AT_CLEANUP
AT_SETUP([write, add corrupted data, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
]], [ignore])
AT_CHECK([echo 'xxx' >> file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read read 'write:[3]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read read 'write:[3]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: write:[3] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
file: read: [3]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, corrupt some data, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
AT_CHECK([[grep -c '\[3]' file]], [0], [1
])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: write:["longer data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: ["longer data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write, truncate file, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
AT_CHECK([[grep -c '^2$' file]], [0], [1
])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read 'write:["longer data"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: write:["longer data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: ["longer data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
AT_SETUP([write bad JSON, read, overwrite])
-AT_KEYWORDS([ovsdb file])
+AT_KEYWORDS([ovsdb log])
AT_CAPTURE_FILE([file])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
+ [[test-ovsdb log-io file 'O_CREAT|O_RDWR' 'write:[0]' 'write:[1]' 'write:[2]']], [0],
[[file: open successful
file: write:[0] successful
file: write:[1] successful
]], [ignore])
AT_CHECK([[printf '%s\n%s\n' 'OVSDB JSON 5 d910b02871075d3156ec8675dfc95b7d5d640aa6' 'null' >> file]])
OVS_CHECK_LCOV(
- [[test-ovsdb file-io file 'O_RDWR' read read read read 'write:["replacement data"]']], [0],
+ [[test-ovsdb log-io file 'O_RDWR' read read read read 'write:["replacement data"]']], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: write:["replacement data"] successful
]], [ignore])
OVS_CHECK_LCOV(
- [test-ovsdb file-io file 'O_RDONLY' read read read read read], [0],
+ [test-ovsdb log-io file 'O_RDONLY' read read read read read], [0],
[[file: open successful
file: read: [0]
file: read: [1]
file: read: [2]
file: read: ["replacement data"]
-file: read: end of file
+file: read: end of log
]], [ignore])
AT_CHECK([test -f .file.~lock~])
AT_CLEANUP
[0], [ignore], [ignore])
AT_CLEANUP])
-m4_include([tests/ovsdb-file.at])
+m4_include([tests/ovsdb-log.at])
m4_include([tests/ovsdb-types.at])
m4_include([tests/ovsdb-data.at])
m4_include([tests/ovsdb-column.at])
#include "ovsdb-types.h"
#include "ovsdb/column.h"
#include "ovsdb/condition.h"
-#include "ovsdb/file.h"
+#include "ovsdb/log.h"
#include "ovsdb/ovsdb.h"
#include "ovsdb/query.h"
#include "ovsdb/row.h"
{
printf("%s: Open vSwitch database test utility\n"
"usage: %s [OPTIONS] COMMAND [ARG...]\n\n"
- " file-io FILE FLAGS COMMAND...\n"
+ " log-io FILE FLAGS COMMAND...\n"
" open FILE with FLAGS, run COMMANDs\n"
" parse-atomic-type TYPE\n"
" parse TYPE as OVSDB atomic type, and re-serialize\n"
/* Command implementations. */
static void
-do_file_io(int argc, char *argv[])
+do_log_io(int argc, char *argv[])
{
const char *name = argv[1];
char *mode = argv[2];
struct ovsdb_error *error;
- struct ovsdb_file *file;
+ struct ovsdb_log *log;
char *save_ptr = NULL;
const char *token;
int flags;
}
}
- check_ovsdb_error(ovsdb_file_open(name, flags, &file));
+ check_ovsdb_error(ovsdb_log_open(name, flags, &log));
printf("%s: open successful\n", name);
for (i = 3; i < argc; i++) {
if (!strcmp(command, "read")) {
struct json *json;
- error = ovsdb_file_read(file, &json);
+ error = ovsdb_log_read(log, &json);
if (!error) {
printf("%s: read: ", name);
if (json) {
print_and_free_json(json);
} else {
- printf("end of file\n");
+ printf("end of log\n");
}
continue;
}
} else if (!strncmp(command, "write:", 6)) {
struct json *json = parse_json(command + 6);
- error = ovsdb_file_write(file, json);
+ error = ovsdb_log_write(log, json);
json_destroy(json);
} else if (!strcmp(command, "commit")) {
- error = ovsdb_file_commit(file);
+ error = ovsdb_log_commit(log);
} else {
- ovs_fatal(0, "unknown file-io command \"%s\"", command);
+ ovs_fatal(0, "unknown log-io command \"%s\"", command);
}
if (error) {
char *s = ovsdb_error_to_string(error);
}
}
- ovsdb_file_close(file);
+ ovsdb_log_close(log);
}
static void
}
static struct command all_commands[] = {
- { "file-io", 2, INT_MAX, do_file_io },
+ { "log-io", 2, INT_MAX, do_log_io },
{ "parse-atomic-type", 1, 1, do_parse_atomic_type },
{ "parse-type", 1, 1, do_parse_type },
{ "parse-atoms", 2, INT_MAX, do_parse_atoms },