From aa8c622a156a14b4d61cb8d98162df31505904fc Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 20 May 2009 14:32:42 -0700 Subject: [PATCH] cfg: Add new function cfg_is_dirty(). --- lib/cfg.c | 10 ++++++++++ lib/cfg.h | 1 + utilities/ovs-cfg-mod.c | 7 +------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/cfg.c b/lib/cfg.c index 67545f37..a6595a58 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -254,6 +254,8 @@ cfg_read(void) } svec_destroy(&old_cfg); + dirty = false; + return 0; } @@ -392,6 +394,14 @@ cfg_write_data(uint8_t *data, size_t len) return retval; } +/* Returns true if the configuration has changed since the last time it was + * read or written. */ +bool +cfg_is_dirty(void) +{ + return dirty; +} + void cfg_buf_put(struct ofpbuf *buffer) { diff --git a/lib/cfg.h b/lib/cfg.h index 1216e062..ebd93784 100644 --- a/lib/cfg.h +++ b/lib/cfg.h @@ -43,6 +43,7 @@ int cfg_lock(uint8_t *cookie, int timeout); void cfg_unlock(void); int cfg_write(void); int cfg_write_data(uint8_t *data, size_t len); +bool cfg_is_dirty(void); void cfg_get_all(struct svec *); diff --git a/utilities/ovs-cfg-mod.c b/utilities/ovs-cfg-mod.c index fdda7534..cb21a8d8 100644 --- a/utilities/ovs-cfg-mod.c +++ b/utilities/ovs-cfg-mod.c @@ -144,7 +144,6 @@ int main(int argc, char *argv[]) }; char *short_options; bool config_set = false; - bool modified = false; set_program_name(argv[0]); time_init(); @@ -172,22 +171,18 @@ int main(int argc, char *argv[]) case 'a': cfg_add_entry("%s", optarg); - modified = true; break; case 'd': cfg_del_entry("%s", optarg); - modified = true; break; case 'D': cfg_del_section("%s", optarg); - modified = true; break; case OPT_DEL_MATCH: cfg_del_match("%s", optarg); - modified = true; break; case 'q': @@ -224,7 +219,7 @@ int main(int argc, char *argv[]) "(use --help for help)"); } - if (modified) { + if (cfg_is_dirty()) { cfg_write(); } cfg_unlock(); -- 2.30.2