summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-05-04 17:54:56 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-05-04 17:54:56 -0700
commit0ffdc5e6d89f9677694a8eef916b07c089264753 (patch)
tree08f9693bdad87301ebb1306de73d77888df84413 /src/common
parent576e0fed6b0e32bb92915a10f95677303eda478a (diff)
downloadvyatta-cfg-0ffdc5e6d89f9677694a8eef916b07c089264753.tar.gz
vyatta-cfg-0ffdc5e6d89f9677694a8eef916b07c089264753.zip
initial working version of activate and deactivate: load,save,show,commit supported.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/defs.h7
-rw-r--r--src/common/unionfs.c49
-rw-r--r--src/common/unionfs.h1
3 files changed, 51 insertions, 6 deletions
diff --git a/src/common/defs.h b/src/common/defs.h
index 6f97e9b..88b8441 100644
--- a/src/common/defs.h
+++ b/src/common/defs.h
@@ -35,6 +35,12 @@ 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)
@@ -72,6 +78,7 @@ 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?
};
struct VyattaNode
diff --git a/src/common/unionfs.c b/src/common/unionfs.c
index 2be210e..151c6ce 100644
--- a/src/common/unionfs.c
+++ b/src/common/unionfs.c
@@ -189,6 +189,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
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;
vn->_data._path = malloc(MAX_LENGTH_DIR_PATH*sizeof(char));
sprintf(vn->_data._path,"%s",rel_data_path);
@@ -280,9 +281,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
}
if (G_NODE_IS_ROOT(node) == FALSE) {
- struct VyattaNode* vn_parent = (struct VyattaNode*)node->parent->data;
struct VyattaNode* vn = (struct VyattaNode*)node->data;
- // vn->_config._priority = vn_parent->_config._def.def_priority;
if (vn->_config._def.tag && vn->_config._multi) {
vn->_config._priority = LOWEST_PRIORITY;
@@ -343,19 +342,49 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
strcmp(dirp->d_name, "..") != 0 &&
strcmp(dirp->d_name, MODIFIED_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, VALUE_FILE) != 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 buf[MAX_LENGTH_HELP_STR];
+ sprintf(buf,"%s/%s/%s/%s",get_mdirp(),rel_data_path,dirp->d_name,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,dirp->d_name,DISABLE_FILE);
+ if (lstat(buf,&s) == 0) {
+ deactivated |= K_ACTIVE_DISABLE_OP;
+ }
+ }
+
char *data_buf = malloc(MAX_LENGTH_DIR_PATH*sizeof(char));
- if (strncmp(dirp->d_name,DELETED_NODE,4) == 0) {
- strcpy(data_buf,dirp->d_name+4); //SKIP THE .WH.
+ if (strncmp(dirp->d_name,DELETED_NODE,4) == 0 ||
+ deactivated != K_NO_DISABLE_OP) {
+
+ 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.
+ vn->_data._operation = K_DEL_OP;
+ }
+ else {
+ strcpy(data_buf,dirp->d_name);
+ vn->_data._operation = K_NO_OP;
+ }
//create new node and insert...
- struct VyattaNode *vn = calloc(1,sizeof(struct VyattaNode));
vn->_data._name = data_buf;
vn->_data._value = FALSE;
- vn->_data._operation = K_DEL_OP;
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);
@@ -374,6 +403,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
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);
@@ -444,6 +474,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op)
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);
@@ -473,6 +504,7 @@ 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
@@ -902,6 +934,7 @@ 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;
@@ -1070,6 +1103,10 @@ dlist_test_func(GQuark key_id,gpointer data,gpointer user_data)
strcpy(new_vn->_data._name,(char*)g_quark_to_string(key_id));
new_vn->_config._path = malloc(MAX_LENGTH_DIR_PATH*sizeof(char));
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 098ac41..2933deb 100644
--- a/src/common/unionfs.h
+++ b/src/common/unionfs.h
@@ -23,6 +23,7 @@
#define NODE_TAG_FILE "node.tag"
#define VALUE_FILE "node.val"
#define MODIFIED_FILE ".modified"
+#define DISABLE_FILE ".disable"
#define DEF_FILE "def"
#define WHITEOUT_FILE ".wh.__dir_opaque"
#define DELETED_NODE ".wh."