linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Lei <zhaolei@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Zhao Lei <zhaolei@cn.fujitsu.com>
Subject: [PATCH 00/11] btrfs-progs: Use btrfs_open_dir to avoid show error of ioctl or tree search
Date: Mon, 12 Oct 2015 21:22:53 +0800	[thread overview]
Message-ID: <cover.1444655800.git.zhaolei@cn.fujitsu.com> (raw)

Use btrfs_open_dir() instead of open_file_or_dir(), to show error before
real action(in ioctl or tree search), to make the error message exact
and unified.

It can also make code simple:
  85 insertions(+), 185 deletions(-)

Also include some small bug fix.

Before patch:
  # grep open_file_or_dir *.c
  btrfs-fragments.c:      fd = open_file_or_dir(path, &dirstream);
  cmds-balance.c: fd = open_file_or_dir(path, &dirstream);
  cmds-balance.c: fd = open_file_or_dir(path, &dirstream);
  cmds-balance.c: fd = open_file_or_dir(path, &dirstream);
  cmds-balance.c: fd = open_file_or_dir(path, &dirstream);
  cmds-balance.c: fd = open_file_or_dir(path, &dirstream);
  cmds-filesystem.c:      fd = open_file_or_dir(path, &dirstream);
  cmds-filesystem.c:      fd = open_file_or_dir(path, &dirstream);
  cmds-filesystem.c:              fd = open_file_or_dir(argv[i], &dirstream);
  cmds-filesystem.c:      fd = open_file_or_dir(path, &dirstream);
  cmds-fi-usage.c:                fd = open_file_or_dir(argv[i], &dirstream);
  cmds-inspect.c: fd = open_file_or_dir(argv[optind+1], &dirstream);
  cmds-inspect.c: fd = open_file_or_dir(argv[optind+1], &dirstream);
  cmds-inspect.c:                         path_fd = open_file_or_dir(full_path, &dirs);
  cmds-inspect.c: fd = open_file_or_dir(argv[2], &dirstream);
  cmds-inspect.c: fd = open_file_or_dir(argv[1], &dirstream);
  cmds-inspect.c: fd = open_file_or_dir(argv[optind], &dirstream);
  cmds-qgroup.c:  fd = open_file_or_dir(path, &dirstream);
  cmds-qgroup.c:  fd = open_file_or_dir(path, &dirstream);
  cmds-qgroup.c:  fd = open_file_or_dir(path, &dirstream);
  cmds-qgroup.c:  fd = open_file_or_dir(path, &dirstream);
  cmds-quota.c:   fd = open_file_or_dir(path, &dirstream);
  cmds-quota.c:   fd = open_file_or_dir(path, &dirstream);
  cmds-replace.c: fd = open_file_or_dir(path, &dirstream);
  cmds-replace.c: fd = open_file_or_dir(path, &dirstream);
  cmds-subvolume.c:       fddst = open_file_or_dir(dstdir, &dirstream);
  cmds-subvolume.c:       fd = open_file_or_dir(dname, &dirstream);
  cmds-subvolume.c:       fd = open_file_or_dir(subvol, &dirstream);
  cmds-subvolume.c:       fddst = open_file_or_dir(dstdir, &dirstream1);
  cmds-subvolume.c:       fd = open_file_or_dir(subvol, &dirstream2);
  cmds-subvolume.c:       fd = open_file_or_dir(subvol, &dirstream);
  cmds-subvolume.c:       fd = open_file_or_dir(path, &dirstream);
  cmds-subvolume.c:       fd = open_file_or_dir(subvol, &dirstream);
  cmds-subvolume.c:       fd = open_file_or_dir(fullpath, &dirstream1);
  cmds-subvolume.c:       mntfd = open_file_or_dir(mnt, &dirstream2);
  cmds-subvolume.c:       fd = open_file_or_dir(argv[optind], &dirstream);
  props.c:        fd = open_file_or_dir3(object, &dirstream, open_flags);
  utils.c:                fdmnt = open_file_or_dir(mp, dirstream);
  utils.c:                fdmnt = open_file_or_dir(path, dirstream);
  utils.c: * Do the following checks before calling open_file_or_dir():
  utils.c:        ret = open_file_or_dir(path, dirstream);
  utils.c:int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags)
  utils.c:int open_file_or_dir(const char *fname, DIR **dirstream)
  utils.c:        return open_file_or_dir3(fname, dirstream, O_RDWR);
  utils.c:        fd = open_file_or_dir(path, &dirstream);
  #

