From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: [PATCH] btrfs-progs: fix loop device mount checks
Date: Fri, 20 Sep 2013 18:52:18 +0200 [thread overview]
Message-ID: <1379695938-31244-1-git-send-email-dsterba@suse.cz> (raw)
When creating a fs on a loop device, mkfs checks whether the same file
is not already mounted, but a backing file of another loop dev does not
exist, mkfs fails. This fixes a bug during openSUSE installation.
Signed-off-by: David Sterba <dsterba@suse.cz>
---
utils.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/utils.c b/utils.c
index 5fa193b..357983d 100644
--- a/utils.c
+++ b/utils.c
@@ -803,11 +803,11 @@ static 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)
@@ -848,8 +848,8 @@ static 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 */
@@ -858,10 +858,13 @@ static 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;
+ ret = resolve_loop_device(a, res_a, sizeof(res_a));
+ if (ret < 0) {
+ if (errno != EPERM)
+ return ret;
+ } else {
+ final_a = res_a;
+ }
} else {
final_a = a;
}
@@ -872,10 +875,13 @@ static 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;
+ ret = resolve_loop_device(b, res_b, sizeof(res_b));
+ if (ret < 0) {
+ if (errno != EPERM)
+ return ret;
+ } else {
+ final_b = res_b;
+ }
} else {
final_b = b;
}
--
1.8.3.1
reply other threads:[~2013-09-20 16:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379695938-31244-1-git-send-email-dsterba@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).