From b7e7c9fe1c5c2f1f519ea6f44d4362305d6a6cc408911ab382f374ed9d01233b Mon Sep 17 00:00:00 2001 From: Sascha Peilicke Date: Mon, 4 Jul 2011 07:35:11 +0000 Subject: [PATCH] Accepting request 75017 from filesystems - 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 --- btrfsprogs.changes | 5 +++ btrfsprogs.spec | 2 + ignore-deleted-loopmounts.diff | 81 ++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 ignore-deleted-loopmounts.diff diff --git a/btrfsprogs.changes b/btrfsprogs.changes index bdf6cf9..d58d2fe 100644 --- a/btrfsprogs.changes +++ b/btrfsprogs.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Jul 1 16:31:44 CEST 2011 - dmueller@suse.de + +- fix failing on deleted loop mounts (bnc#697671) + ------------------------------------------------------------------- Mon Mar 21 13:01:23 CET 2011 - dmueller@suse.de diff --git a/btrfsprogs.spec b/btrfsprogs.spec index 77db926..f1563e7 100644 --- a/btrfsprogs.spec +++ b/btrfsprogs.spec @@ -29,6 +29,7 @@ Supplements: filesystem(btrfs) Source: btrfs-progs-%{tar_version}.tar.bz2 Patch0: memleak-fix.diff Patch1: 0001-Plug-Memory-leak-in-find_and_setup_log_root.patch +Patch2: ignore-deleted-loopmounts.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: libacl-devel libext2fs-devel libuuid-devel zlib-devel # for /bin/true @@ -42,6 +43,7 @@ debugging btrfs file systems. %setup -q -n btrfs-progs-%{tar_version} %patch0 %patch1 -p1 +%patch2 -p1 %build make %{?jobs:-j%jobs} CFLAGS="%{optflags}" all convert diff --git a/ignore-deleted-loopmounts.diff b/ignore-deleted-loopmounts.diff new file mode 100644 index 0000000..d7c1345 --- /dev/null +++ b/ignore-deleted-loopmounts.diff @@ -0,0 +1,81 @@ +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*/