Pino Toscano
2015-Jan-05 12:26 UTC
Re: [Libguestfs] [PATCH 3/5] New API: btrfs_filesystem_get_label
In data venerdì 26 dicembre 2014 16:17:47, Hu Tao ha scritto:> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > --- > daemon/btrfs.c | 32 ++++++++++++++++++++++++++++++++ > generator/actions.ml | 15 +++++++++++++++ > src/MAX_PROC_NR | 2 +- > 3 files changed, 48 insertions(+), 1 deletion(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index de20bc3..6c74892 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -1399,3 +1399,35 @@ do_btrfs_check (const char *device) > > return 0; > } > + > +char * > +do_btrfs_filesystem_get_label (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; > + char *out; > + int r; > + > + path_buf = sysroot_path (path); > + if (path_buf == NULL) { > + reply_with_perror ("malloc"); > + return NULL; > + } > + > + ADD_ARG (argv, i, str_btrfs); > + ADD_ARG (argv, i, "filesystem"); > + ADD_ARG (argv, i, "label"); > + 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 NULL; > + } > + > + return out; > +}There's vfs_label already as command to get the label of a filesystem, so this special case for btrfs should be added there (just like the ones done in set_label). Isn't blkid working on btrfs filesystems? From what I see, there is support for it already.> diff --git a/generator/actions.ml b/generator/actions.ml > index c328319..5223eb8 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -12281,6 +12281,21 @@ corrupt data." }; > longdesc = "\ > Check or repair a btrfs filesystem offline." }; > > + { defaults with > + name = "btrfs_filesystem_get_label"; > + style = RString "label", [Pathname "path"], []; > + proc_nr = Some 437; > + optional = Some "btrfs"; camel_name = "BTRFSFilesystemGetLabel"; > + tests = [ > + InitPartition, Always, TestResultString ( > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "label"; "NOARG"; ""; ""]; > + ["mount"; "/dev/sda1"; "/"]; > + ["btrfs_filesystem_get_label"; "/";]], "label\n"), []; > + ];This test bit would be good to be added to the tests of vfs_label, just with s/Always/IfAvailable "btrfs"/ so it is run only when btrfs is available. Thanks, -- Pino Toscano
Hu Tao
2015-Jan-06 01:30 UTC
Re: [Libguestfs] [PATCH 3/5] New API: btrfs_filesystem_get_label
On Mon, Jan 05, 2015 at 01:26:08PM +0100, Pino Toscano wrote:> In data venerdì 26 dicembre 2014 16:17:47, Hu Tao ha scritto: > > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > > --- > > daemon/btrfs.c | 32 ++++++++++++++++++++++++++++++++ > > generator/actions.ml | 15 +++++++++++++++ > > src/MAX_PROC_NR | 2 +- > > 3 files changed, 48 insertions(+), 1 deletion(-) > > > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > > index de20bc3..6c74892 100644 > > --- a/daemon/btrfs.c > > +++ b/daemon/btrfs.c > > @@ -1399,3 +1399,35 @@ do_btrfs_check (const char *device) > > > > return 0; > > } > > + > > +char * > > +do_btrfs_filesystem_get_label (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; > > + char *out; > > + int r; > > + > > + path_buf = sysroot_path (path); > > + if (path_buf == NULL) { > > + reply_with_perror ("malloc"); > > + return NULL; > > + } > > + > > + ADD_ARG (argv, i, str_btrfs); > > + ADD_ARG (argv, i, "filesystem"); > > + ADD_ARG (argv, i, "label"); > > + 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 NULL; > > + } > > + > > + return out; > > +} > > There's vfs_label already as command to get the label of a filesystem, > so this special case for btrfs should be added there (just like the > ones done in set_label). > > Isn't blkid working on btrfs filesystems? From what I see, there is > support for it already.Yes, blkid just works. I think this patch can be dropped. Thanks for reminding! Regards, Hu> > > diff --git a/generator/actions.ml b/generator/actions.ml > > index c328319..5223eb8 100644 > > --- a/generator/actions.ml > > +++ b/generator/actions.ml > > @@ -12281,6 +12281,21 @@ corrupt data." }; > > longdesc = "\ > > Check or repair a btrfs filesystem offline." }; > > > > + { defaults with > > + name = "btrfs_filesystem_get_label"; > > + style = RString "label", [Pathname "path"], []; > > + proc_nr = Some 437; > > + optional = Some "btrfs"; camel_name = "BTRFSFilesystemGetLabel"; > > + tests = [ > > + InitPartition, Always, TestResultString ( > > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "label"; "NOARG"; ""; ""]; > > + ["mount"; "/dev/sda1"; "/"]; > > + ["btrfs_filesystem_get_label"; "/";]], "label\n"), []; > > + ]; > > This test bit would be good to be added to the tests of vfs_label, > just with s/Always/IfAvailable "btrfs"/ so it is run only when btrfs > is available. > > Thanks, > -- > Pino Toscano > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs
Pino Toscano
2015-Jan-07 10:23 UTC
Re: [Libguestfs] [PATCH 3/5] New API: btrfs_filesystem_get_label
In data martedì 6 gennaio 2015 09:30:19, Hu Tao ha scritto:> > > diff --git a/generator/actions.ml b/generator/actions.ml > > > index c328319..5223eb8 100644 > > > --- a/generator/actions.ml > > > +++ b/generator/actions.ml > > > @@ -12281,6 +12281,21 @@ corrupt data." }; > > > longdesc = "\ > > > Check or repair a btrfs filesystem offline." }; > > > > > > + { defaults with > > > + name = "btrfs_filesystem_get_label"; > > > + style = RString "label", [Pathname "path"], []; > > > + proc_nr = Some 437; > > > + optional = Some "btrfs"; camel_name = "BTRFSFilesystemGetLabel"; > > > + tests = [ > > > + InitPartition, Always, TestResultString ( > > > + [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "label"; "NOARG"; ""; ""]; > > > + ["mount"; "/dev/sda1"; "/"]; > > > + ["btrfs_filesystem_get_label"; "/";]], "label\n"), []; > > > + ]; > > > > This test bit would be good to be added to the tests of vfs_label, > > just with s/Always/IfAvailable "btrfs"/ so it is run only when btrfs > > is available.Feel free to send this bit (updated) anyway, also for patch 5. Thanks, -- Pino Toscano
Apparently Analagous Threads
- Re: [PATCH 3/5] New API: btrfs_filesystem_get_label
- [PATCH 3/5] New API: btrfs_filesystem_get_label
- Re: [PATCH 3/5] New API: btrfs_filesystem_get_label
- [PATCH 0/5] btrfs: add API for btrfs filesystem, check and scrub
- Re: [PATCH 4/5] New API: add btrfs_filesystem_defragment