summaryrefslogtreecommitdiff
path: root/src/cstore/unionfs/cstore-unionfs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cstore/unionfs/cstore-unionfs.cpp')
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index 6ccdbf2..41ce008 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -63,6 +63,7 @@ const string UnionfsCstore::C_COMMENT_FILE = ".comment";
const string UnionfsCstore::C_TAG_NAME = "node.tag";
const string UnionfsCstore::C_VAL_NAME = "node.val";
const string UnionfsCstore::C_DEF_NAME = "node.def";
+const string UnionfsCstore::C_COMMIT_LOCK_FILE = "/opt/vyatta/config/.lock";
////// static
@@ -696,6 +697,23 @@ UnionfsCstore::commitConfig(commit::PrioNode& node)
return true;
}
+bool
+UnionfsCstore::getCommitLock()
+{
+ int fd = creat(C_COMMIT_LOCK_FILE.c_str(), 0777);
+ if (fd < 0) {
+ // should not happen since all commit processes should have write access
+ output_internal("getCommitLock() failed to open lock file\n");
+ return false;
+ }
+ if (lockf(fd, F_TLOCK, 0) < 0) {
+ // locked by someone else
+ return false;
+ }
+ // got the lock
+ return true;
+}
+
////// virtual functions defined in base class
/* check if current tmpl_path is a valid tmpl dir.