After patch:
  # grep open_file_or_dir *.c
  cmds-filesystem.c:              fd = open_file_or_dir(argv[i], &dirstream); *1
  props.c:        fd = open_file_or_dir3(object, &dirstream, open_flags);
  utils.c:                ret = open_file_or_dir(mp, dirstream);
  utils.c: * Do the following checks before calling open_file_or_dir():
  utils.c:        ret = open_file_or_dir(path, dirstream);
  utils.c:int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags)
  utils.c:int open_file_or_dir(const char *fname, DIR **dirstream)
  utils.c:        return open_file_or_dir3(fname, dirstream, O_RDWR);
  utils.c:        fd = open_file_or_dir(path, &dirstream);
  #
  *1: It is used to open dir or file, can not use btrfs_open_dir()
      instead.

Zhao Lei (11):
  btrfs-progs: subvolume: use btrfs_open_dir for btrfs subvolume command
  btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem
    command
  btrfs-progs: balance: use btrfs_open_dir for btrfs balance command
  btrfs-progs: inspect: Bypass unnecessary clean function in open_error
  btrfs-progs: inspect: set return value of error case
  btrfs-progs: inspect: use btrfs_open_dir for btrfs inspect command
  btrfs-progs: qgroup: use btrfs_open_dir for btrfs qgroup command
  btrfs-progs: quota: use btrfs_open_dir for btrfs quota command
  btrfs-progs: use btrfs_open_dir in open_path_or_dev_mnt
  btrfs-progs: replace: use btrfs_open_dir for btrfs replace command
  btrfs-progs: fragments: use btrfs_open_dir for btrfs-fragments command

 btrfs-fragments.c |  6 ++----
 cmds-balance.c    | 30 ++++++++++-------------------
 cmds-device.c     | 13 ++-----------
 cmds-fi-usage.c   |  4 +---
 cmds-filesystem.c | 19 +++++++------------
 cmds-inspect.c    | 26 +++++++++-----------------
 cmds-qgroup.c     | 24 ++++++++----------------
 cmds-quota.c      | 12 ++++--------
 cmds-replace.c    | 29 ++++++----------------------
 cmds-scrub.c      | 28 +++++-----------------------
 cmds-subvolume.c  | 56 +++++++++++++++++++------------------------------------
 utils.c           | 21 +++++++++++----------
 utils.h           |  2 +-
 13 files changed, 85 insertions(+), 185 deletions(-)

-- 
1.8.5.1


             reply	other threads:[~2015-10-12 13:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 13:22 Zhao Lei [this message]
2015-10-12 13:22 ` [PATCH 01/11] btrfs-progs: subvolume: use btrfs_open_dir for btrfs subvolume command Zhao Lei
2015-10-12 13:22 ` [PATCH 02/11] btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem command Zhao Lei
2015-10-12 13:22 ` [PATCH 03/11] btrfs-progs: balance: use btrfs_open_dir for btrfs balance command Zhao Lei
2015-10-12 13:22 ` [PATCH 04/11] btrfs-progs: inspect: Bypass unnecessary clean function in open_error Zhao Lei
2015-10-12 13:22 ` [PATCH 05/11] btrfs-progs: inspect: set return value of error case Zhao Lei
2015-10-12 13:22 ` [PATCH 06/11] btrfs-progs: inspect: use btrfs_open_dir for btrfs inspect command Zhao Lei
2015-10-12 13:23 ` [PATCH 07/11] btrfs-progs: qgroup: use btrfs_open_dir for btrfs qgroup command Zhao Lei
2015-10-12 13:23 ` [PATCH 08/11] btrfs-progs: quota: use btrfs_open_dir for btrfs quota command Zhao Lei
2015-10-12 13:23 ` [PATCH 09/11] btrfs-progs: use btrfs_open_dir in open_path_or_dev_mnt Zhao Lei
2015-10-12 13:23 ` [PATCH 10/11] btrfs-progs: replace: use btrfs_open_dir for btrfs replace command Zhao Lei
2015-10-12 13:23 ` [PATCH 11/11] btrfs-progs: fragments: use btrfs_open_dir for btrfs-fragments command Zhao Lei
2015-10-13 15:58 ` [PATCH 00/11] btrfs-progs: Use btrfs_open_dir to avoid show error of ioctl or tree search 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=cover.1444655800.git.zhaolei@cn.fujitsu.com \
    --to=zhaolei@cn.fujitsu.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).