diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-03-09 22:40:07 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-03-09 22:40:07 -0700 |
commit | f51be17447504aed009f3b31fd6868f02019445d (patch) | |
tree | 3a82782aa94ad8d760538b00adde68b234b04520 /src | |
parent | 9597176ac1f7f2ddee37fc78102185e844bca70f (diff) | |
parent | bd48938b3dc1634c64c6d099ccf5d193d94c4019 (diff) | |
download | vyatta-cfg-f51be17447504aed009f3b31fd6868f02019445d.tar.gz vyatta-cfg-f51be17447504aed009f3b31fd6868f02019445d.zip |
Merge branch 'jenner' of suva.vyatta.com:/git/vyatta-cfg into jenner
Diffstat (limited to 'src')
-rw-r--r-- | src/commit2.c | 5 | ||||
-rw-r--r-- | src/common/unionfs.c | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/commit2.c b/src/commit2.c index 0d77fb6..e6b63fa 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <syslog.h> #include <sys/time.h> #include <glib-2.0/glib.h> #include "common/common.h" @@ -231,6 +232,9 @@ main(int argc, char** argv) if (disable_partial_commit == TRUE) { complete(orig_node_tree, test_mode); } + /* + * Need to add to the following func below to clean up dangling .wh. files + */ common_commit_clean_temp_config(test_mode); if (g_debug == TRUE) { printf("commit2: successful commit, now cleaning up temp directories\n"); @@ -363,6 +367,7 @@ process_func(GNode *node, gpointer data) } if (!status) { //EXECUTE_LIST RETURNS FALSE ON FAILURE.... + syslog(LOG_ERR,"commit error for %s:[%s]\n",ActionNames[result->_action],d->_path); if (g_display_error_node) { fprintf(out_stream,"%s:[%s]\n",ActionNames[result->_action],d->_path); } diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 4cb2ed6..4e62b01 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -524,6 +524,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) } char *command = malloc(MAX_LENGTH_DIR_PATH); static const char format0[]="mkdir -p %s ; /bin/true"; + static const char formatpoint5[]="rm -fr %s"; /*tmpp*/ static const char format1[]="cp -r -f %s/* %s"; /*mdirp, tmpp*/ static const char format2[]="sudo umount %s"; //mdirp @@ -564,6 +565,16 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) return; } + //have to clean out tbuf before copying + sprintf(command, formatpoint5, tbuf); + if (g_debug) { + printf("%s\n",command); + fflush(NULL); + } + if (test_mode == FALSE) { + system(command); + } + //mkdir temp merge sprintf(command,format0,tbuf); if (g_debug) { @@ -574,6 +585,8 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) system(command); } + + //cp merge to temp merge sprintf(command, format1, mbuf, tbuf); if (g_debug) { @@ -622,6 +635,13 @@ common_commit_clean_temp_config(boolean test_mode) } //first clean up the root // common_commit_copy_to_live_config("/"); + + /* + * Need to add to the following func below to clean up dangling .wh. files. + * This pass needs to be prior to the commands below (but after the umount). + * This fixes a bug when higher priority root nodes are deleted and not removed. + */ + char *command; command = malloc(MAX_LENGTH_DIR_PATH); @@ -1020,12 +1040,28 @@ copy_func(GNode *node, gpointer data) struct SrcDst *sd = (struct SrcDst*)data; static const char format[]="mkdir -p %s%s";/*tmpp, adirp*/ static const char format_value[]="cp %s%s{node.val,def} %s%s. 2>/dev/null";/*tmpp, adirp*/ + static const char clear_def[]="rm %s%sdef 2>/dev/null";/*adirp*/ char *path = ((struct VyattaNode*)(node->data))->_data._path; //might not work for terminating multinodes as the node.val won't be copied if (((struct VyattaNode*)(node->data))->_data._value == TRUE && ((struct VyattaNode*)(node->data))->_config._def.tag == FALSE) { //THIS IS ONLY FOR NODE.VAL (or leafs, term multis) + + //before copy also need to clear out def file in active directory (will copy over current if found) + //this is for the case where it is set by default, then unset at the node--i.e. no longer a default value. + if (((struct VyattaNode*)(node->data))->_config._multi == FALSE) { //only for leaf + char *parent_path = ((struct VyattaNode*)(node->parent->data))->_data._path; + sprintf(command,clear_def,sd->_dst,parent_path,sd->_dst,parent_path); + if (g_debug) { + printf("%s\n",command); + fflush(NULL); + } + if (sd->_test_mode == FALSE) { + system(command); + } + } + char *parent_path = ((struct VyattaNode*)(node->parent->data))->_data._path; sprintf(command,format_value,sd->_src,parent_path,sd->_dst,parent_path); if (g_debug) { |