diff options
author | Michael Larson <slioch@slioch.vyatta.com> | 2010-06-09 14:39:42 -0700 |
---|---|---|
committer | Michael Larson <slioch@slioch.vyatta.com> | 2010-06-09 14:39:42 -0700 |
commit | 2bc58238bc4ee5136bf31719b7c7a2435c8012b0 (patch) | |
tree | a0f5514ac1fb99d7c1cd4a95a2075b3900b0933a | |
parent | 9e84035a42dcc335d9799256d7f465c3e3277500 (diff) | |
download | vyatta-cfg-2bc58238bc4ee5136bf31719b7c7a2435c8012b0.tar.gz vyatta-cfg-2bc58238bc4ee5136bf31719b7c7a2435c8012b0.zip |
cleanup and fix cases to handle activated deleted multinodes correctly. simplified deactivated nodes logic in commit.
-rw-r--r-- | src/commit2.c | 13 | ||||
-rw-r--r-- | src/common/unionfs.c | 43 | ||||
-rw-r--r-- | src/common/unionfs.h | 2 |
3 files changed, 37 insertions, 21 deletions
diff --git a/src/commit2.c b/src/commit2.c index d5ed4d0..fabc7ae 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -752,7 +752,7 @@ sort_func(GNode *node, gpointer data, boolean priority_mode) } else if ((d->_disable_op & K_LOCAL_DISABLE_OP) && !(d->_disable_op & K_ACTIVE_DISABLE_OP)) { //node will be deactivated on commit - //LET'S SPOOF the operation... convert it to DELETE + //LET'S SPOOF the operation... convert it to DELETE op = K_DEL_OP; } } @@ -784,9 +784,10 @@ sort_func(GNode *node, gpointer data, boolean priority_mode) while (TRUE) { n = n->parent; vtw_def def = ((struct VyattaNode*)(n->data))->_config._def; - ((struct VyattaNode*)(n->data))->_data._operation = ((struct VyattaNode*)gp)->_data._operation; + // ((struct VyattaNode*)(n->data))->_data._operation = ((struct VyattaNode*)gp)->_data._operation; //DON'T set active when only in disable state... - if (((struct VyattaNode*)(n->data))->_data._disable_op == K_NO_DISABLE_OP) { + // if (((struct VyattaNode*)(n->data))->_data._disable_op == K_NO_DISABLE_OP) { + if (((struct VyattaNode*)(n->data))->_data._operation == K_NO_OP) { ((struct VyattaNode*)(n->data))->_data._operation |= K_ACTIVE_OP; } if (def.actions[end_act].vtw_list_head || def.actions[begin_act].vtw_list_head) { @@ -967,13 +968,13 @@ dump_func(GNode *node, gpointer data) char disable_op[2]; if (((struct VyattaNode*)gp)->_data._disable_op == (K_ACTIVE_DISABLE_OP | K_LOCAL_DISABLE_OP)) { - disable_op[0] = 'c'; + disable_op[0] = '!'; } else if (((struct VyattaNode*)gp)->_data._disable_op == K_ACTIVE_DISABLE_OP) { - disable_op[0] = 'u'; + disable_op[0] = 'A'; } else if (((struct VyattaNode*)gp)->_data._disable_op == K_LOCAL_DISABLE_OP) { - disable_op[0] = 's'; + disable_op[0] = 'D'; } else { disable_op[0] = ' '; diff --git a/src/common/unionfs.c b/src/common/unionfs.c index db3addd..d96ef0e 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -340,9 +340,11 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root, if (strcmp(dirp->d_name, ".") != 0 && strcmp(dirp->d_name, "..") != 0 && strcmp(dirp->d_name, MODIFIED_FILE) != 0 && + strcmp(dirp->d_name, UNSAVED_FILE) != 0 && strcmp(dirp->d_name, DEF_FILE) != 0 && strcmp(dirp->d_name, DISABLE_FILE) != 0 && strcmp(dirp->d_name, WHITEOUT_FILE) != 0 && + strcmp(dirp->d_name, WHITEOUT_DISABLE_FILE) != 0 && strcmp(dirp->d_name, VALUE_FILE) != 0) { processed = TRUE; @@ -365,24 +367,12 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root, } char *data_buf = malloc(MAX_LENGTH_DIR_PATH*sizeof(char)); - if (strncmp(dirp->d_name,DELETED_NODE,4) == 0 || - deactivated != K_NO_DISABLE_OP) { - + if (strncmp(dirp->d_name,DELETED_NODE,4) == 0) { struct VyattaNode *vn = calloc(1,sizeof(struct VyattaNode)); if (strncmp(dirp->d_name,DELETED_NODE,4) == 0) { strcpy(data_buf,dirp->d_name+4); //SKIP THE .WH. - - //special test for deleted .disable file. - char buf[MAX_LENGTH_HELP_STR]; - sprintf(buf,"%s/%s/%s/%s",get_adirp(),rel_data_path,data_buf,DISABLE_FILE); - struct stat s; - if (lstat(buf,&s) == 0) { - vn->_data._operation = K_NO_OP; - } - else { - vn->_data._operation = K_DEL_OP; - } + vn->_data._operation = K_DEL_OP; } else { strcpy(data_buf,dirp->d_name); @@ -405,6 +395,29 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root, //will need to enter a special recursion against the active configuration to mark nested delete nodes retrieve_data(new_data_path,new_node,get_adirp(),K_DEL_OP); } + else if (deactivated != K_NO_DISABLE_OP) { + //NEED TO RECURSE DOWN THE ACTIVE PATH THEN. + struct VyattaNode *vn = calloc(1,sizeof(struct VyattaNode)); + + strcpy(data_buf,dirp->d_name); + vn->_data._operation = K_NO_OP; + + //create new node and insert... + vn->_data._name = data_buf; + vn->_data._value = FALSE; + vn->_config._priority = LOWEST_PRIORITY; + vn->_data._disable_op = deactivated; + + char new_data_path[MAX_LENGTH_DIR_PATH]; + sprintf(new_data_path,"%s/%s",rel_data_path,data_buf); + + GNode *new_node = g_node_new(vn); + // new_node = g_node_insert(node, -1, new_node); + new_node = insert_sibling_in_order(node,new_node); + + //will need to enter a special recursion against the active configuration to mark nested delete nodes + retrieve_data(new_data_path,new_node,get_adirp(),K_NO_OP); + } else { strcpy(data_buf,dirp->d_name); //create new node and insert... @@ -435,7 +448,7 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root, GNode *new_node = g_node_new(vn); // new_node = g_node_insert(node, -1, new_node); new_node = insert_sibling_in_order(node,new_node); - if (op == K_DEL_OP) { + if (op == K_DEL_OP || vn->_data._disable_op != K_NO_DISABLE_OP) { retrieve_data(new_data_path,new_node,get_adirp(),vn->_data._operation); } else { diff --git a/src/common/unionfs.h b/src/common/unionfs.h index 2933deb..7881594 100644 --- a/src/common/unionfs.h +++ b/src/common/unionfs.h @@ -23,9 +23,11 @@ #define NODE_TAG_FILE "node.tag" #define VALUE_FILE "node.val" #define MODIFIED_FILE ".modified" +#define UNSAVED_FILE ".unsaved" #define DISABLE_FILE ".disable" #define DEF_FILE "def" #define WHITEOUT_FILE ".wh.__dir_opaque" +#define WHITEOUT_DISABLE_FILE ".wh..disable" #define DELETED_NODE ".wh." #define MAX_LENGTH_DIR_PATH 1024 |