Richard W.M. Jones
2014-Dec-05 12:33 UTC
Re: [Libguestfs] [PATCH 4/8] New API: btrfs_quota_disable
On Tue, Dec 02, 2014 at 05:33:34PM +0800, Hu Tao wrote:> btrfs_quota_disable disables quota for subvolumes. > > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > --- > daemon/btrfs.c | 31 +++++++++++++++++++++++++++++++ > generator/actions.ml | 9 +++++++++ > src/MAX_PROC_NR | 2 +- > 3 files changed, 41 insertions(+), 1 deletion(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index 31dd806..5fcb85b 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -1026,3 +1026,34 @@ int do_btrfs_quota_enable (const char *path) > > return 0; > } > + > +int do_btrfs_quota_disable (const char *path) > +{ > + const size_t MAX_ARGS = 64; > + const char *argv[MAX_ARGS]; > + size_t i = 0; > + CLEANUP_FREE char *path_buf = NULL; > + CLEANUP_FREE char *err = NULL; > + CLEANUP_FREE char *out = NULL; > + int r; > + > + path_buf = sysroot_path (path); > + if (path_buf == NULL) { > + reply_with_perror ("malloc"); > + return -1; > + } > + > + ADD_ARG (argv, i, str_btrfs); > + ADD_ARG (argv, i, "quota"); > + ADD_ARG (argv, i, "disable"); > + ADD_ARG (argv, i, path_buf); > + ADD_ARG (argv, i, NULL); > + > + r = commandv (&out, &err, argv); > + if (r == -1) { > + reply_with_error ("%s: %s", path, err); > + return -1; > + } > + > + return 0; > +} > diff --git a/generator/actions.ml b/generator/actions.ml > index 3af8380..ab1a07a 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -12054,6 +12054,15 @@ Return detailed information of the subvolume." }; > longdesc = "\ > Enable subvolume quota support for filesystem which contains C<path>." }; > > + { defaults with > + name = "btrfs_quota_disable"; > + style = RErr, [Pathname "path"], []; > + proc_nr = Some 428; > + optional = Some "btrfs"; camel_name = "BTRFSQuotaDisable"; > + shortdesc = "disable subvolume quota support"; > + longdesc = "\ > +Disable subvolume quota support for filesystem which contains C<path>." }; > + > ] > > (* Non-API meta-commands available only in guestfish. > diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR > index d2a1e59..43d371a 100644 > --- a/src/MAX_PROC_NR > +++ b/src/MAX_PROC_NR > @@ -1 +1 @@ > -427 > +428ACK. Could do with a test. How about combining this with the previous API, so you'd have: guestfs_btrfs_quota (guestfs_h *g, int enable); ? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On Fri, Dec 05, 2014 at 12:33:08PM +0000, Richard W.M. Jones wrote:> On Tue, Dec 02, 2014 at 05:33:34PM +0800, Hu Tao wrote: > > btrfs_quota_disable disables quota for subvolumes. > > > > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > > --- > > daemon/btrfs.c | 31 +++++++++++++++++++++++++++++++ > > generator/actions.ml | 9 +++++++++ > > src/MAX_PROC_NR | 2 +- > > 3 files changed, 41 insertions(+), 1 deletion(-) > > > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > > index 31dd806..5fcb85b 100644 > > --- a/daemon/btrfs.c > > +++ b/daemon/btrfs.c > > @@ -1026,3 +1026,34 @@ int do_btrfs_quota_enable (const char *path) > > > > return 0; > > } > > + > > +int do_btrfs_quota_disable (const char *path) > > +{ > > + const size_t MAX_ARGS = 64; > > + const char *argv[MAX_ARGS]; > > + size_t i = 0; > > + CLEANUP_FREE char *path_buf = NULL; > > + CLEANUP_FREE char *err = NULL; > > + CLEANUP_FREE char *out = NULL; > > + int r; > > + > > + path_buf = sysroot_path (path); > > + if (path_buf == NULL) { > > + reply_with_perror ("malloc"); > > + return -1; > > + } > > + > > + ADD_ARG (argv, i, str_btrfs); > > + ADD_ARG (argv, i, "quota"); > > + ADD_ARG (argv, i, "disable"); > > + ADD_ARG (argv, i, path_buf); > > + ADD_ARG (argv, i, NULL); > > + > > + r = commandv (&out, &err, argv); > > + if (r == -1) { > > + reply_with_error ("%s: %s", path, err); > > + return -1; > > + } > > + > > + return 0; > > +} > > diff --git a/generator/actions.ml b/generator/actions.ml > > index 3af8380..ab1a07a 100644 > > --- a/generator/actions.ml > > +++ b/generator/actions.ml > > @@ -12054,6 +12054,15 @@ Return detailed information of the subvolume." }; > > longdesc = "\ > > Enable subvolume quota support for filesystem which contains C<path>." }; > > > > + { defaults with > > + name = "btrfs_quota_disable"; > > + style = RErr, [Pathname "path"], []; > > + proc_nr = Some 428; > > + optional = Some "btrfs"; camel_name = "BTRFSQuotaDisable"; > > + shortdesc = "disable subvolume quota support"; > > + longdesc = "\ > > +Disable subvolume quota support for filesystem which contains C<path>." }; > > + > > ] > > > > (* Non-API meta-commands available only in guestfish. > > diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR > > index d2a1e59..43d371a 100644 > > --- a/src/MAX_PROC_NR > > +++ b/src/MAX_PROC_NR > > @@ -1 +1 @@ > > -427 > > +428 > > ACK. > > Could do with a test. > > How about combining this with the previous API, so you'd have: > > guestfs_btrfs_quota (guestfs_h *g, int enable); > > ?Okay, it's more neat. But I changed it into guestfs_btrfs_quota_enable (guestfs_h *g, const char *path, int enable) BTW, why not generate bool for c from ocaml Bool? Regards, Hu> > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > libguestfs lets you edit virtual machines. Supports shell scripting, > bindings from many languages. http://libguestfs.org
Richard W.M. Jones
2014-Dec-09 09:05 UTC
Re: [Libguestfs] [PATCH 4/8] New API: btrfs_quota_disable
On Tue, Dec 09, 2014 at 02:54:28PM +0800, Hu Tao wrote:> Okay, it's more neat. But I changed it into > > guestfs_btrfs_quota_enable (guestfs_h *g, const char *path, int enable) > > BTW, why not generate bool for c from ocaml Bool?The reason is historical - when we started out we generated 'int', and C99 'bool' is not compatible with 'int' ('bool' is really a 'char') so we cannot change it. Also 'bool' is of dubious utility. See Linus's comments here: https://lkml.org/lkml/2013/8/31/138 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v