[Libguestfs] [PATCH 2/5] New API: btrfs_check
Hu Tao
hutao at cn.fujitsu.com
Mon Jan 12 01:37:36 UTC 2015
On Wed, Jan 07, 2015 at 01:25:50PM +0100, Pino Toscano wrote:
> In data venerdì 26 dicembre 2014 16:17:46, Hu Tao ha scritto:
> > Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
> > ---
> > daemon/btrfs.c | 24 ++++++++++++++++++++++++
> > generator/actions.ml | 14 ++++++++++++++
> > src/MAX_PROC_NR | 2 +-
> > 3 files changed, 39 insertions(+), 1 deletion(-)
> >
> > diff --git a/daemon/btrfs.c b/daemon/btrfs.c
> > index 79de539..de20bc3 100644
> > --- a/daemon/btrfs.c
> > +++ b/daemon/btrfs.c
> > @@ -1375,3 +1375,27 @@ do_btrfs_scrub (const char *path)
> >
> > return 0;
> > }
> > +
> > +int
> > +do_btrfs_check (const char *device)
> > +{
> > + const size_t MAX_ARGS = 64;
> > + const char *argv[MAX_ARGS];
> > + size_t i = 0;
> > + CLEANUP_FREE char *err = NULL;
> > + CLEANUP_FREE char *out = NULL;
> > + int r;
> > +
> > + ADD_ARG (argv, i, str_btrfs);
> > + ADD_ARG (argv, i, "check");
> > + ADD_ARG (argv, i, device);
> > + ADD_ARG (argv, i, NULL);
> > +
> > + r = commandv (&out, &err, argv);
> > + if (r == -1) {
> > + reply_with_error ("%s: %s", device, err);
> > + return -1;
> > + }
> > +
> > + return 0;
> > +}
>
> We do have already a "fsck" action; OTOH fsck.btrfs does nothing, so
> I would rather call `btrfs check` there, instead of adding a new
> btrfs-specific API.
> Let's make our fsck useful on btrfs :)
I found btrfs_fsck has been already implemented. Do you mean we should
extend btrfs to support btrfs?
Regards,
Hu
>
> > diff --git a/generator/actions.ml b/generator/actions.ml
> > index b44ce1c..c328319 100644
> > --- a/generator/actions.ml
> > +++ b/generator/actions.ml
> > @@ -12267,6 +12267,20 @@ Reads all the data and metadata on the filesystem, and uses checksums
> > and the duplicate copies from RAID storage to identify and repair any
> > corrupt data." };
> >
> > + { defaults with
> > + name = "btrfs_check";
> > + style = RErr, [Device "device"], [];
> > + proc_nr = Some 436;
> > + optional = Some "btrfs"; camel_name = "BTRFSCheck";
> > + tests = [
> > + InitPartition, Always, TestRun (
> > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
> > + ["btrfs_check"; "/dev/sda1"]]), [];
> > + ];
>
> This test bit would be good to be added to the tests of fsck,
> just with s/Always/IfAvailable "btrfs"/ so it is run only when btrfs
> is available.
>
> Thanks,
> --
> Pino Toscano
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
More information about the Libguestfs
mailing list