diff options
-rwxr-xr-x | lib/Vyatta/Config.pm | 77 | ||||
-rw-r--r-- | src/commit2.c | 24 | ||||
-rw-r--r-- | src/common/unionfs.c | 3 |
3 files changed, 101 insertions, 3 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index f80ff86..fd0222f 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -98,6 +98,83 @@ sub listNodes { return @nodes_modified; } +## listNodes("level") +# return array of all nodes (active plus currently committed) at "level" +# level is relative +sub listOrigPlusComNodes { + my ($self, $path) = @_; + my @nodes = (); + + my @nodes_modified = $self->listNodes(); + + #convert array to hash + my %coll; + my $coll; + @coll{@nodes_modified} = @nodes_modified; + + my $level = $self->{_level}; + + #now test against the inprocess file in the system +# my $com_file = "/tmp/.changes_$$"; + my $com_file = "/tmp/.changes"; + open FILE, "<", $com_file; + if (-e $com_file) { + foreach my $line (<FILE>) { + my @node = split " ", $line; #split on space + #$node[1] is of the form: system/login/blah + #$coll is of the form: blah + + my $dir_path = $level; + $dir_path =~ s/ /\//g; + $dir_path = "/".$dir_path; + +# print("comparing: $dir_path and $level to $node[1]\n"); + + #first only consider $path matches against $node[1] + if (!defined $dir_path || $node[1] =~ m/^$dir_path/) { + #or does $node[1] match the beginning of the line for $path + + #if yes, then split the right side and find against the hash for the value... + my $tmp; + if (defined $dir_path) { + $tmp = substr($node[1],length($dir_path)); + } + else { + $tmp = $node[1]; + } + + my @child = split "/",$tmp; + my $child; +# print("tmp: $tmp, $child[0], $child[1]\n"); + if ($child[0] =~ /^\s*$/ || !defined $child[0] || $child[0] eq '') { + shift(@child); + } + +# print("child value is: >$child[0]<\n"); + + #now can we find this entry in the hash? + #if '-' this is a delete and need to remove from hash + if ($node[0] eq "-") { + if (!defined $child[1]) { + delete($coll{$child[0]}); + } + } + #if '+' this is a set and need to add to hash + elsif ($node[0] eq "+" && $child[0] ne '') { + $coll{$child[0]} = '1'; + } + } + } + } + +#print "coll count: ".keys(%coll); + + #now convert hash to array and return + @nodes_modified = (); + @nodes_modified = keys(%coll); + return @nodes_modified; +} + ## listOrigNodes("level") # return array of all original nodes (i.e., before any current change; i.e., # in "working") at "level" diff --git a/src/commit2.c b/src/commit2.c index daea436..5f70aa4 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -436,7 +436,13 @@ process_func(GNode *node, gpointer data) status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def); } else { - fprintf(out_stream,"%s\t:\t%s\n",ActionNames[result->_action],d->_path); + char buf[MAX_LENGTH_DIR_PATH*sizeof(char)]; + sprintf(buf,"%s\t:\t%s",ActionNames[result->_action],d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } + fprintf(out_stream,"%s\n",buf); status = 1; } if (result->_action == delete_act) { @@ -985,11 +991,19 @@ validate_func(GNode *node, gpointer data) char *buf = malloc(MAX_LENGTH_DIR_PATH*sizeof(char)); if (IS_DELETE(d->_operation)) { sprintf(buf,"- %s",d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } coll = g_slist_append(coll,buf); result->_data = (void*)&coll; } else if (IS_SET_OR_CREATE(d->_operation)) { sprintf(buf,"+ %s",d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } coll = g_slist_append(coll,buf); result->_data = (void*)&coll; } @@ -1052,7 +1066,13 @@ validate_func(GNode *node, gpointer data) status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def); } else { - fprintf(out_stream,"%s\t:\t%s\n",ActionNames[result->_action],d->_path); + char buf[MAX_LENGTH_DIR_PATH*sizeof(char)]; + sprintf(buf,"%s\t:\t%s",ActionNames[result->_action],d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } + fprintf(out_stream,"%s\n",buf); status = 1; } diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 80a9ba7..5ef6618 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -580,7 +580,7 @@ common_commit_copy_to_live_config(GNode *node, boolean test_mode) 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 static const char format8[]="sudo mount -t unionfs -o dirs=%s=rw:%s=ro unionfs %s"; //cdirp, adirp, mdirp @@ -1038,6 +1038,7 @@ dlist_test_func(GQuark key_id,gpointer data,gpointer user_data) } else { new_vn = vn; + // strcat(new_vn->_data._path,"/"); strcat(new_vn->_data._path,"/value"); } new_vn->_data._value = TRUE; |