From ba1aa28496cf2a2c7ffff0521c6c858a0505d4c2 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Thu, 27 Oct 2011 16:23:14 -0400 Subject: btrfs-progs: fixup is_mounted checks /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 --- utils.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 86c643c1..178d1b9d 100644 --- 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; -- cgit v1.2.3