<div dir="ltr">Hey Serge,<div><br></div><div>To be honest I wasn't thinking about parse errors while sending the patch. Maybe we can handle the non-existent file issue with something like that</div><div><br></div><div>

diff --git a/src/lxc/confile.c b/src/lxc/confile.c</div><div>index 8fe1541..96f9122 100644</div><div>--- a/src/lxc/confile.c</div><div>+++ b/src/lxc/confile.c</div><div>@@ -1422,6 +1422,11 @@ int lxc_config_readline(char *buffer, struct lxc_conf *conf)</div>

<div><br></div><div> int lxc_config_read(const char *file, struct lxc_conf *conf)</div><div> {</div><div>+       /* make sure file exists and reabable by us */</div><div>+       if( access(file, R_OK) == -1 ) {</div><div>

+               return -1;</div><div>+       }</div><div>+</div><div>        /* Catch only the top level config file name in the structure */</div><div>        if( ! conf->rcfile ) {</div><div>                conf->rcfile = strdup( file ); </div>

<div><br></div><div style>and address parse errors differently?</div><div style><br></div><div style>Cheers,</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 27, 2013 at 4:09 PM, Serge Hallyn <span dir="ltr"><<a href="mailto:serge.hallyn@ubuntu.com" target="_blank">serge.hallyn@ubuntu.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Quoting S.Çağlar Onur (<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>):<br>
> From: "S.Çağlar Onur" <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>><br>
><br>
> Signed-off-by: S.Çağlar Onur <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>><br>
<br>
</div>The only downside I see is that now the callbacks can be called<br>
with conf->rcfile NULL when it otherwise might be set to strdup(file).<br>
<br>
This gets tricky because the file being read could have a #include<br>
which will trigger lxc_config_read() again.  So now the recursive call<br>
will end up setting rcfile.<br>
<br>
This gets tricky but I think the best thing to do is<br>
<br>
if (!conf->rcfile) {<br>
        was_unset = true;<br>
        conf->rcfile = strdup(file);<br>
<div class="im">}<br>
ret = lxc_file_for_each_line(file, parse_line, conf);<br>
</div>if (ret != 0 && was_unset) {<br>
        free(conf->rcfile;<br>
        conf->rcfile = NULL;<br>
}<br>
<br>
Maybe you have a better idea though.<br>
<div class="im"><br>
> ---<br>
>  src/lxc/confile.c |    6 ++++--<br>
>  1 file changed, 4 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/lxc/confile.c b/src/lxc/confile.c<br>
> index 8fe1541..16b8594 100644<br>
> --- a/src/lxc/confile.c<br>
> +++ b/src/lxc/confile.c<br>
> @@ -1422,11 +1422,13 @@ int lxc_config_readline(char *buffer, struct lxc_conf *conf)<br>
><br>
>  int lxc_config_read(const char *file, struct lxc_conf *conf)<br>
>  {<br>
> +     int ret = lxc_file_for_each_line(file, parse_line, conf);<br>
> +<br>
>       /* Catch only the top level config file name in the structure */<br>
> -     if( ! conf->rcfile ) {<br>
> +     if( ret == 0 && ! conf->rcfile ) {<br>
>               conf->rcfile = strdup( file );<br>
>       }<br>
> -     return lxc_file_for_each_line(file, parse_line, conf);<br>
> +     return ret;<br>
>  }<br>
><br>
>  int lxc_config_define_add(struct lxc_list *defines, char* arg)<br>
> --<br>
> 1.7.10.4<br>
><br>
><br>
</div>> ------------------------------------------------------------------------------<br>
> Own the Future-Intel&reg; Level Up Game Demo Contest 2013<br>
> Rise to greatness in Intel's independent game demo contest.<br>
> Compete for recognition, cash, and the chance to get your game<br>
> on Steam. $5K grand prize plus 10 genre and skill prizes.<br>
> Submit your demo by 6/6/13. <a href="http://p.sf.net/sfu/intel_levelupd2d" target="_blank">http://p.sf.net/sfu/intel_levelupd2d</a><br>
> _______________________________________________<br>
> Lxc-devel mailing list<br>
> <a href="mailto:Lxc-devel@lists.sourceforge.net">Lxc-devel@lists.sourceforge.net</a><br>
> <a href="https://lists.sourceforge.net/lists/listinfo/lxc-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/lxc-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>S.Çağlar Onur <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>>
</div>