summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commit2.cpp100
-rw-r--r--src/common/defs.h7
-rw-r--r--src/common/unionfs.c80
-rw-r--r--src/common/unionfs.h2
-rw-r--r--src/cstore/ctemplate.hpp2
5 files changed, 28 insertions, 163 deletions
diff --git a/src/commit2.cpp b/src/commit2.cpp
index f3ec50f..45d53bc 100644
--- a/src/commit2.cpp
+++ b/src/commit2.cpp
@@ -527,31 +527,10 @@ process_func(GNode *node, gpointer data)
if (c->_def.actions &&
c->_def.actions[result->_action].vtw_list_head){
d_dplog("commit2::process_func(), calling process on : %s for action "
- "%d, type: %d, operation: %d, path: %s, disable state: %d",
+ "%d, type: %d, operation: %d, path: %s",
(d->_name ? d->_name : "[n/a]"), result->_action,
- (d->_name ? c->_def.def_type : -1), op, d->_path, d->_disable_op);
+ (d->_name ? c->_def.def_type : -1), op, d->_path);
- //FIRST LET'S COMPUTE THE DEACTIVATE->ACTIVATE OVERRIDE
- if (d->_disable_op != K_NO_DISABLE_OP) {
- if (IS_DELETE(op) && (d->_disable_op & K_ACTIVE_DISABLE_OP)) {
- //if this was actively disabled and is being deleted do nothing.
- return FALSE;
- } else if ((d->_disable_op & K_LOCAL_DISABLE_OP)
- && (d->_disable_op & K_ACTIVE_DISABLE_OP)) {
- //no state change: deactivated
- return FALSE; //skip operation on node
- } else if (!(d->_disable_op & K_LOCAL_DISABLE_OP)
- && (d->_disable_op & K_ACTIVE_DISABLE_OP)) {
- //node will be activated on commit
- //LET'S SPOOF the operation... convert it to CREATE
- op = K_CREATE_OP;
- } 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
- op = K_DEL_OP;
- }
- }
/* Needs to be cleaned up a bit such that this convoluted if clause
* is easier to read.
* (XXX original comment no longer correct and therefore is removed.)
@@ -578,9 +557,7 @@ process_func(GNode *node, gpointer data)
* delete--shouldn't be done, but needs to be include in the rule
* set above
*/
- if (IS_DELETE(op) && IS_ACTIVE(op) && result->_action == delete_act
- && d->_disable_op == K_NO_DISABLE_OP) {
- //only apply this when no disable operation is set
+ if (IS_DELETE(op) && IS_ACTIVE(op) && result->_action == delete_act) {
return FALSE;
}
@@ -857,22 +834,6 @@ sort_func(GNode *node, gpointer data, boolean priority_mode)
d_dplog("commit2::sort_func(): %s, node count: %d",
(d->_name ? d->_name : "[n/a]"), g_node_n_children(root_node));
- // FIRST LET'S COMPUTE THE DEACTIVATE->ACTIVATE OVERRIDE
- NODE_OPERATION op = d->_operation;
- if (d->_disable_op != K_NO_DISABLE_OP) {
- if (!(d->_disable_op & K_LOCAL_DISABLE_OP)
- && (d->_disable_op & K_ACTIVE_DISABLE_OP)) {
- //node will be activated on commit
- //LET'S SPOOF the operation... convert it to CREATE
- op = K_CREATE_OP;
- } 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
- op = K_DEL_OP;
- }
- }
-
//change action state of node according to enclosing behavior
/* XXX this is ugly. originally the condition for the if is the following:
* (c1 && c2 || (c3 || c4) && c5)
@@ -892,13 +853,24 @@ sort_func(GNode *node, gpointer data, boolean priority_mode)
* note that since the current goal is simply cleanup, no attempt is
* made to understand the logic here, and the change is purely based
* on operator precendence to maintain the original logic.
+ *
+ * XXX now removing deactivate-handling code, which involves c2.
+ *
+ * note that c2 is (d->_disable_op != K_NO_DISABLE_OP), which means
+ * the node is "deactivated" (in working or active config or both).
+ * this in turn means that the (c1 && c2) part of the logic can only
+ * be true if the node is deactivated.
+ *
+ * however, since activate/deactivate has not actually been exposed,
+ * this means that in actual usage the (c1 && c2) part is never true.
+ * therefore, we can simply remove the whole part, and the logic
+ * becomes:
+ * ((c3 || c4) && c5)
*/
- if (((/* c1 */ G_NODE_IS_ROOT(node) == FALSE)
- && (/* c2 */ d->_disable_op != K_NO_DISABLE_OP))
- //added to support enclosing behavior of activated/deactivated
- || (((/* c3 */ IS_SET_OR_CREATE(op)) || (/* c4 */ IS_DELETE(op)))
- && (/* c5 */ IS_NOOP(((struct VyattaNode*)
- (node->parent->data))->_data._operation)))) {
+ NODE_OPERATION op = d->_operation;
+ if (((/* c3 */ IS_SET_OR_CREATE(op)) || (/* c4 */ IS_DELETE(op)))
+ && (/* c5 */ IS_NOOP(((struct VyattaNode*)
+ (node->parent->data))->_data._operation))) {
//first check if there is enclosing behavior
boolean enclosing = FALSE;
GNode *n = node;
@@ -1101,30 +1073,17 @@ dump_func(GNode *node, gpointer data)
struct Config *gcfg = &(gp->_config);
if (gdata->_name != NULL) {
unsigned int i;
-
- char disable_op[2] = { 0, 0 };
- NODE_ACTIVATE dop = gdata->_disable_op;
- if (dop == (K_ACTIVE_DISABLE_OP | K_LOCAL_DISABLE_OP)) {
- disable_op[0] = '!';
- } else if (dop == K_ACTIVE_DISABLE_OP) {
- disable_op[0] = 'A';
- } else if (dop == K_LOCAL_DISABLE_OP) {
- disable_op[0] = 'D';
- } else {
- disable_op[0] = ' ';
- }
-
NODE_OPERATION op = gdata->_operation;
if (IS_ACTIVE(op)) {
- fprintf(out,"%s*",disable_op);
+ fprintf(out, "*");
} else if (IS_DELETE(op)) {
- fprintf(out,"%s-",disable_op);
+ fprintf(out, "-");
} else if (IS_CREATE(op)) {
- fprintf(out,"%s+",disable_op);
+ fprintf(out, "+");
} else if (IS_SET(op)) {
- fprintf(out,"%s>",disable_op);
+ fprintf(out, ">");
} else {
- fprintf(out,"%s ",disable_op);
+ fprintf(out, " ");
}
for (i = 0; i < depth; ++i) {
@@ -1440,15 +1399,6 @@ validate_func(GNode *node, gpointer data)
return FALSE;
}
- //don't perform validation checks on disabled nodes
- if (d->_disable_op == K_LOCAL_DISABLE_OP
- || d->_disable_op == (K_LOCAL_DISABLE_OP | K_ACTIVE_DISABLE_OP)) {
- /* SHOULD only hit the case where the node is locally disabled
- * or globally disabled and not in a transition to active state
- */
- return FALSE;
- }
-
if (IS_DELETE(d->_operation) && !IS_ACTIVE(d->_operation)) {
return FALSE; //will not perform validation checks on deleted nodes
}
diff --git a/src/common/defs.h b/src/common/defs.h
index 331fe2b..5ba98ce 100644
--- a/src/common/defs.h
+++ b/src/common/defs.h
@@ -40,12 +40,6 @@ typedef enum {
K_DEL_OP = 0x10
} NODE_OPERATION;
-typedef enum {
- K_NO_DISABLE_OP = 0X00,
- K_LOCAL_DISABLE_OP = 0x02, //MEANS DISABLE FLAG IS SET IN LOCAL CONFIGURATION
- K_ACTIVE_DISABLE_OP = 0x04 //MEANS DISABLE FLAG IS SET IN ACTIVE CONFIGURATION
-} NODE_ACTIVATE;
-
#define IS_SET(op) (op & K_SET_OP)
#define IS_ACTIVE(op) (op & K_ACTIVE_OP)
#define IS_CREATE(op) (op & K_CREATE_OP)
@@ -83,7 +77,6 @@ struct Data
boolean _value; //is this a value?
char* _path;
NODE_OPERATION _operation; //no-op, set, or delete
- NODE_ACTIVATE _disable_op; //is this node currently deactivated?
};
/*
diff --git a/src/common/unionfs.c b/src/common/unionfs.c
index e9266cc..2d8bddd 100644
--- a/src/common/unionfs.c
+++ b/src/common/unionfs.c
@@ -209,7 +209,6 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root,
vn->_data._name = cp;
vn->_data._value = FALSE;//TRUE; //data value
vn->_data._operation = op;
- vn->_data._disable_op = K_NO_DISABLE_OP;
vn->_config._priority = LOWEST_PRIORITY;
if (rel_data_path != NULL) {
vn->_data._path = (char*)malloc(strlen(rel_data_path)+1);
@@ -383,46 +382,10 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root,
strcmp(dirp->d_name, MOD_NAME) != 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, VAL_NAME) != 0) {
processed = TRUE;
- NODE_ACTIVATE deactivated = K_NO_DISABLE_OP;
- if (G_NODE_IS_ROOT(node) == FALSE
- && ((struct VyattaNode*)node->data)->_data._disable_op
- != K_NO_DISABLE_OP) {
- deactivated = ((struct VyattaNode*)node->data)->_data._disable_op;
- }
- else { //do a lstat check in the local dir
- struct stat s;
-
- char namebuf[MAX_LENGTH_HELP_STR];
- if (strncmp(dirp->d_name,DELETED_NODE,4) == 0) {
- strcpy(namebuf,dirp->d_name+4); //SKIP THE .WH.
- }
- else {
- strcpy(namebuf,dirp->d_name);
- }
-
-
- char buf[MAX_LENGTH_HELP_STR];
- sprintf(buf, "%s/%s/%s/%s", get_mdirp(), rel_data_path, namebuf,
- DISABLE_FILE);
- if (lstat(buf,&s) == 0) {
- /* need to check existence of file in active configuration here
- * as well!
- */
- deactivated |= K_LOCAL_DISABLE_OP;
- }
- sprintf(buf, "%s/%s/%s/%s", get_adirp(), rel_data_path, namebuf,
- DISABLE_FILE);
- if (lstat(buf,&s) == 0) {
- deactivated |= K_ACTIVE_DISABLE_OP;
- }
- }
-
char *data_buf = malloc(strlen(dirp->d_name)+5);
if (strncmp(dirp->d_name,DELETED_NODE,4) == 0) {
struct VyattaNode *vn = calloc(1,sizeof(struct VyattaNode));
@@ -439,7 +402,6 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root,
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);
@@ -451,45 +413,13 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root,
* 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);
- if (op == K_DEL_OP) {
- vn->_data._operation = K_DEL_OP;
- }
- else {
- 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 = 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(),
- vn->_data._operation);
- }
- else {
+ } else {
strcpy(data_buf,dirp->d_name);
//create new node and insert...
struct VyattaNode *vn = calloc(1,sizeof(struct VyattaNode));
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);
@@ -511,7 +441,7 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root,
}
GNode *new_node = g_node_new(vn);
new_node = insert_sibling_in_order(node,new_node);
- if (op == K_DEL_OP || vn->_data._disable_op != K_NO_DISABLE_OP) {
+ if (op == K_DEL_OP) {
retrieve_data(new_data_path, new_node, get_adirp(),
vn->_data._operation);
}
@@ -565,7 +495,6 @@ retrieve_data(char* rel_data_path, GNode *node, const char* root,
vn->_data._value = FALSE;
vn->_data._operation = K_DEL_OP;
vn->_config._priority = LOWEST_PRIORITY;
- vn->_data._disable_op = K_NO_DISABLE_OP;
GNode *new_node = g_node_new(vn);
new_node = insert_sibling_in_order(node,new_node);
@@ -594,7 +523,6 @@ common_get_local_session_data()
struct VyattaNode *vn = calloc(1,sizeof(struct VyattaNode));
vn->_data._name = NULL; //root node has null
vn->_data._operation = K_NO_OP;
- vn->_data._disable_op = K_NO_DISABLE_OP;
vn->_config._priority = LOWEST_PRIORITY;
//create first node
@@ -974,7 +902,6 @@ copy_vyatta_node(struct VyattaNode* vn)
strcpy(new_vn->_data._path,vn->_data._path);
}
new_vn->_data._operation = vn->_data._operation;
- new_vn->_data._disable_op = vn->_data._disable_op;
new_vn->_config._multi = vn->_config._multi;
new_vn->_config._priority = vn->_config._priority;
new_vn->_config._priority_extended = vn->_config._priority_extended;
@@ -1144,9 +1071,6 @@ dlist_test_func(GQuark key_id,gpointer data,gpointer user_data)
new_vn->_config._path = malloc(strlen(vn_parent->_config._path)+10);
sprintf(new_vn->_config._path,"%s/node.tag",vn_parent->_config._path);
- // let's set this nodes disable_op to its parent's value.
- new_vn->_data._disable_op = vn_parent->_data._disable_op;
-
new_vn->_data._operation = ((struct ValueData*)data)->_state;
new_vn->_config._def = vn_parent->_config._def;
}
diff --git a/src/common/unionfs.h b/src/common/unionfs.h
index 747262a..6437e2a 100644
--- a/src/common/unionfs.h
+++ b/src/common/unionfs.h
@@ -12,10 +12,8 @@ extern "C" {
#endif
#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 4096
diff --git a/src/cstore/ctemplate.hpp b/src/cstore/ctemplate.hpp
index b9d1d8c..1915273 100644
--- a/src/cstore/ctemplate.hpp
+++ b/src/cstore/ctemplate.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Vyatta, Inc.
+ * Copyright (C) 2011 Vyatta, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as