X-Spam-Check-By: sourceware.org Date: Thu, 11 May 2006 11:00:17 -0400 (EDT) From: Igor Peshansky Reply-To: cygwin AT cygwin DOT com To: Dave Korn cc: cygwin AT cygwin DOT com Subject: RE: Data streams being treated as files in Cygwin In-Reply-To: <003501c67508$df2a7e50$a501a8c0@CAM.ARTIMI.COM> Message-ID: References: <003501c67508$df2a7e50$a501a8c0 AT CAM DOT ARTIMI DOT COM> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Thu, 11 May 2006, Dave Korn wrote: > 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. Yes, and that leads to some funny behavior -- see below. > > 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. As can be easily seen by looking at the inode number, which is the same for test00 and test00:stream. > 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> > ------------------------------------------------------------------ Interestingly enough: $ echo "BLAH" > a:b bash: a:b: No such file or directory > 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... However: $ rm test00 $ ls -l test00:stream test00:garbagegarbage test00 ls: test00:stream: No such file or directory ls: test00:garbagegarbage: No such file or directory ls: test00: No such file or directory > 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. Yep, and when demanding that a patch be applied, it usually helps A LOT to actually provide the patch that you want applied. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com ZZZzz /,`.-'`' -. ;-;;,_ Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte." "But no -- you are no fool; you call yourself a fool, there's proof enough in that!" -- Rostand, "Cyrano de Bergerac" -- 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/