summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2011-10-27 16:23:14 -0400
committerChris Mason <chris.mason@oracle.com>2011-10-27 16:23:14 -0400
commitba1aa28496cf2a2c7ffff0521c6c858a0505d4c2 (patch)
treeafb36912305ae49312eb50aa25434499a57e64ee /utils.c
parentbe826706b5c0fcca3bdeff6934cd8d46d046ddfe (diff)
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 <chris.mason@oracle.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c18
1 files changed, 12 insertions, 6 deletions
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;