From: Anand Jain <Anand.Jain@oracle.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org, jbacik@fusionio.com
Subject: Re: [PATCH v4 2/3] btrfs-progs: fs show should handle if subvol(s) mounted
Date: Thu, 21 Nov 2013 11:32:36 +0800 [thread overview]
Message-ID: <528D7ED4.1000300@oracle.com> (raw)
In-Reply-To: <20131120141856.GH5007@twin.jikos.cz>
On 11/20/2013 10:18 PM, David Sterba wrote:
> On Fri, Nov 15, 2013 at 07:25:34PM +0800, Anand Jain wrote:
>> static int btrfs_scan_kernel(void *search)
>> {
>> - int ret = 0, fd;
>> - FILE *f;
>> - struct mntent *mnt;
>> - struct btrfs_ioctl_fs_info_args fs_info_arg;
>> - struct btrfs_ioctl_dev_info_args *dev_info_arg = NULL;
>> - struct btrfs_ioctl_space_args *space_info_arg;
>> + int ret = 0;
>> char label[BTRFS_LABEL_SIZE];
>> -
>> - f = setmntent("/proc/self/mounts", "r");
>> - if (f == NULL)
>> - return 1;
>> -
>> - memset(label, 0, sizeof(label));
>> - while ((mnt = getmntent(f)) != NULL) {
>> - if (strcmp(mnt->mnt_type, "btrfs"))
>> + char mnt[BTRFS_PATH_NAME_MAX + 1];
>> + struct btrfs_ioctl_fslist *fslist;
>> + struct btrfs_ioctl_fslist *fslist_saved;
>
> [CC] cmds-send.o
> cmds-filesystem.c: In function ‘btrfs_scan_kernel’:
> cmds-filesystem.c:461:29: warning: variable ‘fslist_saved’ set but not used [-Wunused-but-set-variable]
Thanks David. That was something for later todo which I missed.
sorry my mistake. Sent out v5.
>> + u64 cnt_fs;
>> + int cnt_mnt;
>> + __u8 *fsid;
>> + __u64 flags;
>> +
>> + ret = get_fslist(&fslist, &cnt_fs);
>> + if (ret)
>> + return ret;
>> + fslist_saved = fslist;
>> + while (cnt_fs--) {
>> + fsid = fslist->fsid;
>> + flags = fslist->flags;
>> + fslist++;
>> + if (!(flags & BTRFS_FS_MOUNTED))
>> continue;
>> - ret = get_fs_info(mnt->mnt_dir, &fs_info_arg,
>> - &dev_info_arg);
>> + memset(mnt, 0, BTRFS_PATH_NAME_MAX + 1);
>> + memset(label, 0, sizeof(label));
>> + ret = fsid_to_mntpt(fsid, mnt, &cnt_mnt);
>> if (ret)
>> return ret;
>> -
>> - if (get_label_mounted(mnt->mnt_dir, label)) {
>> - kfree(dev_info_arg);
>> + if (get_label_mounted(mnt, label))
>> return 1;
>> - }
>> - if (search && !match_search_item_kernel(fs_info_arg.fsid,
>> - mnt->mnt_dir, label, search)) {
>> - kfree(dev_info_arg);
>> +
>> + if (search && !match_search_item_kernel(fsid,
>> + mnt, label, search))
>> continue;
>> - }
>>
>> - fd = open(mnt->mnt_dir, O_RDONLY);
>> - if ((fd != -1) && !get_df(fd, &space_info_arg)) {
>> - print_one_fs(&fs_info_arg, dev_info_arg,
>> - space_info_arg, label, mnt->mnt_dir);
>> - kfree(space_info_arg);
>> - memset(label, 0, sizeof(label));
>> - }
>> - if (fd != -1)
>> - close(fd);
>> - kfree(dev_info_arg);
>> + handle_print(mnt, label);
>> if (search)
>> return 0;
>> }
> --
> 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-21 3:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 11:25 [PATCH v4 1/3] btrfs-progs: mechanism to fetch fsinfo from btrfs-control Anand Jain
2013-11-15 11:25 ` [PATCH v4 2/3] btrfs-progs: fs show should handle if subvol(s) mounted Anand Jain
2013-11-20 14:18 ` David Sterba
2013-11-21 3:32 ` Anand Jain [this message]
2013-11-22 7:56 ` David Sterba
2013-11-21 3:28 ` [PATCH v5 " Anand Jain
2013-11-15 11:25 ` [PATCH v4 3/3] btrfs-progs: lblkid wouldn't find non mapper path input Anand Jain
2013-11-15 15:07 ` [PATCH v4 1/3] btrfs-progs: mechanism to fetch fsinfo from btrfs-control David Sterba
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=528D7ED4.1000300@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
/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).