2017-12-24 16:19:24 -08:00
|
|
|
/* Copyright (c) 2009, 2010, 2011, 2017 Nicira, Inc.
|
2009-11-04 15:11:44 -08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2009-11-13 13:23:35 -08:00
|
|
|
#ifndef OVSDB_LOG_H
|
|
|
|
#define OVSDB_LOG_H 1
|
2009-11-04 15:11:44 -08:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "compiler.h"
|
|
|
|
|
2017-12-14 13:44:15 -08:00
|
|
|
struct ds;
|
2009-11-04 15:11:44 -08:00
|
|
|
struct json;
|
2009-11-13 13:23:35 -08:00
|
|
|
struct ovsdb_log;
|
2009-11-04 15:11:44 -08:00
|
|
|
|
2010-02-15 11:31:32 -08:00
|
|
|
/* Access mode for opening an OVSDB log. */
|
|
|
|
enum ovsdb_log_open_mode {
|
|
|
|
OVSDB_LOG_READ_ONLY, /* Open existing file, read-only. */
|
|
|
|
OVSDB_LOG_READ_WRITE, /* Open existing file, read/write. */
|
2017-12-05 09:30:26 -08:00
|
|
|
OVSDB_LOG_CREATE_EXCL, /* Create new file, read/write. */
|
|
|
|
OVSDB_LOG_CREATE /* Create or open file, read/write. */
|
2010-02-15 11:31:32 -08:00
|
|
|
};
|
|
|
|
|
2017-12-24 16:19:24 -08:00
|
|
|
/* 'magic' for use with ovsdb_log_open() for OVSDB databases (see ovsdb(5)). */
|
|
|
|
#define OVSDB_MAGIC "JSON"
|
2017-12-24 11:43:59 -08:00
|
|
|
|
|
|
|
struct ovsdb_error *ovsdb_log_open(const char *name, const char *magic,
|
|
|
|
enum ovsdb_log_open_mode,
|
2010-02-15 11:31:32 -08:00
|
|
|
int locking, struct ovsdb_log **)
|
2014-12-15 14:10:38 +01:00
|
|
|
OVS_WARN_UNUSED_RESULT;
|
2009-11-13 13:23:35 -08:00
|
|
|
void ovsdb_log_close(struct ovsdb_log *);
|
2009-11-04 15:11:44 -08:00
|
|
|
|
2017-12-24 16:19:24 -08:00
|
|
|
const char *ovsdb_log_get_magic(const struct ovsdb_log *);
|
|
|
|
|
2009-11-13 13:23:35 -08:00
|
|
|
struct ovsdb_error *ovsdb_log_read(struct ovsdb_log *, struct json **)
|
2014-12-15 14:10:38 +01:00
|
|
|
OVS_WARN_UNUSED_RESULT;
|
2011-03-28 13:05:40 -07:00
|
|
|
void ovsdb_log_unread(struct ovsdb_log *);
|
|
|
|
|
2017-12-24 11:43:59 -08:00
|
|
|
void ovsdb_log_compose_record(const struct json *, const char *magic,
|
2017-12-14 13:44:15 -08:00
|
|
|
struct ds *header, struct ds *data);
|
|
|
|
|
2017-12-05 08:33:50 -08:00
|
|
|
struct ovsdb_error *ovsdb_log_write(struct ovsdb_log *, const struct json *)
|
2014-12-15 14:10:38 +01:00
|
|
|
OVS_WARN_UNUSED_RESULT;
|
2009-11-13 13:23:35 -08:00
|
|
|
struct ovsdb_error *ovsdb_log_commit(struct ovsdb_log *)
|
2014-12-15 14:10:38 +01:00
|
|
|
OVS_WARN_UNUSED_RESULT;
|
2009-11-04 15:11:44 -08:00
|
|
|
|
2010-03-18 11:24:55 -07:00
|
|
|
off_t ovsdb_log_get_offset(const struct ovsdb_log *);
|
|
|
|
|
2017-12-07 14:33:28 -08:00
|
|
|
struct ovsdb_error *ovsdb_log_replace(struct ovsdb_log *,
|
|
|
|
struct json **entries, size_t n)
|
|
|
|
OVS_WARN_UNUSED_RESULT;
|
|
|
|
struct ovsdb_error *ovsdb_log_replace_start(struct ovsdb_log *old,
|
|
|
|
struct ovsdb_log **newp)
|
|
|
|
OVS_WARN_UNUSED_RESULT;
|
|
|
|
struct ovsdb_error *ovsdb_log_replace_commit(struct ovsdb_log *old,
|
|
|
|
struct ovsdb_log *new)
|
|
|
|
OVS_WARN_UNUSED_RESULT;
|
|
|
|
void ovsdb_log_replace_abort(struct ovsdb_log *new);
|
|
|
|
|
|
|
|
/* For testing. */
|
|
|
|
void ovsdb_log_disable_renaming_open_files(void);
|
|
|
|
|
2009-11-13 13:23:35 -08:00
|
|
|
#endif /* ovsdb/log.h */
|