diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commit2.c | 25 | ||||
-rw-r--r-- | src/common/unionfs.c | 32 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/commit2.c b/src/commit2.c index 4b543a1..e692d1f 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -151,6 +151,7 @@ main(int argc, char** argv) init_paths(TRUE); if (g_debug) { printf("commit2: starting up\n"); + syslog(LOG_DEBUG,"commit2: starting up"); } //get local session data plus configuration data @@ -173,6 +174,7 @@ main(int argc, char** argv) if (g_debug == TRUE || g_dump_trans == TRUE) { if (g_dump_trans == TRUE) { fprintf(out_stream,"Dumping transactions\n"); + syslog(LOG_DEBUG,"Dumping transactions"); } //iterate over config_data and dump... g_node_traverse(trans_coll, @@ -200,9 +202,11 @@ main(int argc, char** argv) if (g_debug == TRUE) { if (trans_child_node != NULL && trans_child_node->data != NULL && ((struct VyattaNode*)(trans_child_node->data))->_data._name != NULL) { printf("commit2: Starting new transaction processing pass on root: %s\n", ((struct VyattaNode*)(trans_child_node->data))->_data._name); + syslog(LOG_DEBUG,"commit2: Starting new transaction processing pass on root: %s", ((struct VyattaNode*)(trans_child_node->data))->_data._name); } else { printf("commit2: Starting new transaction processing pass on root:\n"); + syslog(LOG_DEBUG,"commit2: Starting new transaction processing pass on root:"); } } @@ -235,6 +239,7 @@ main(int argc, char** argv) no_errors = FALSE; if (g_debug == TRUE) { printf("commit2: Failed in processing node\n"); + syslog(LOG_DEBUG,"commit2: Failed in processing node\n"); } } ++i; @@ -252,6 +257,7 @@ main(int argc, char** argv) } if (g_debug == TRUE) { printf("commit2: successful commit, now cleaning up temp directories\n"); + syslog(LOG_DEBUG,"commit2: successful commit, now cleaning up temp directories"); } } else { @@ -265,6 +271,7 @@ main(int argc, char** argv) if (g_debug) { printf("DONE\n"); + syslog(LOG_DEBUG,"DONE"); } exit (no_errors == FALSE); @@ -293,9 +300,11 @@ process_func(GNode *node, gpointer data) if (g_debug) { if (d->_name != NULL) { printf("commit2::process_func(), calling process on : %s for action %d, type: %d, operation: %d, path: %s\n",d->_name,result->_action,c->_def.def_type, d->_operation, d->_path); + syslog(LOG_DEBUG,"commit2::process_func(), calling process on : %s for action %d, type: %d, operation: %d, path: %s",d->_name,result->_action,c->_def.def_type, d->_operation, d->_path); } else { printf("commit2::process_func(), calling process on : [n/a] for action %d, operation: %d, path: %s\n",result->_action, d->_operation, d->_path); + syslog(LOG_DEBUG,"commit2::process_func(), calling process on : [n/a] for action %d, operation: %d, path: %s",result->_action, d->_operation, d->_path); } } @@ -334,22 +343,27 @@ process_func(GNode *node, gpointer data) } if (g_debug) { printf("commit2::process_func(): @ value: %s\n",(char*)val); + syslog(LOG_DEBUG,"commit2::process_func(): @ value: %s",(char*)val); } set_at_string(val); //embedded multinode value } else { if (g_debug) { printf("commit2::process_func(): boolean value is: %d\n",d->_value); + syslog(LOG_DEBUG,"commit2::process_func(): boolean value is: %d",d->_value); if (node->parent != NULL && ((struct VyattaNode*)(node->parent->data))->_data._name != NULL) { printf("commit2::process_func(): parent has a name and it is: %s\n",((struct VyattaNode*)(node->parent->data))->_data._name); + syslog(LOG_DEBUG,"commit2::process_func(): parent has a name and it is: %s\n",((struct VyattaNode*)(node->parent->data))->_data._name); } printf("commit2::process_func(): @ value: [NULL]\n"); + syslog(LOG_DEBUG,"commit2::process_func(): @ value: [NULL]\n"); } } common_set_context(c->_path,d->_path); if (g_debug) { printf("Executing %s on this node\n", ActionNames[result->_action]); + syslog(LOG_DEBUG,"Executing %s on this node\n", ActionNames[result->_action]); } if (g_coverage) { @@ -409,6 +423,7 @@ process_func(GNode *node, gpointer data) result->_err_code = 1; if (g_debug) { printf("commit2::process_func(): FAILURE: status: %d\n",status); + syslog(LOG_DEBUG,"commit2::process_func(): FAILURE: status: %d",status); } return TRUE; //WILL STOP AT THIS POINT } @@ -428,9 +443,11 @@ complete(GNode *node, boolean test_mode) if (g_debug) { if (((struct VyattaNode*)gp)->_data._name != NULL) { printf("commit2::complete():name: %s, path: %s\n",((struct VyattaNode*)gp)->_data._name,((struct VyattaNode*)gp)->_data._path); + syslog(LOG_DEBUG,"commit2::complete():name: %s, path: %s",((struct VyattaNode*)gp)->_data._name,((struct VyattaNode*)gp)->_data._path); } else { printf("commit2::complete()\n"); + syslog(LOG_DEBUG,"commit2::complete()"); } } //on transactional nodes only, note to avoid calling this if a headless root @@ -473,9 +490,11 @@ sort_func(GNode *node, gpointer data, boolean priority_mode) if (g_debug) { if (((struct VyattaNode*)gp)->_data._name != NULL) { printf("commit2::sort_func(): %s, node count: %d\n",((struct VyattaNode*)gp)->_data._name,g_node_n_children(root_node)); + syslog(LOG_DEBUG,"commit2::sort_func(): %s, node count: %d",((struct VyattaNode*)gp)->_data._name,g_node_n_children(root_node)); } else { printf("commit2::sort_func(): [n/a], node count: %d\n",g_node_n_children(root_node)); + syslog(LOG_DEBUG,"commit2::sort_func(): [n/a], node count: %d",g_node_n_children(root_node)); } } @@ -541,6 +560,7 @@ sort_func(GNode *node, gpointer data, boolean priority_mode) pri = ((struct VyattaNode*)(sibling->data))->_priority; } printf("commit2::sort_func(): inserting %s into transaction, priority: %d BEFORE %d\n", ((struct VyattaNode*)gp)->_data._name, ((struct VyattaNode*)gp)->_priority, pri); + syslog(LOG_DEBUG,"commit2::sort_func(): inserting %s into transaction, priority: %d BEFORE %d\n", ((struct VyattaNode*)gp)->_data._name, ((struct VyattaNode*)gp)->_priority, pri); } g_node_insert_before(root_node,sibling,new_node); } @@ -549,6 +569,7 @@ sort_func(GNode *node, gpointer data, boolean priority_mode) if (g_node_depth(node) == 2) { if (g_debug) { printf("commit2::sort_func(): inserting %s into transaction\n", ((struct VyattaNode*)gp)->_data._name); + syslog(LOG_DEBUG,"commit2::sort_func(): inserting %s into transaction\n", ((struct VyattaNode*)gp)->_data._name); } GNode *new_node = g_node_copy(node); g_node_insert(root_node,-1,new_node); //make a flat structure for now @@ -568,6 +589,7 @@ get_transactions(GNode *config, boolean priority_mode) { if (g_debug) { printf("commit2::get_transactions()\n"); + syslog(LOG_DEBUG,"commit2::get_transactions()\n"); } if (config == NULL) { @@ -795,6 +817,7 @@ process_priority_node(GNode *priority_node) if (result._err_code != 0) { if (g_debug) { printf("commit2::process_priority_node(): failure on processing pass: %d\n", i); + syslog(LOG_DEBUG,"commit2::process_priority_node(): failure on processing pass: %d\n", i); } return FALSE; } @@ -827,6 +850,7 @@ enclosing_process_func(GNode *node, gpointer data) if (g_debug) { printf("commit2::enclosing_process_func(): enclosing statement found on: %s\n",d->_path); + syslog(LOG_DEBUG,"commit2::enclosing_process_func(): enclosing statement found on: %s\n",d->_path); } //perform recursive calling on new process node... @@ -851,6 +875,7 @@ enclosing_process_func(GNode *node, gpointer data) if (result->_err_code != 0) { //EXECUTE_LIST RETURNS FALSE ON FAILURE.... if (g_debug) { printf("commit2::enclosing_process_func(): FAILURE: status: %d\n",result->_err_code); + syslog(LOG_DEBUG,"commit2::enclosing_process_func(): FAILURE: status: %d\n",result->_err_code); } return TRUE; //WILL STOP AT THIS POINT } diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 8d02bbe..8cd5213 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -3,6 +3,7 @@ #include <dirent.h> #include <sys/types.h> #include <sys/stat.h> +#include <syslog.h> #include <unistd.h> #include <glib-2.0/glib.h> #include "common/defs.h" @@ -90,6 +91,7 @@ get_config_path(GNode *node) if (d == NULL) { if (g_debug) { printf("unionfs::get_config_path(): data ptr is null\n"); + syslog(LOG_DEBUG,"unionfs::get_config_path(): data ptr is null"); } return NULL; } @@ -146,6 +148,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op) if (g_debug) { printf("unionfs::retrieve_data(): %s\n", full_data_path); + syslog(LOG_DEBUG,"unionfs::retrieve_data(): %s\n", full_data_path); } @@ -188,6 +191,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op) struct stat s; if (g_debug) { printf("unionfs::retrieve_data(): config path: %s\n",buf); + syslog(LOG_DEBUG,"unionfs::retrieve_data(): config path: %s\n",buf); } struct VyattaNode* vn = (struct VyattaNode*)node->data; @@ -197,6 +201,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op) if (parse_def(&def, buf, FALSE) == 0) { if (g_debug) { printf("[FOUND node.def]"); + syslog(LOG_DEBUG,"[FOUND node.def]"); } //either multi or tag--shouldn't have made a difference, but arkady was confused. vn->_config._multi = (def.tag | def.multi); @@ -261,6 +266,7 @@ retrieve_data(char* rel_data_path, GNode *node, char* root, NODE_OPERATION op) if (g_debug) { //could also be a terminating value now printf("unionfs::retrieve_data(), failed to open directory: %s\n", full_data_path); + syslog(LOG_DEBUG,"unionfs::retrieve_data(), failed to open directory: %s\n", full_data_path); } return; } @@ -393,6 +399,7 @@ common_set_parent_context(char *cpath, char *dpath) { if (g_debug) { printf("common_set_parent_context(incoming): %s, %s\n",cpath,dpath); + syslog(LOG_DEBUG,"common_set_parent_context(incoming): %s, %s\n",cpath,dpath); } //strip off last path and set int index = strlen(cpath)-1; @@ -426,6 +433,7 @@ common_set_parent_context(char *cpath, char *dpath) set_path(dpath,FALSE); if (g_debug) { printf("common_set_parent_context: %s, %s\n",cpath,dpath); + syslog(LOG_DEBUG,"common_set_parent_context: %s, %s\n",cpath,dpath); } } @@ -437,6 +445,7 @@ common_set_context(char *cpath, char *dpath) { if (g_debug) { printf("common_set_context: %s, %s\n",cpath,dpath); + syslog(LOG_DEBUG,"common_set_context: %s, %s\n",cpath,dpath); } set_path(cpath,TRUE); set_path(dpath,FALSE); @@ -463,6 +472,7 @@ set_path(char *path, boolean config) if (path == NULL) { if (g_debug) { printf("unionfs::set_path() null value on entry\n"); + syslog(LOG_DEBUG,"unionfs::set_path() null value on entry\n"); } return; } @@ -527,6 +537,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) if (g_debug) { printf("common_commit_copy_to_live_config(): %s\n",path); + syslog(LOG_DEBUG,"common_commit_copy_to_live_config(): %s\n",path); } char *command = malloc(MAX_LENGTH_DIR_PATH); static const char format0[]="mkdir -p %s ; /bin/true"; @@ -561,6 +572,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) sprintf(command, formatpoint5, tbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -571,6 +583,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) sprintf(command,format0,tbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -583,6 +596,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) sprintf(command, format1, mbuf, tbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -593,6 +607,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) sprintf(command, format2, mbuf_root); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -604,6 +619,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) sprintf(command, format8, cbuf_root,abuf_root,mbuf_root); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -632,6 +648,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) { if (g_debug) { printf("common_commit_clean_temp_config()\n"); + syslog(LOG_DEBUG,"common_commit_clean_temp_config()\n"); } //first clean up the root // common_commit_copy_to_live_config("/"); @@ -658,6 +675,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) sprintf(command, format2, mbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } @@ -689,6 +707,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) sprintf(command, format3, tbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -698,6 +717,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) sprintf(command, format3, cbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -707,6 +727,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) sprintf(command, format5, cbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -716,6 +737,7 @@ common_commit_clean_temp_config(GNode *root_node, boolean test_mode) sprintf(command, format7, cbuf,abuf,mbuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (test_mode == FALSE) { @@ -789,6 +811,7 @@ apply_priority(GNode *root_node) if (fp != NULL) { if (g_debug) { printf("unionfs::apply_priority(), found priority file\n"); + syslog(LOG_DEBUG,"unionfs::apply_priority(), found priority file\n"); } char str[1025]; @@ -800,6 +823,7 @@ apply_priority(GNode *root_node) char *path = tok_str[1]; if (g_debug) { printf("unionfs::apply_priority(), working on this %s\n",path); + syslog(LOG_DEBUG,"unionfs::apply_priority(), working on this %s\n",path); } //now apply to node @@ -1062,6 +1086,7 @@ copy_func(GNode *node, gpointer data) sprintf(command,clear_def,sd->_dst,parent_path); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1073,6 +1098,7 @@ copy_func(GNode *node, gpointer data) sprintf(command,format_value,sd->_src,parent_path,sd->_dst,parent_path); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1084,6 +1110,7 @@ copy_func(GNode *node, gpointer data) sprintf(command,format,sd->_dst,path); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1136,6 +1163,7 @@ delete_func(GNode *node, gpointer data) sprintf(command,format,sd->_src,path,sd->_src,path); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1153,6 +1181,7 @@ delete_func(GNode *node, gpointer data) sprintf(command,delete_format,sd->_src,path,((struct VyattaNode*)(node->data))->_data._name); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1162,6 +1191,7 @@ delete_func(GNode *node, gpointer data) sprintf(command,format_force_delete,sd->_dst,path,sd->_dst,path); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1205,6 +1235,7 @@ delete_wh_func(GNode *node, gpointer data) sprintf(command,format0,abuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { @@ -1223,6 +1254,7 @@ delete_wh_func(GNode *node, gpointer data) sprintf(command,format0,abuf); if (g_debug) { printf("%s\n",command); + syslog(LOG_DEBUG,"%s\n",command); fflush(NULL); } if (sd->_test_mode == FALSE) { |