From: Anand Jain <Anand.Jain@oracle.com>
To: Josef Bacik <jbacik@fusionio.com>
Cc: linux-btrfs@vger.kernel.org, zab@redhat.com, dsterba@suse.cz
Subject: Re: [PATCH 4/4] btrfs-progs: lblkid wouldn't find non mapper path input
Date: Thu, 07 Nov 2013 17:54:21 +0800 [thread overview]
Message-ID: <527B634D.3020701@oracle.com> (raw)
In-Reply-To: <20131106202018.GG27784@localhost.localdomain>
Done.
On 11/07/13 04:20 AM, Josef Bacik wrote:
> On Mon, Nov 04, 2013 at 11:45:45AM +0800, Anand Jain wrote:
>> A new test case when disk is unmounted and if the non mapper
>> disk path is given as the argument to the btrfs filesystem show<arg>
>> we still need this to work but lblkid will pull only mapper disks,
>> it won't match. So this will normalize the input to find btrfs
>> by fsid and pass it to the search.
>>
>> v2: accepts Josef suggested
>>
>> Signed-off-by: Anand Jain<anand.jain@oracle.com>
>> ---
>> cmds-filesystem.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---
>> 1 files changed, 55 insertions(+), 4 deletions(-)
>>
>> diff --git a/cmds-filesystem.c b/cmds-filesystem.c
>> index f8e8475..f40178a 100644
>> --- a/cmds-filesystem.c
>> +++ b/cmds-filesystem.c
>> @@ -37,6 +37,7 @@
>> #include "version.h"
>> #include "commands.h"
>> #include "list_sort.h"
>> +#include "disk-io.h"
>>
>> static const char * const filesystem_cmd_group_usage[] = {
>> "btrfs filesystem [<group>]<command> [<args>]",
>> @@ -414,6 +415,39 @@ static int btrfs_scan_kernel(void *search)
>> return 0;
>> }
>>
>> +static int dev_to_fsid(char *dev, __u8 *fsid)
>> +{
>> + struct btrfs_super_block *disk_super;
>> + char *buf;
>> + int ret;
>> + int fd;
>> +
>> + buf = malloc(4096);
>> + if (!buf)
>> + return -ENOMEM;
>> +
>> + fd = open(dev, O_RDONLY);
>> + if (fd< 0) {
>> + ret = -errno;
>> + free(buf);
>> + return ret;
>> + }
>> +
>> + disk_super = (struct btrfs_super_block *)buf;
>> + ret = btrfs_read_dev_super(fd, disk_super,
>> + BTRFS_SUPER_INFO_OFFSET);
>> + if (ret)
>> + goto out;
>> +
>> + memcpy(fsid, disk_super->fsid, BTRFS_FSID_SIZE);
>> + ret = 0;
>> +
>> +out:
>> + close(fd);
>> + free(buf);
>> + return ret;
>> +}
>> +
>> static const char * const cmd_show_usage[] = {
>> "btrfs filesystem show [options] [<path>|<uuid>|<device>|label]",
>> "Show the structure of a filesystem",
>> @@ -434,6 +468,8 @@ static int cmd_show(int argc, char **argv)
>> int type = 0;
>> char mp[BTRFS_PATH_NAME_MAX + 1];
>> char path[PATH_MAX];
>> + __u8 fsid[BTRFS_FSID_SIZE];
>> + char uuid_buf[37];
>>
>> while (1) {
>> int long_index;
>> @@ -466,6 +502,10 @@ static int cmd_show(int argc, char **argv)
>> if (strlen(search) == 0)
>> usage(cmd_show_usage);
>> type = check_arg_type(search);
>> + /*needs spl handling if input arg is block dev
>> + *And if input arg is mount-point just print it
>> + *right away
>> + */
>
> Format screwup. Thanks,
>
> Josef
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-11-07 9:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-04 3:45 [PATCH 1/4] btrfs-progs: make filesystem show by label work Anand Jain
2013-11-04 3:45 ` [PATCH 2/4 v2] btrfs-progs: mechanism to fetch fsinfo from btrfs-control Anand Jain
2013-11-06 20:13 ` Josef Bacik
2013-11-07 9:53 ` Anand Jain
2013-11-04 3:45 ` [PATCH 3/4 v2] btrfs-progs: fs show should handle if subvol(s) mounted Anand Jain
2013-11-06 20:19 ` Josef Bacik
2013-11-07 9:54 ` Anand Jain
2013-11-04 3:45 ` [PATCH 4/4] btrfs-progs: lblkid wouldn't find non mapper path input Anand Jain
2013-11-04 4:36 ` [PATCH 4/4 v2] " Anand Jain
2013-11-06 20:20 ` [PATCH 4/4] " Josef Bacik
2013-11-07 9:54 ` Anand Jain [this message]
2013-11-07 10:06 ` [PATCH 1/3] btrfs-progs: mechanism to fetch fsinfo from btrfs-control v3 Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=527B634D.3020701@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=zab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).