From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#13807: updated version to avoid MS-Windows vs non-MS-Windows clashes Date: Sat, 02 Mar 2013 14:37:29 -0800 Organization: UCLA Computer Science Department Message-ID: <51327F29.5000600@cs.ucla.edu> References: <512A98D5.7080000@cs.ucla.edu> <512D3508.1000906@cs.ucla.edu> <83txoxwq0p.fsf@gnu.org> <51326459.4030001@cs.ucla.edu> <83vc99tsbm.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050900080305030900000207" X-Trace: ger.gmane.org 1362263886 31147 80.91.229.3 (2 Mar 2013 22:38:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Mar 2013 22:38:06 +0000 (UTC) Cc: 13807@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 02 23:38:29 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UBv4W-0003oO-GX for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Mar 2013 23:38:28 +0100 Original-Received: from localhost ([::1]:40550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBv4B-0008Sz-4e for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Mar 2013 17:38:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:50105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBv45-0008Rj-BG for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2013 17:38:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBv40-00076d-QZ for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2013 17:38:01 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBv40-00076L-Mz for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2013 17:37:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UBv45-0002lb-Jt for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2013 17:38:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Mar 2013 22:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13807 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13807-submit@debbugs.gnu.org id=B13807.136226387010618 (code B ref 13807); Sat, 02 Mar 2013 22:38:01 +0000 Original-Received: (at 13807) by debbugs.gnu.org; 2 Mar 2013 22:37:50 +0000 Original-Received: from localhost ([127.0.0.1]:55985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UBv3s-0002lC-TJ for submit@debbugs.gnu.org; Sat, 02 Mar 2013 17:37:50 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:34285) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UBv3n-0002kw-E4 for 13807@debbugs.gnu.org; Sat, 02 Mar 2013 17:37:47 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 0B8C1A60015; Sat, 2 Mar 2013 14:37:32 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eLmzjpl27YEa; Sat, 2 Mar 2013 14:37:29 -0800 (PST) Original-Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id D0991A6000E; Sat, 2 Mar 2013 14:37:29 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 In-Reply-To: <83vc99tsbm.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72036 Archived-At: This is a multi-part message in MIME format. --------------050900080305030900000207 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 03/02/2013 01:17 PM, Eli Zaretskii wrote: > Can you describe your testing > in more details, and what versions of NFS and Windows did you use? Sure, I created a MS-Windows style lock file .#FILE by hand, then edited FILE with a GNU/Linux Emacs. I didn't build the MS-Windows Emacs, and didn't need to use NFS to reproduce the problem. There's another issue: a GNU/Linux Emacs might be using an MS-Windows file system that does not support symbolic links. Such an Emacs should use a regular-file lock, just as MS-Windows Emacs does, which means that the code to create regular-file locks should be implementable in POSIXish primitives. Also, locking should work even if the Emacs instance that created a lock uses a symlink whereas the Emacs instance trying to get the lock would use a regular file, or vice versa. It'll take some thinking to get all this to work well. I've written a first cut for this and have attached it. I have not tested this on MS-Windows at all, and haven't tested it as much as I'd like on GNU/Linux, but it should give a feel for the sort of changes that need to be made. Unfortunately the patch is a bit complicated, but to some extent this is inherent in such a complicated area. --------------050900080305030900000207 Content-Type: text/plain; charset=UTF-8; name="filelock2.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="filelock2.txt" PT09IG1vZGlmaWVkIGZpbGUgJ2V0Yy9DaGFuZ2VMb2cnCi0tLSBldGMvQ2hhbmdlTG9nCTIw MTMtMDMtMDIgMjA6NDE6NTMgKzAwMDAKKysrIGV0Yy9DaGFuZ2VMb2cJMjAxMy0wMy0wMiAy MjoyOToyMyArMDAwMApAQCAtMSw1ICsxLDggQEAKIDIwMTMtMDMtMDIgIFBhdWwgRWdnZXJ0 ICA8ZWdnZXJ0QGNzLnVjbGEuZWR1PgogCisJVGhlIGxvY2sgZm9yIEZJTEUgaXMgbm93IC4j RklMRSBhbmQgbWF5IGJlIGEgcmVndWxhciBmaWxlIChCdWcjMTM4MDcpLgorCSogTkVXUzog RG9jdW1lbnQgdGhpcy4KKwogCSogTkVXUzogVGhlIGxvY2sgZm9yIEZJTEUgaXMgbm93IC4j RklMRSBvciAuIy1GSUxFIChCdWcjMTM4MDcpLgogCiAyMDEzLTAzLTAxICBNaWNoYWVsIEFs YmludXMgIDxtaWNoYWVsLmFsYmludXNAZ214LmRlPgoKPT09IG1vZGlmaWVkIGZpbGUgJ2V0 Yy9ORVdTJwotLS0gZXRjL05FV1MJMjAxMy0wMy0wMiAyMDo0MTo1MyArMDAwMAorKysgZXRj L05FV1MJMjAxMy0wMy0wMiAyMjoyOToyMyArMDAwMApAQCAtMzIwLDcgKzMyMCw3IEBACiAq KiBUaGUgYGRlZmFsaWFzLWZzZXQtZnVuY3Rpb24nIHByb3BlcnR5IGxldHMgeW91IGNhdGNo IGNhbGxzIHRvIGRlZmFsaWFzCiBhbmQgcmVkaXJlY3QgdGhlbSB0byB5b3VyIG93biBmdW5j dGlvbiBpbnN0ZWFkIG9mIGBmc2V0Jy4KIAotKiogVGhlIGxvY2sgZm9yICdESVIvRklMRScg aXMgbm93ICdESVIvLiNGSUxFJyBvciAnRElSLy4j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KKwkgICAgZXJyID0gZXJybm87CisJICBpZiAoZW1hY3NfY2xvc2UgKGZkKSAh PSAwKQorCSAgICBlcnIgPSBlcnJubzsKKworCSAgLyogUmVuYW1lIE5PTkNFIHRvIExGTkFN RSwgYnV0IGRvIG5vdCByZXBsYWNlIGFueSBleGlzdGluZworCSAgICAgTEZOQU1FIHVubGVz cyBGT1JDRS4gIEl0IGlzIE9LIGlmIHRoZXJlIGFyZSB0ZW1wb3JhcmlseQorCSAgICAgdHdv IGhhcmQgbGlua3MgdG8gTEZOQU1FLiAgKi8KKwkgIGlmICghZXJyICYmIChmb3JjZSA/IHJl bmFtZSA6IGxpbmspIChub25jZSwgbGZuYW1lKSAhPSAwKQorCSAgICBlcnIgPSBlcnJubzsK KwkgIGlmICgoIWZvcmNlIHx8IGVycikgJiYgdW5saW5rIChub25jZSkgIT0gMAorCSAgICAg ICYmICFlcnIgJiYgZXJybm8gIT0gRU5PRU5UKQorCSAgICBlcnIgPSBlcnJubzsKKwl9CisK KyAgICAgIFNBRkVfRlJFRSAoKTsKKyAgICB9CisKICAgcmV0dXJuIGVycjsKIH0KIAogLyog TG9jayB0aGUgbG9jayBmaWxlIG5hbWVkIExGTkFNRS4KICAgIElmIEZPUkNFLCBkbyBzbyBl dmVuIGlmIGl0IGlzIGFscmVhZHkgbG9ja2VkLgotICAgUmV0dXJuIHRydWUgaWYgc3VjY2Vz c2Z1bC4gICovCisgICBSZXR1cm4gMCBpZiBzdWNjZXNzZnVsLCBhbiBlcnJvciBudW1iZXIg b24gZmFpbHVyZS4gICovCiAKLXN0YXRpYyBib29sCitzdGF0aWMgaW50CiBsb2NrX2ZpbGVf MSAoY2hhciAqbGZuYW1lLCBib29sIGZvcmNlKQogewotICBpbnQgZXJyOwotICBpbnQgc3lt bGlua19lcnJubzsKLSAgVVNFX1NBRkVfQUxMT0NBOwotCiAgIC8qIENhbGwgdGhpcyBmaXJz dCBiZWNhdXNlIGl0IGNhbiBHQy4gICovCiAgIHByaW50bWF4X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90KQotICAgIHJldHVybiAtMTsKLSAgbGVuID0gYXQgLSBsZmlu Zm87Ci0gIEdDUFJPMSAobGZpbmZvX29iamVjdCk7Ci0gIG93bmVyLT51c2VyID0geG1hbGxv YyAobGVuICsgMSk7Ci0gIG1lbWNweSAob3duZXItPnVzZXIsIGxmaW5mbywgbGVuKTsKLSAg b3duZXItPnVzZXJbbGVuXSA9IDA7CisgIGF0ID0gbWVtcmNociAob3duZXItPnVzZXIsICdA JywgbGZpbmZvbGVuKTsKKyAgaWYgKCFhdCkKKyAgICByZXR1cm4gLTE7CisgIGRvdCA9IHN0 cnJjaHIgKGF0LCAnLicpOworICBpZiAoIWRvdCkKKyAgICByZXR1cm4gLTE7CiAKICAgLyog VGhlIFBJRCBpcyBldmVyeXRoaW5nIGZyb20gdGhlIGxhc3QgYC4nIHRvIHRoZSBgOicuICAq LworICBpZiAoISBjX2lzZGlnaXQgKGRvdFsxXSkpCisgICAgcmV0dXJuIC0xOwogICBlcnJu byA9IDA7Ci0gIG4gPSBzdHJ0b2ltYXggKGRvdCArIDEsIE5VTEwsIDEwKTsKLSAgb3duZXIt PnBpZCA9Ci0gICAgKCgwIDw9IG4gJiYgbiA8PSBUWVBFX01BWElNVU0gKHBpZF90KQotICAg ICAgJiYgKFRZUEVfTUFYSU1VTSAocGlkX3QpIDwgSU5UTUFYX01BWCB8fCBlcnJubyAhPSBF UkFOR0UpKQotICAgICA/IG4gOiAwKTsKKyAgbiA9IHN0cnRvaW1heCAoZG90ICsgMSwgJmNv bG9uLCAxMCk7CisgIGlmICghIChuIDw9IFRZUEVfTUFYSU1VTSAocGlkX3QpCisJICYmIChU WVBFX01BWElNVU0gKHBpZF90KSA8IElOVE1BWF9NQVggfHwgZXJybm8gIT0gRVJBTkdFKSkp CisgICAgcmV0dXJuIC0xOworICBwaWQgPSBuOwogCi0gIGNvbG9uID0gc3RyY2hyIChkb3Qg KyAxLCAnOicpOwogICAvKiBBZnRlciB0aGUgYDonLCBpZiB0aGVyZSBpcyBvbmUsIGNvbWVz IHRoZSBib290IHRpbWUuICAqLwotICBuID0gMDsKLSAgaWYgKGNvbG9uKQorICBzd2l0Y2gg KCpjb2xvbikKICAgICB7CisgICAgY2FzZSAwOgorICAgICAgbiA9IDA7CisgICAgICBicmVh azsKKworICAgIGNhc2UgJzonOgorICAgICAgaWYgKCEgY19pc2RpZ2l0IChjb2xvblsxXSkp CisJcmV0dXJuIC0xOwogICAgICAgZXJybm8gPSAwOwotICAgICAgbiA9IHN0cnRvaW1heCAo Y29sb24gKyAxLCBOVUxMLCAxMCk7CisgICAgICBuID0gc3RydG9pbWF4IChjb2xvbiArIDEs ICZsZmluZm9fZW5kLCAxMCk7CisgICAgICBpZiAoISAobGZpbmZvX2VuZCA9PSBvd25lci0+ dXNlciArIGxmaW5mb2xlbgorCSAgICAgJiYgbiA8PSBUWVBFX01BWElNVU0gKHRpbWVfdCkK KwkgICAgICYmIChUWVBFX01BWElNVU0gKHRpbWVfdCkgPCBJTlRNQVhfTUFYIHx8IGVycm5v ICE9IEVSQU5HRSkpKQorCXJldHVybiAtMTsKKyAgICAgIGJyZWFrOworCisgICAgZGVmYXVs dDoKKyAgICAgIHJldHVybiAtMTsKICAgICB9Ci0gIG93bmVyLT5ib290X3RpbWUgPQotICAg ICgoMCA8PSBuICYmIG4gPD0gVFlQRV9NQVhJTVVNICh0aW1lX3QpCi0gICAgICAmJiAoVFlQ RV9NQVhJTVVNICh0aW1lX3QpIDwgSU5UTUFYX01BWCB8fCBlcnJubyAhPSBFUkFOR0UpKQot ICAgICA/IG4gOiAwKTsKLQotICAvKiBUaGUgaG9zdCBpcyBldmVyeXRoaW5nIGluIGJldHdl ZW4uICAqLwotICBsZW4gPSBkb3QgLSBhdCAtIDE7Ci0gIG93bmVyLT5ob3N0ID0geG1hbGxv YyAobGVuICsgMSk7Ci0gIG1lbWNweSAob3duZXItPmhvc3QsIGF0ICsgMSwgbGVuKTsKLSAg b3duZXItPmhvc3RbbGVuXSA9IDA7Ci0KLSAgLyogV2UncmUgZG9uZSBsb29raW5nIGF0IHRo ZSBsaW5rIGluZm8uICAqLwotICBVTkdDUFJPOworICBib290X3RpbWUgPSBuOwogCiAgIC8q IE9uIGN1cnJlbnQgaG9zdD8gICovCi0gIGlmIChTVFJJTkdQIChGc3lzdGVtX25hbWUgKCkp Ci0gICAgICAmJiBzdHJjbXAgKG93bmVyLT5ob3N0LCBTU0RBVEEgKEZzeXN0ZW1fbmFtZSAo KSkpID09IDApCisgIGlmIChTVFJJTkdQIChWc3lzdGVtX25hbWUpCisgICAgICAmJiBkb3Qg LSAoYXQgKyAxKSA9PSBTQllURVMgKFZzeXN0ZW1fbmFtZSkKKyAgICAgICYmIG1lbWNtcCAo YXQgKyAxLCBTU0RBVEEgKFZzeXN0ZW1fbmFtZSksIFNCWVRFUyAoVnN5c3RlbV9uYW1lKSkg PT0gMCkKICAgICB7Ci0gICAgICBpZiAob3duZXItPnBpZCA9PSBnZXRwaWQgKCkpCisgICAg ICBpZiAocGlkID09IGdldHBpZCAoKSkKICAgICAgICAgcmV0ID0gMjsgLyogV2Ugb3duIGl0 LiAgKi8KLSAgICAgIGVsc2UgaWYgKG93bmVyLT5waWQgPiAwCi0gICAgICAgICAgICAgICAm JiAoa2lsbCAob3duZXItPnBpZCwgMCkgPj0gMCB8fCBlcnJubyA9PSBFUEVSTSkKLQkgICAg ICAgJiYgKG93bmVyLT5ib290X3RpbWUgPT0gMAotCQkgICB8fCB3aXRoaW5fb25lX3NlY29u ZCAob3duZXItPmJvb3RfdGltZSwgZ2V0X2Jvb3RfdGltZSAoKSkpKQorICAgICAgZWxzZSBp ZiAocGlkID4gMAorICAgICAgICAgICAgICAgJiYgKGtpbGwgKHBpZCwgMCkgPj0gMCB8fCBl cnJubyA9PSBFUEVSTSkKKwkgICAgICAgJiYgKGJvb3RfdGltZSA9PSAwCisJCSAgIHx8IHdp dGhpbl9vbmVfc2Vjb25kIChib290X3RpbWUsIGdldF9ib290X3RpbWUgKCkpKSkKICAgIC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W5mb190eXBlICpjbGFzaGVyLCBjaGFyICpsZm5hbWUpCiB7Ci0g IHdoaWxlICghIGxvY2tfZmlsZV8xIChsZm5hbWUsIDApKQorICBpbnQgZXJyOworICB3aGls ZSAoKGVyciA9IGxvY2tfZmlsZV8xIChsZm5hbWUsIDApKSA9PSBFRVhJU1QpCiAgICAgewot ICAgICAgaW50IGxvY2tlcjsKLQotICAgICAgaWYgKGVycm5vICE9IEVFWElTVCkKLQlyZXR1 cm4gLTE7Ci0KLSAgICAgIGxvY2tlciA9IGN1cnJlbnRfbG9ja19vd25lciAoY2xhc2hlciwg bGZuYW1lKTsKLSAgICAgIGlmIChsb2NrZXIgPT0gMikKLSAgICAgICAgewotICAgICAgICAg IEZSRUVfTE9DS19JTkZPICgqY2xhc2hlcik7Ci0gICAgICAgICAgcmV0dXJuIDA7ICAgLyog V2Ugb3Vyc2VsdmVzIGxvY2tlZCBpdC4gICovCi0gICAgICAgIH0KLSAgICAgIGVsc2UgaWYg KGxvY2tlciA9PSAxKQotICAgICAgICByZXR1cm4gMTsgIC8qIFNvbWVvbmUgZWxzZSBoYXMg aXQuICAqLwotICAgICAgZWxzZSBpZiAobG9ja2VyID09IC0xKQotCXJldHVybiAtMTsgICAv KiBjdXJyZW50X2xvY2tfb3duZXIgcmV0dXJuZWQgc3RyYW5nZSBlcnJvci4gICovCisgICAg ICBzd2l0Y2ggKGN1cnJlbnRfbG9ja19vd25lciAoY2xhc2hlciwgbGZuYW1lKSkKKwl7CisJ Y2FzZSAyOgorCSAgcmV0dXJuIDA7ICAgLyogV2Ugb3Vyc2VsdmVzIGxvY2tlZCBpdC4gICov CisJY2FzZSAxOgorCSAgcmV0dXJuIDE7ICAgLyogU29tZW9uZSBlbHNlIGhhcyBpdC4gICov CisJY2FzZSAtMToKKwkgIHJldHVybiAtMTsgIC8qIGN1cnJlbnRfbG9ja19vd25lciByZXR1 cm5lZCBzdHJhbmdlIGVycm9yLiAgKi8KKwl9CiAKICAgICAgIC8qIFdlIG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IChpbnRlcm4gKCJhc2stdXNlci1hYm91dC1sb2NrIiksIGZuLAorCQkgICAg ICBidWlsZF9zdHJpbmcgKGxvY2tfaW5mby51c2VyKSk7CiAgICAgICAvKiBUYWtlIHRoZSBs b2NrIGlmIHRoZSB1c2VyIHNhaWQgc28uICAqLwogICAgICAgaWYgKCFOSUxQIChhdHRhY2sp KQogCWxvY2tfZmlsZV8xIChsZm5hbWUsIDEpOwpAQCAtNzYwLDEwICs3OTUsNyBAQAogICBl bHNlIGlmIChvd25lciA9PSAyKQogICAgIHJldCA9IFF0OwogICBlbHNlCi0gICAgcmV0ID0g YnVpbGRfc3RyaW5nIChsb2NrZXIudXNlcik7Ci0KLSAgaWYgKG93bmVyID4gMCkKLSAgICBG UkVFX0xPQ0tfSU5GTyAobG9ja2VyKTsKKyAgICByZXQgPSBtYWtlX3N0cmluZyAobG9ja2Vy LnVzZXIsIGxvY2tlci5hdCAtIGxvY2tlci51c2VyKTsKIAogICBTQUZFX0ZSRUUgKCk7CiAg IHJldHVybiByZXQ7Cgo= --------------050900080305030900000207--