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 Thu, 11 May 2006, Dave Korn wrote:

> 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.

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@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>
> ------------------------------------------------------------------

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...


$ 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.
      |\      _,,,---,,_ |
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:
Problem reports:

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