86 lines
2.1 KiB
Diff
86 lines
2.1 KiB
Diff
|
From 6ca37050db7e94257559da2b8e8009c2347ed798 Mon Sep 17 00:00:00 2001
|
||
|
From: Chris Mason <chris.mason@oracle.com>
|
||
|
Date: Thu, 27 Oct 2011 16:23:14 -0400
|
||
|
Subject: [PATCH 16/35] 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>
|
||
|
---
|
||
|
utils.c | 34 +++++++++++++++++++---------------
|
||
|
1 files changed, 19 insertions(+), 15 deletions(-)
|
||
|
|
||
|
diff --git a/utils.c b/utils.c
|
||
|
index 1c27e14..6c96548 100644
|
||
|
--- a/utils.c
|
||
|
+++ b/utils.c
|
||
|
@@ -674,11 +674,11 @@ int is_same_blk_file(const char* a, const char* b)
|
||
|
char real_a[PATH_MAX];
|
||
|
char real_b[PATH_MAX];
|
||
|
|
||
|
- if(!realpath(a, real_a) ||
|
||
|
- !realpath(b, real_b))
|
||
|
- {
|
||
|
- return -errno;
|
||
|
- }
|
||
|
+ if(!realpath(a, real_a))
|
||
|
+ strcpy(real_a, a);
|
||
|
+
|
||
|
+ if (!realpath(b, real_b))
|
||
|
+ strcpy(real_b, b);
|
||
|
|
||
|
/* Identical path? */
|
||
|
if(strcmp(real_a, real_b) == 0)
|
||
|
@@ -719,8 +719,8 @@ int is_same_loop_file(const char* a, const char* b)
|
||
|
{
|
||
|
char res_a[PATH_MAX];
|
||
|
char res_b[PATH_MAX];
|
||
|
- const char* final_a;
|
||
|
- const char* final_b;
|
||
|
+ const char* final_a = NULL;
|
||
|
+ const char* final_b = NULL;
|
||
|
int ret;
|
||
|
|
||
|
/* Resolve a if it is a loop device */
|
||
|
@@ -729,10 +729,12 @@ int is_same_loop_file(const char* a, const char* b)
|
||
|
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;
|
||
|
+ if ((ret = resolve_loop_device(a, res_a, sizeof(res_a))) < 0) {
|
||
|
+ if (errno != EPERM)
|
||
|
+ return ret;
|
||
|
+ }
|
||
|
+ else
|
||
|
+ final_a = res_a;
|
||
|
} else {
|
||
|
final_a = a;
|
||
|
}
|
||
|
@@ -743,10 +745,12 @@ int is_same_loop_file(const char* a, const char* b)
|
||
|
return 0;
|
||
|
return ret;
|
||
|
} else if (ret) {
|
||
|
- if((ret = resolve_loop_device(b, res_b, sizeof(res_b))) < 0)
|
||
|
- return ret;
|
||
|
-
|
||
|
- final_b = res_b;
|
||
|
+ if ((ret = resolve_loop_device(b, res_b, sizeof(res_b))) < 0) {
|
||
|
+ if (errno != EPERM)
|
||
|
+ return ret;
|
||
|
+ }
|
||
|
+ else
|
||
|
+ final_b = res_b;
|
||
|
} else {
|
||
|
final_b = b;
|
||
|
}
|
||
|
--
|
||
|
1.7.6.233.gd79bc
|
||
|
|