[augeas-devel] [PATCH] Add aug_rename to rename node labels without moving them in the tree.

David Lutterkort lutter at redhat.com
Wed Aug 1 17:57:02 UTC 2012


On Wed, 2012-08-01 at 10:54 +0200, Raphaël Pinson wrote:
> ---
>  src/augeas.c           |   26 ++++++++++++++++++++++++++
>  src/augeas.h           |   10 ++++++++++
>  src/augeas_sym.version |    1 +
>  src/augrun.c           |   34 +++++++++++++++++++++++++++++++++-
>  src/augtool.c          |    2 +-
>  tests/run.tests        |   35 +++++++++++++++++++++++++++++++++++
>  tests/test-api.c       |   17 +++++++++++++++++
>  7 files changed, 123 insertions(+), 2 deletions(-)

ACK, with one minor nit: there's no semicolons after functions in C (see
below)

I also wonder if requiring that SRC matches exactly one node is too
strict - if somebody wants to 'rename /files/etc/hosts//ipaddr address'
we should let them, I think.

David

> diff --git a/src/augrun.c b/src/augrun.c
> index 7895252..22627ef 100644
> --- a/src/augrun.c
> +++ b/src/augrun.c
> @@ -547,7 +547,7 @@ static void cmd_mv(struct command *cmd) {
>      if (r < 0)
>          ERR_REPORT(cmd, AUG_ECMDRUN,
>                     "Moving %s to %s failed", src, dst);
> -}
> +};

No semicolon here
 
> +static void cmd_rename(struct command *cmd) {
> +    const char *src = arg_value(cmd, "src");
> +    const char *lbl = arg_value(cmd, "lbl");
> +    int r;
> +
> +    r = aug_rename(cmd->aug, src, lbl);
> +    if (r < 0)
> +        ERR_REPORT(cmd, AUG_ECMDRUN,
> +                   "Renaming %s to %s failed", src, lbl);
> +};

or here

David





More information about the augeas-devel mailing list