summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2012-03-18 14:56:44 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-04-05 11:20:09 -0700
commit5866ee2f1560e27dff4d60f09429818ab8401333 (patch)
treefbf304eb34b7fe5209e68005096cbf722fb48b8a
parent31c43691242c234c1c9bca336eda6647b79d1442 (diff)
downloadding-libs-5866ee2f1560e27dff4d60f09429818ab8401333.tar.gz
ding-libs-5866ee2f1560e27dff4d60f09429818ab8401333.tar.xz
ding-libs-5866ee2f1560e27dff4d60f09429818ab8401333.zip
Function to check for changes
Added function to detect changes to the configuration file.
-rw-r--r--ini/ini_configobj.h4
-rw-r--r--ini/ini_fileobj.c34
2 files changed, 36 insertions, 2 deletions
diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index eccad71..913b91e 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -335,8 +335,8 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx,
* - device ID
* - i-node
*/
-int ini_config_changed(struct ini_cfgfile *file_ctx,
- struct ini_cfgfile *file_ctx_saved,
+int ini_config_changed(struct ini_cfgfile *file_ctx1,
+ struct ini_cfgfile *file_ctx2,
int *changed);
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 5764933..552cedd 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -484,3 +484,37 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx,
return EOK;
}
+
+/* Determins if two file contexts are different by comparing:
+ * - time stamp
+ * - device ID
+ * - i-node
+ */
+int ini_config_changed(struct ini_cfgfile *file_ctx1,
+ struct ini_cfgfile *file_ctx2,
+ int *changed)
+{
+ TRACE_FLOW_ENTRY();
+
+ if ((file_ctx1 == NULL) ||
+ (file_ctx2 == NULL) ||
+ (changed == NULL)) {
+ TRACE_ERROR_NUMBER("Invalid parameter.", EINVAL);
+ return EINVAL;
+ }
+
+ *changed = 0;
+
+ if((file_ctx1->file_stats.st_mtime !=
+ file_ctx2->file_stats.st_mtime) ||
+ (file_ctx1->file_stats.st_dev !=
+ file_ctx2->file_stats.st_dev) ||
+ (file_ctx1->file_stats.st_ino !=
+ file_ctx2->file_stats.st_ino)) {
+ TRACE_INFO_STRING("File changed!", "");
+ *changed = 1;
+ }
+
+ TRACE_FLOW_EXIT();
+ return EOK;
+}