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>
master
Chris Mason 2011-10-27 16:23:14 -04:00
parent be826706b5
commit ba1aa28496
1 changed files with 12 additions and 6 deletions

18
utils.c
View File

@ -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;