This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Data streams being treated as files in Cygwin


On 11 May 2006 15:17, Vishwanath_Karthik@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@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@rainbow /test/stream> echo "data1" > test00:stream
dk@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@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@rainbow /test/stream> if [ -f test00 ] ; then echo found ; fi
found
dk@rainbow /test/stream> if [ -f test00:stream ] ; then echo found ; fi
found
dk@rainbow /test/stream> if [ -f test00:garbagegarbage ] ; then echo found ;
fi

dk@rainbow /test/stream> echo "data1" > test00:garbagegarbage
dk@rainbow /test/stream> if [ -f test00:stream ] ; then echo found ; fi
found
dk@rainbow /test/stream> if [ -f test00:garbagegarbage ] ; then echo found ;
fi
found
dk@rainbow /test/stream> rm test00:stream
dk@rainbow /test/stream> if [ -f test00:stream ] ; then echo found ; fi
dk@rainbow /test/stream> if [ -f test00:garbagegarbage ] ; then echo found ;
fi
found
dk@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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]