From: David Levine Date: Sun, 6 May 2012 15:59:42 +0000 (-0500) Subject: Added check for EPERM when checking errno after a failed link(2). X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=783f1bcf7d7429121a97eb0117bf444c1a59a28e;p=mmh Added check for EPERM when checking errno after a failed link(2). Cygwin will produce that on FAT32 filesystems. Must do this at runtime rather than configure time because link() succeeds on NTFS filesystems. --- diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c old mode 100644 new mode 100755 index a0595e6..1a1c8b1 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -166,8 +166,9 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, * across devices, then check if there is a message * already in the desired location. If so, then return * error, else just copy the message. + * Cygwin with FAT32 filesystem produces EPERM. */ - if (linkerr == EXDEV) { + if (linkerr == EXDEV || linkerr == EPERM) { if (stat (newmsg, &st1) == 0) { advise (NULL, "message %s:%s already exists", mp->foldpath, newmsg); return -1; diff --git a/test/refile/test-refile b/test/refile/test-refile index 9de20e2..0d9303c 100755 --- a/test/refile/test-refile +++ b/test/refile/test-refile @@ -115,17 +115,29 @@ other+ has 1 message (1- 1). TOTAL = 11 messages in 2 folders.' -# check -link -run_test 'refile 7 -src +inbox +other -link' '' -run_test 'folders -noheader' \ -'inbox+ has 10 messages (1-10); cur=7. +printf '' > $$.txt +set +e +if link $$.txt $$-2.txt 2>/dev/null; then + # Hard links are supported. + # check -link + run_test 'refile 7 -src +inbox +other -link' '' + run_test 'folders -noheader' \ + 'inbox+ has 10 messages (1-10); cur=7. other has 2 messages (1- 2). TOTAL = 12 messages in 2 folders.' -# inbox/7 and other/2 are linked. Modify one and verify -# that the other changes as well. -echo '' >>$MH_TEST_DIR/Mail/other/2 -run_test "cmp $MH_TEST_DIR/Mail/inbox/7 $MH_TEST_DIR/Mail/other/2" '' + # inbox/7 and other/2 are linked. Modify one and verify + # that the other changes as well. + echo '' >>$MH_TEST_DIR/Mail/other/2 + run_test "cmp $MH_TEST_DIR/Mail/inbox/7 $MH_TEST_DIR/Mail/other/2" '' +else + # Hard links are not supported. Skip the -link test but emulate + # what it would have done using a copy instead of a link. + cp -p Mail/inbox/7 Mail/other/2 + folder -f +inbox 7 >/dev/null +fi +set -e +rm -f $$.txt $$-2.txt # check -nolink run_test 'refile 7 +other -link -nolink' '' diff --git a/uip/send.c b/uip/send.c old mode 100644 new mode 100755 index 5034121..577abac --- a/uip/send.c +++ b/uip/send.c @@ -442,7 +442,8 @@ go_to_it: distfile = getcpy (m_mktemp2 (altmsg, invo_name, NULL, NULL)); unlink(distfile); if (link (altmsg, distfile) == NOTOK) { - if (errno != EXDEV + /* Cygwin with FAT32 filesystem produces EPERM. */ + if (errno != EXDEV && errno != EPERM #ifdef EISREMOTE && errno != EISREMOTE #endif /* EISREMOTE */