[Libguestfs] [PATCH libguestfs 16/23] generator.ml: use new "Pathname" designation

Richard W.M. Jones rjones at redhat.com
Wed Aug 12 17:55:13 UTC 2009


On Wed, Aug 12, 2009 at 06:52:52PM +0200, Jim Meyering wrote:
>  /* We need to rewrite the root path so it is based at /sysroot. */
>  int
> -do_aug_init (char *root, int flags)
> +do_aug_init (const char *root, int flags)
[etc.]

As discussed in the previous patch, the augeas change to path is
dubious.  However hopefully this will become a const char * in the end.

> diff --git a/src/generator.ml b/src/generator.ml
> index 325d3cb..f9032fb 100755
> --- a/src/generator.ml
> +++ b/src/generator.ml
> @@ -981,7 +981,7 @@ Note that this function cannot correctly handle binary files
>  as end of line).  For those you need to use the C<guestfs_read_file>
>  function which has a more complex interface.");
> 
> -  ("aug_init", (RErr, [String "root"; Int "flags"]), 16, [],
> +  ("aug_init", (RErr, [Pathname "root"; Int "flags"]), 16, [],
>     [], (* XXX Augeas code needs tests. *)
>     "create a new Augeas handle",
>     "\

This change is actually OK however.  Here the "root" really is a path.

> @@ -2523,7 +2523,11 @@ into a list of lines.
> 
>  See also: C<guestfs_command_lines>");
> 
> -  ("glob_expand", (RStringList "paths", [String "pattern"]), 113, [],
> +  ("glob_expand", (RStringList "paths", [Pathname "pattern"]), 113, [],
> +   (* Use Pathname here, and hence ABS_PATH (pattern,... in generated
> +    * code in stubs.c, since all valid glob patterns must start with "/".
> +    * There is no concept of "cwd" in libguestfs, hence no "."-relative names.
> +    *)
>     [InitBasicFS, Always, TestOutputList (
>        [["mkdir_p"; "/a/b/c"];
>         ["touch"; "/a/b/c/d"];

Agreed.

> @@ -2590,7 +2594,8 @@ containing C<dir>.
>  It is an interface to the L<scrub(1)> program.  See that
>  manual page for more details.");
> 
> -  ("mkdtemp", (RString "dir", [Pathname "template"]), 117, [],
> +(* FIXME: make this a WritableString? *)
> +  ("mkdtemp", (RString "dir", [String "template"]), 117, [],
>     [InitBasicFS, Always, TestRun (
>        [["mkdir"; "/tmp"];
>         ["mkdtemp"; "/tmp/tmpXXXXXX"]])],

Hope this is fixed in a future patch.

> @@ -2999,7 +3004,12 @@ This call is similar to C<guestfs_mounts>.  That call returns
>  a list of devices.  This one returns a hash table (map) of
>  device name to directory where the device is mounted.");
> 
> -  ("mkmountpoint", (RErr, [Pathname "path"]), 148, [],
> +  ("mkmountpoint", (RErr, [String "exemptpath"]), 148, [],
> +  (* This is a special case: while you would expect a parameter
> +   * of type "Pathname", that doesn't work, because it implies
> +   * NEED_ROOT in the generated calling code in stubs.c, and
> +   * this function cannot use NEED_ROOT.
> +   *)
>     [],
>     "create a mountpoint",
>     "\

Agreed.

ACK.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list