[augeas-devel] [PATCH] Write last created node in /augeas/tree/last_created for tree_create and tree_insert

Raphaël Pinson raphink at gmail.com
Fri Aug 8 18:25:23 UTC 2008


Hmmm now I realize why doing this in the tree_* functions could be nasty,
since /augeas/tree/last_created will be set when nodes in /augeas are set...

I dont' really know how to do it though... I see two options:
* Checking if the first segment of the path is /augeas and not setting
/augeas/tree/last_created in this case
* Modifying the internal API so the tree_create and tree_insert functions
can return the created path and the aug_* functions can set
/augeas/tree/last_created.


Raphael


On Fri, Aug 8, 2008 at 7:38 PM, Raphael Pinson <raphink at gmail.com> wrote:

> # HG changeset patch
> # User Raphael Pinson <raphink at gmail.com>
> # Date 1218215555 -7200
> # Node ID 5697b74b2d7341f923ee889187a9d8d6276744ae
> # Parent  10f6354c863e1feba41daa86e9d475c25007c0c2
> Write last created node in /augeas/tree/last_created for tree_create and
> tree_insert
>
> diff -r 10f6354c863e -r 5697b74b2d73 src/augeas.c
> --- a/src/augeas.c      Thu Aug 07 18:06:22 2008 -0700
> +++ b/src/augeas.c      Fri Aug 08 19:12:35 2008 +0200
> @@ -432,6 +432,11 @@ static struct segment *tree_create(struc
>     else
>         list_append(tree->children, seg->tree);
>
> +    for (s = seg ; s <= last_segment(path); s++) {
> +       s->index = sibling_index(seg_siblings(path, s), s->tree);
> +    }
> +
> +    tree_set(root, AUGEAS_META_LAST_CREATED, format_path(path));
>     return seg;
>  error:
>     for (s = seg; s->tree != NULL && s <= last_segment(path); s++) {
> @@ -642,6 +647,13 @@ int tree_insert(struct tree **tree, cons
>         new->next = seg->tree->next;
>         seg->tree->next = new;
>     }
> +
> +    free(seg->label);
> +    seg->label = strdup(label);
> +    seg->tree  = new;
> +    seg->index = sibling_index(seg_siblings(p, seg), new);
> +    tree_set(*tree, AUGEAS_META_LAST_CREATED, format_path(p));
> +
>     free_path(p);
>     return 0;
>  error:
> diff -r 10f6354c863e -r 5697b74b2d73 src/internal.h
> --- a/src/internal.h    Thu Aug 07 18:06:22 2008 -0700
> +++ b/src/internal.h    Fri Aug 08 19:12:35 2008 +0200
> @@ -61,6 +61,9 @@
>
>  /* How we save files. One of 'backup', 'overwrite' or 'newfile' */
>  #define AUGEAS_META_SAVE_MODE AUGEAS_META_TREE "/save"
> +
> +/* Last created node */
> +#define AUGEAS_META_LAST_CREATED AUGEAS_META_TREE "/tree/last_created"
>
>  /* Name of env var that contains list of paths to search for additional
>    spec files */
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080808/e512e260/attachment.htm>


More information about the augeas-devel mailing list