X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org X-Authority-Analysis: v=1.0 c=1 a=xe8BsctaAAAA:8 a=XCyGPjIIUWCRSc9R0vMA:9 a=2h9nqzfKJBSzsWUpgE_RXrXdV14A:4 a=eDFNAWYWrCwA:10 a=rPt6xJ-oxjAA:10 Message-ID: <490B0243.2040504@byu.net> Date: Fri, 31 Oct 2008 07:04:03 -0600 From: Eric Blake User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: canonicalize_file_name References: <001b01c93a65$97134460$4001a8c0 AT mycomputer> <49099F53 DOT 9060105 AT byu DOT net> <20081030121050 DOT GL6478 AT calimero DOT vinschen DOT de> <007f01c93abc$68806f40$4001a8c0 AT mycomputer> <20081031082454 DOT GB12818 AT calimero DOT vinschen DOT de> <20081031111722 DOT GA14239 AT calimero DOT vinschen DOT de> In-Reply-To: <20081031111722.GA14239@calimero.vinschen.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Corinna Vinschen on 10/31/2008 5:17 AM: >> The safest course would be to declare or >> preallocate a buffer of size PATH_MAX and pass it to realpath(); that >> should work with any POSIX-compliant C library. > > Neverthless this is good advice if portability is an issue. POSIX 200x (which is on track to be approved later this year) has modified the requirements on realpath() that NULL be a universally accepted argument. Not all vendors comply with this yet, but at some point, it will no longer be a GNU extension, but a POSIX-mandated requirement that realpath() be able to malloc its result. This is part of the overall paradigm change in POSIX 200x that recognizes that it is legal to have paths longer than PATH_MAX (and that is certainly the case with cygwin 1.7.0); as well as a thread-safety issue (in between the time you call pathconf() and realpath(), some other process may have renamed one of the symlinks on the path you are changing, such that your pathconf() results are no longer valid for the file you end up resolving). In fact, the rationale given in POSIX for this change is: "Since realpath( ) has no length argument, if {PATH_MAX} is not defined as a constant in , applications have no way of determining how large a buffer they need to allocate for it to be safe to pass to realpath( ). A {PATH_MAX} value obtained from a prior pathconf( ) call is out-of-date by the time realpath( ) is called. Hence the only reliable way to use realpath( ) when {PATH_MAX} is not defined in is to pass a null pointer for resolved_name so that realpath( ) will allocate a buffer of the necessary size." - -- Don't work too hard, make some time for fun as well! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkkLAkMACgkQ84KuGfSFAYCQ0ACaAtH7nJGaibJPWLltx3LXer2O WHwAoKb35S6tgp80AndvBXV0n3WAZApC =3XqJ -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/