Hi, the patch provided before does not take into account that the file may exists before we call link() on a file system where link() fails (and not with EEXIST). In that case, we would use the already existing file.
The attached patch makes sure we try a new file name in that case. Regards, Andi
>From 0482adf516a914d9215ebd00b93ee63a15976836 Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" <a...@debian.org> Date: Fri, 24 Sep 2021 21:10:52 +0200 Subject: [PATCH] Fix for sshfs. --- debian/patches/series | 1 + debian/patches/sshfs.patch | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 debian/patches/sshfs.patch diff --git a/debian/patches/series b/debian/patches/series index e1ee4dfc..8c81fbe2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ 03_kfreebsd.patch 05_skip-known-test-failures.patch +sshfs.patch diff --git a/debian/patches/sshfs.patch b/debian/patches/sshfs.patch new file mode 100644 index 00000000..a1f6ab5f --- /dev/null +++ b/debian/patches/sshfs.patch @@ -0,0 +1,23 @@ +--- a/pkcs11/gkm/gkm-transaction.c ++++ b/pkcs11/gkm/gkm-transaction.c +@@ -294,16 +294,16 @@ + * stat, the check on the increased link count + * will fail. Fortunately the case for + * hardlinks are not working solves it. */ +- if (link (filename, result) && errno == EEXIST) { ++ if (!access (result, F_OK) || (link (filename, result) && errno == EEXIST)) { + /* This is probably a valid error. + * Let us try another temporary file. */ + } else if (stat (filename, &sb)) { + stat_failed = 1; + } else { +- if ((sb.st_nlink == nlink + 1) ++ if ((sb.st_nlink == nlink + 1) || !access (result, F_OK) + || !copy_to_temp_file (result, filename)) { +- /* Either the link worked or +- * the copy succeeded. */ ++ /* Either the link worked (on sshfs, a copy is made ++ * instead) or the final copy_to_temp_file succeeded. */ + gkm_transaction_add (self, NULL, + complete_link_temporary, + result); -- 2.30.2