From: anorland AT hem2 DOT passagen DOT se (Anders Norlander)
Subject: Re: B20, Win95: cp destroys file
18 Nov 1998 13:49:20 -0800
Message-ID: <3652A205.404EDF05.cygnus.gnu-win32@hem2.passagen.se>
References: <9811160532 DOT AA24319 AT modi DOT xraylith DOT wisc DOT edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Mumit Khan <khan AT xraylith DOT wisc DOT edu>
Cc: earnie_boyd AT yahoo DOT com, "Henry S. Warren, Jr." <hank AT watson DOT ibm DOT com>,
        gnu-win32 AT cygnus DOT com

Mumit Khan wrote:
> 
> Earnie Boyd <earnie_boyd AT yahoo DOT com> writes:
> > ---"Henry S. Warren, Jr." <hank AT watson DOT ibm DOT com> wrote:
> > >
> > > If you copy, using cp, a file to itself, and the target and source
> > files
> > > differ in capitalization, then the content of the file is wiped out;
> > it
> > > becomes a file of 0-length.  Example: "cp hilbert.c hilbert.C" trashes
> > > file hilbert.c.
> > >    The Win95 "copy" command gives the error message "File cannot be
> > > copied onto itself" in this situation (much preferable)
> >
> > Hmm.  It used to do it that way in b19.  Is it possible that inode or
> > stat routine has become buggy?
> 
> Are you by any chance doing this on a SMB mounted filesystem? I remember
> playing with this a while back, and it worked on FAT and NTFS, but not
> on SAMBA disk (didn't try SMB disks from non-SAMBA server, such as NT).
> 
> I believe that the problem is in MoveFileEx (WIN API), which doesn't do
> the right thing. However, the rename in MSVC runtime does somehow do
> it correctly on all filesystems, so it's doing something more than using
> MoveFileEx. (fyi, mv uses the rename runtime routine in winsup that in
> turn uses MoveFileEx to do the actual renaming).

Isn't this the same as the win32 `cat foo >foo' problem?
I find it hard to believe that this is related to a bug in
MoveFileEx, since MoveFileEx really just calls the driver for
the file-system in question (I would imagine) to perform the
actual disk/filesystem operations. At least on my FAT system,
running b19, cp destroys the file if it is the same file but
the names differ in capitalization.

Anders Norlander
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".