X-Spam-Check-By: sourceware.org From: "Dave Korn" To: Subject: RE: Data streams being treated as files in Cygwin Date: Thu, 11 May 2006 15:40:39 +0100 Message-ID: <003501c67508$df2a7e50$a501a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <721B8481D73DE047B62D7AB3750F656006B5A8@CORPUSMX30A.corp.emc.com> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: 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 On 11 May 2006 15:17, Vishwanath_Karthik AT emc wrote: > There seems to a problem on how the data streams are handled in > Cygwin. Cygwin is treating a data stream as a file which should not > be the case. Cygwin's file handling relies on the underlying facilities of the Windows O/S, for the most part. > Following are the steps followed to create and access a data stream > using cygwin shell in Windows environment. > > Sh-3.1$ echo "data1" > test00 > Sh-3.1$ echo "data1" > test00:stream > > Now test00 is a file and test00:stream is a data stream associated > with the file test00 It's not 'associated' with the file test00. It is *a part of* the file test00. > When we do an "ls" at this path we are able to see only test00 file > and not the stream test00:stream -> this functionality is OK as streams > cannot be locked and also it is not a file Wrong: a stream is a file, or to be precise it is a subset of the content of a file. > In one of the perl scripts when we did a file test for both "test00" > and "test00:stream" ,both succeeded even though "test00:stream" is not a > file Actually, test00:stream and test00 are in fact one and the same file, and hence they both exist. > The network traces of the shell command "test -f test00:stream" > showed that Cygwin opens the file "test00:stream" instead of sending a > server reply "NO file found" The file does exist and hence is found. > So a patch has to be applied to resolve this issue. Can you please > provide us with a patch so that the data streams are handled as expected . The required patch should be applied to your understanding of ADS, not to cygwin! Permit me to demonstrate: ------------------------------------------------------------------ dk AT rainbow /test/stream> ls -la total 0 drwxr-xr-x+ 2 dk Domain Users 0 May 11 15:32 . drwx------+ 33 dk Domain Users 0 May 11 15:32 .. dk AT rainbow /test/stream> echo "data1" > test00:stream dk AT rainbow /test/stream> ls -la total 0 drwxr-xr-x+ 2 dk Domain Users 0 May 11 15:32 . drwx------+ 33 dk Domain Users 0 May 11 15:32 .. -rw-r--r-- 1 dk Domain Users 0 May 11 15:32 test00 dk AT rainbow /test/stream> ------------------------------------------------------------------ Note that I only issued commands to write to a stream, but the file had to exist for the stream to exist. Note also that you can test for the existence of streams: it doesn't just match every stream when the file itself exists, the stream has to have been created, and that you can create and delete streams and cygwin correctly reports their existence or nonexistence: ------------------------------------------------------------------ dk AT rainbow /test/stream> if [ -f test00 ] ; then echo found ; fi found dk AT rainbow /test/stream> if [ -f test00:stream ] ; then echo found ; fi found dk AT rainbow /test/stream> if [ -f test00:garbagegarbage ] ; then echo found ; fi dk AT rainbow /test/stream> echo "data1" > test00:garbagegarbage dk AT rainbow /test/stream> if [ -f test00:stream ] ; then echo found ; fi found dk AT rainbow /test/stream> if [ -f test00:garbagegarbage ] ; then echo found ; fi found dk AT rainbow /test/stream> rm test00:stream dk AT rainbow /test/stream> if [ -f test00:stream ] ; then echo found ; fi dk AT rainbow /test/stream> if [ -f test00:garbagegarbage ] ; then echo found ; fi found dk AT rainbow /test/stream> ------------------------------------------------------------------ If you really want to do a file-exists test that claims ADS streams do not exist, roll your own code that looks for a colon in the filename and returns 'not found' regardless. cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/