b7e7c9fe1c
- fix failing on deleted loop mounts (bnc#697671) OBS-URL: https://build.opensuse.org/request/show/75017 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/btrfsprogs?expand=0&rev=20
82 lines
1.9 KiB
Diff
82 lines
1.9 KiB
Diff
diff --git a/utils.c b/utils.c
|
|
index fd894f3..4f089f5 100644
|
|
--- a/utils.c
|
|
+++ b/utils.c
|
|
@@ -633,19 +633,29 @@ 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)
|
|
return 1;
|
|
|
|
- if(stat(a, &st_buf_a) < 0 ||
|
|
- stat(b, &st_buf_b) < 0)
|
|
- {
|
|
+ if(stat(a, &st_buf_a) < 0)
|
|
+ {
|
|
+ if (errno == ENOENT)
|
|
+ return 0;
|
|
+
|
|
+ return -errno;
|
|
+ }
|
|
+
|
|
+ if(stat(b, &st_buf_b) < 0)
|
|
+ {
|
|
+ if (errno == ENOENT)
|
|
+ return 0;
|
|
+
|
|
return -errno;
|
|
}
|
|
|
|
@@ -684,10 +694,12 @@ int is_same_loop_file(const char* a, const char* b)
|
|
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 = resolve_loop_device(a, res_a, sizeof(res_a))) < 0) {
|
|
+ if (errno != EPERM)
|
|
return ret;
|
|
-
|
|
- final_a = res_a;
|
|
+ }
|
|
+ else
|
|
+ final_a = res_a;
|
|
} else {
|
|
final_a = a;
|
|
}
|
|
@@ -696,15 +708,17 @@ int is_same_loop_file(const char* a, const char* b)
|
|
if((ret = is_loop_device(b)) < 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;
|
|
}
|
|
|
|
- return is_same_blk_file(final_a, final_b);
|
|
+ return is_same_blk_file(final_a, final_b);
|
|
}
|
|
|
|
/* Checks if a file exists and is a block or regular file*/
|