btrfs-progs: make get_btrfs_mount callable
authorAnand Jain <Anand.Jain@oracle.com>
Tue, 22 Oct 2013 05:53:21 +0000 (13:53 +0800)
committerChris Mason <chris.mason@fusionio.com>
Thu, 24 Oct 2013 09:57:44 +0000 (05:57 -0400)
get_btrfs_mount is reusable function but it is printing
errors, this removes it. Here the parent function of
open_path_or_dev_mnt does print error msg on error.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
utils.c
utils.h

diff --git a/utils.c b/utils.c
index a7441c1..cb69b2b 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -692,7 +692,8 @@ int is_block_device(const char *path) {
  * On failure, returns -errno (not mounted yields -EINVAL)
  * Is noisy on failures, expects to be given a mounted device.
  */
-static int get_btrfs_mount(const char *dev, char *mp, size_t mp_size) {
+int get_btrfs_mount(const char *dev, char *mp, size_t mp_size)
+{
        int ret;
        int fd = -1;
 
@@ -717,7 +718,6 @@ static int get_btrfs_mount(const char *dev, char *mp, size_t mp_size) {
 
        ret = check_mounted_where(fd, dev, mp, mp_size, NULL);
        if (!ret) {
-               fprintf(stderr, "%s is not a mounted btrfs device\n", dev);
                ret = -EINVAL;
        } else { /* mounted, all good */
                ret = 0;
@@ -725,8 +725,6 @@ static int get_btrfs_mount(const char *dev, char *mp, size_t mp_size) {
 out:
        if (fd != -1)
                close(fd);
-       if (ret)
-               fprintf(stderr, "Could not get mountpoint for %s\n", dev);
        return ret;
 }
 
diff --git a/utils.h b/utils.h
index 251ef8e..8370686 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -91,5 +91,6 @@ int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
 int ask_user(char *question);
 int lookup_ino_rootid(int fd, u64 *rootid);
 int btrfs_scan_lblkid(int update_kernel);
+int get_btrfs_mount(const char *dev, char *mp, size_t mp_size);
 
 #endif