<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Aug 8, 2008 at 10:12 PM, David Lutterkort <span dir="ltr"><<a href="mailto:dlutter@redhat.com">dlutter@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Fri, 2008-08-08 at 20:25 +0200, Raphaël Pinson wrote:<br>
> Hmmm now I realize why doing this in the tree_* functions could be<br>
> nasty, since /augeas/tree/last_created will be set when nodes<br>
> in /augeas are set...<br>
><br>
> I dont' really know how to do it though... I see two options:<br>
> * Checking if the first segment of the path is /augeas and not<br>
> setting /augeas/tree/last_created in this case<br>
> * Modifying the internal API so the tree_create and tree_insert<br>
> functions can return the created path and the aug_* functions can<br>
> set /augeas/tree/last_created.<br>
<br>
</div>Yes, I think that would be the cleanest solution: tree_insert should<br>
become<br>
<br>
int tree_insert(struct tree **tree, const char *path, const char *label,<br>
int before, struct path **node)<br>
<br>
and the line 'free_path(p)' should become<br>
<br>
if (node != NULL) {<br>
*node = p;<br>
} else {<br>
free_path(p);<br>
}<br>
<br>
and aug_insert would turn into<br>
<br>
int aug_insert(struct augeas *aug, const char *path, const char *label,<br>
int before) {<br>
struct path *node = NULL;<br>
char *s = NULL;<br>
int ret = -1, r;<br>
<br>
r = tree_insert(&(aug->tree), path, label, before, &node);<br>
if (r < 0)<br>
goto done;<br>
<br>
char *s = format_path(node);<br>
if (s == NULL)<br>
goto done;<br>
<br>
if (tree_set(root, AUGEAS_META_LAST_CREATED, s) == NULL)<br>
goto done;<br>
<br>
ret = 0;<br>
done:<br>
FREE(s);<br>
free_path(node);<br>
return ret;<br>
}<br>
<br>
(Isn't error checking fun ?)<br>
<br>
</blockquote><div><br>Yes, that would work here. But how about the tree_create function? tree_create is called from tree_set and aug_mv (and will be called from aug_cp and it's done). Should each of aug_set, aug_mv and aug_cp deal with the node and both tree_create and tree_set calls be changed?<br>
<br><br> </div></div><br></div>