btrfs-progs: fixup is_mounted checks
authorChris Mason <chris.mason@oracle.com>
Thu, 27 Oct 2011 20:23:14 +0000 (16:23 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 27 Oct 2011 20:23:14 +0000 (16:23 -0400)
/proc/mounts contains device names that don't exist,
we end up erroring out because we're not able to stat
the device (that doesn't exist).

Fix this by allowing the mkfs when the target device doesn't exist.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
utils.c

diff --git a/utils.c b/utils.c
index 86c643c..178d1b9 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -687,6 +687,8 @@ int is_same_blk_file(const char* a, const char* b)
        if(stat(a, &st_buf_a) < 0 ||
           stat(b, &st_buf_b) < 0)
        {
+               if (errno == ENOENT)
+                       return 0;
                return -errno;
        }
 
@@ -723,9 +725,11 @@ int is_same_loop_file(const char* a, const char* b)
 
        /* Resolve a if it is a loop device */
        if((ret = is_loop_device(a)) < 0) {
-          return ret;
-       } else if(ret) {
-               if((ret = resolve_loop_device(a, res_a, sizeof(res_a))) < 0)
+               if (ret == -ENOENT)
+                       return 0;
+               return ret;
+       } else if (ret) {
+               if ((ret = resolve_loop_device(a, res_a, sizeof(res_a))) < 0)
                        return ret;
 
                final_a = res_a;
@@ -734,9 +738,11 @@ int is_same_loop_file(const char* a, const char* b)
        }
 
        /* Resolve b if it is a loop device */
-       if((ret = is_loop_device(b)) < 0) {
-          return ret;
-       } else if(ret) {
+       if ((ret = is_loop_device(b)) < 0) {
+               if (ret == -ENOENT)
+                       return 0;
+               return ret;
+       } else if (ret) {
                if((ret = resolve_loop_device(b, res_b, sizeof(res_b))) < 0)
                        return ret;