Re[2]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

Hello Robert,

Friday, May 03, 2002, 1:58:28 AM, you wrote:

 -Original Message-
 From: Corinna Vinschen [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, May 03, 2002 1:44 AM
 To: CygWin Apps; Cygwin-Xfree
 Subject: Re: setup.exe and inuse files for X
 
 
 On Wed, May 01, 2002 at 04:58:36PM +1000, Robert Collins wrote:
  I think I've got a handle on this... looks like read only 
 (-r--r--r--) 
  files don't delete properly, so setup fails to overwrite them.
  
  Patches gratefully accepted, it's going in the TODO for now.
 
 I recall having sent a patch for this a few months ago to the 
 cygwin-apps list...

RC Yes. And I had implemented similar code. (Including the
RC SetFileAttributes call).

RC I'm not sure why it is still failing to do what it should. 

Check this out:

Quoted from the description of DeleteFile in the MDSN library:
To delete or rename a file, you must have either delete permission on the file
or delete child permission in the parent directory. If you set up a directory with
all access except delete and delete child and the ACLs of new files are inherited,
then you should be able to create a file without being able to delete it. However,
you can then create a file, and you will get all the access you request on the handle
returned to you at the time you create the file. If you requested delete permission
at the time you created the file, you could delete or rename the file with that handle
but not with any other.

ACL of a mode 400 file from my home directory:
C:\cygwin\home\paveltz\test.c MORDOR\paveltz:(accesso speciale:)
 READ_CONTROL
 WRITE_DAC
 WRITE_OWNER
 SYNCHRONIZE
 FILE_GENERIC_READ
 FILE_READ_DATA
 FILE_READ_EA
 FILE_WRITE_EA
 FILE_READ_ATTRIBUTES
 FILE_WRITE_ATTRIBUTES
 
  MORDOR\Nessuno:(accesso speciale:)
 READ_CONTROL
 FILE_READ_EA
 FILE_READ_ATTRIBUTES
 
  Everyone:(accesso speciale:)
   READ_CONTROL
   FILE_READ_EA
   FILE_READ_ATTRIBUTES

Obviously the DELETE permission is missing. You call SetFileAttributes
with ~FILE_ATTRIBUTE_READONLY which shoul enable the file for reading
but it does not - I suppose this is why:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/filesio_6c8i.asp

Note that it is said:
dwFileAttributes
Specifies FAT-style attribute information for the file or directory.

But if we're on NTFS there is no joy :( I've tried a simple test with
SetFileAttributes and ~FILE_ATTRIBUTE_READONLY and it doesnt affect
the file at all.

Ok here is how to fix this issues I've just tried it on my XP Home and
it worked fine.

HANDLE h = CreateFile(test.c,
  DELETE,
  0, // We want it all :)
  NULL,
  OPEN_EXISTING,
  FILE_ATTRIBUTE_READONLY /*to be compatible*/
  | FILE_FLAG_DELETE_ON_CLOSE, NULL);
CloseHandle (h);




Re[3]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

[snip]

PT Obviously the DELETE permission is missing. You call SetFileAttributes
PT with ~FILE_ATTRIBUTE_READONLY which shoul enable the file for reading
|
deleting ---+
PT but it does not - I suppose this is why:

[snip]




RE: Re[2]: setup.exe and inuse files for X

2002-05-16 Thread Robert Collins

Does this work on FAT too?

Rob

 -Original Message-
 From: Pavel Tsekov [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, May 16, 2002 6:33 PM

Ok here is how to fix this issues I've just tried it on my XP Home and
it worked fine.

HANDLE h = CreateFile(test.c,
  DELETE,
  0, // We want it all :)
  NULL,
  OPEN_EXISTING,
  FILE_ATTRIBUTE_READONLY /*to be compatible*/
  | FILE_FLAG_DELETE_ON_CLOSE, NULL);
CloseHandle (h);




Re[4]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

Hello Robert,

Thursday, May 16, 2002, 10:59:27 AM, you wrote:

RC Does this work on FAT too?

I don't know - its not clear from the documentation. Someone has to
test it on FAT. However this combined with an an call to
SetFileAttributes () before it should be sufficient.

Btw the snippet below is wrong - FILE_ATTRIBUTES_READONLY should be
removed from the call. I type too fast :(

 -Original Message-
 From: Pavel Tsekov [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, May 16, 2002 6:33 PM

RC Ok here is how to fix this issues I've just tried it on my XP Home and
RC it worked fine.

RC HANDLE h = CreateFile(test.c,
RC   DELETE,
RC   0, // We want it all :)
RC   NULL,
RC   OPEN_EXISTING,
RC   FILE_ATTRIBUTE_READONLY /*to be compatible*/
 |
Bah, this here is an error --+
RC   | FILE_FLAG_DELETE_ON_CLOSE, NULL);
RC CloseHandle (h);




Re[5]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

Ok, I've tested it on my WinXP Home on NTFS, FAT and FAT32. The
following snippet removes the file no matter the filesystem
(the Get/SetFileAttributes is required for FAT/FAT32 only):

HANDLE hFile;
DWORD dwAttr = GetFileAttributes (test.dat);
SetFileAttributes (test.dat, dwAttr  ~FILE_ATTRIBUTE_READONLY);
hFile = CreateFile (test.dat, DELETE, 0, NULL, OPEN_EXISTING,
  FILE_FLAG_DELETE_ON_CLOSE, NULL);
CloseHandle (hFile);

RC Does this work on FAT too?

PT I don't know - its not clear from the documentation. Someone has to
PT test it on FAT. However this combined with an an call to
PT SetFileAttributes () before it should be sufficient.




RE: Re[5]: setup.exe and inuse files for X

2002-05-16 Thread Robert Collins

One thing I'm not clear on - are both calls -required-?

 -Original Message-
 From: Pavel Tsekov [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, May 16, 2002 8:52 PM
 To: Robert Collins
 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re[5]: setup.exe and inuse files for X
 
 
 Ok, I've tested it on my WinXP Home on NTFS, FAT and FAT32. 
 The following snippet removes the file no matter the 
 filesystem (the Get/SetFileAttributes is required for FAT/FAT32 only):
 
 HANDLE hFile;
 DWORD dwAttr = GetFileAttributes (test.dat);
 SetFileAttributes (test.dat, dwAttr  ~FILE_ATTRIBUTE_READONLY);
 hFile = CreateFile (test.dat, DELETE, 0, NULL, OPEN_EXISTING,
   FILE_FLAG_DELETE_ON_CLOSE, NULL);
 CloseHandle (hFile);
 
 RC Does this work on FAT too?
 
 PT I don't know - its not clear from the documentation. 
 Someone has to 
 PT test it on FAT. However this combined with an an call to 
 PT SetFileAttributes () before it should be sufficient.
 
 



RE: Re[5]: setup.exe and inuse files for X

2002-05-16 Thread Robert Collins

Oh, and can you please provide as a patch+ changelog?   

Cheers,
Rob

 -Original Message-
 From: Pavel Tsekov [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, May 16, 2002 8:52 PM
 To: Robert Collins
 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re[5]: setup.exe and inuse files for X
 
 
 Ok, I've tested it on my WinXP Home on NTFS, FAT and FAT32. 
 The following snippet removes the file no matter the 
 filesystem (the Get/SetFileAttributes is required for FAT/FAT32 only):
 
 HANDLE hFile;
 DWORD dwAttr = GetFileAttributes (test.dat);
 SetFileAttributes (test.dat, dwAttr  ~FILE_ATTRIBUTE_READONLY);
 hFile = CreateFile (test.dat, DELETE, 0, NULL, OPEN_EXISTING,
   FILE_FLAG_DELETE_ON_CLOSE, NULL);
 CloseHandle (hFile);
 
 RC Does this work on FAT too?
 
 PT I don't know - its not clear from the documentation. 
 Someone has to 
 PT test it on FAT. However this combined with an an call to 
 PT SetFileAttributes () before it should be sufficient.
 
 



Re[7]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

No! Because I'm stupid... There is something else here. I got fooled.

RC Oh, and can you please provide as a patch+ changelog?   




Installation of X with setup.exe was Re[8]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

Ok, yesterday I've installed X with setup.exe and ended up with a lot
of filename.new files under /usr/X11R6/ and some other dirs. I took
a look at setup.log and saw this:

2002/05/15 11:26:13 Failed to open cygfile:///usr/X11R6/lib/X11/xman.help for wr
iting.

.. and many others like this. Obviosly I wasn't looking very sharp at
the log file since I choose a wrong direction when looking how to fix
the problem. Today after some bunch of messages I sent to the list, I
decided to grep the setup source for the message printed in the log
file. It appears only in archive.cc:

io_stream::remove (destfilename);
io_stream *tmp = io_stream::open (destfilename, wb);
if (!tmp)
{
  log (LOG_TIMESTAMP, String (Failed to open ) + destfilename +  for writ
ing.);
  return 1;
}

Ok what's wrong here is that io_stream_cygfile::remove doesn't do the
SetFileAttributes() trick when calling DeleteFile ().

I was looking in the wrong place, package_meta.cc in
packagemeta::uninstall. However these  code was never executed,
because X was never installed on my PC with setup.exe, but
with the old method for installing X.

Sorry, for spamming the mail list :(

Thursday, May 16, 2002, 1:45:12 PM, you wrote:

PT No! Because I'm stupid... There is something else here. I got fooled.

RC Oh, and can you please provide as a patch+ changelog?   




RE: Installation of X with setup.exe was Re[8]: setup.exe and inuse files for X

2002-05-16 Thread Robert Collins



 -Original Message-
 From: Pavel Tsekov [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, May 16, 2002 10:07 PM

 Sorry, for spamming the mail list :(

It wasn't spam. I think that the NTFS changes may well be needed
anyway... or are you saying that just tweaking the cygfile remove to
have the SetFileAttributes thing is enough?

As for the X problem, yes that would explain it, as setup doesn't know
to uninstall. 

Rob



Re[2]: Installation of X with setup.exe was Re[8]: setup.exe and inuse files for X

2002-05-16 Thread Pavel Tsekov

Hello Robert,

Thursday, May 16, 2002, 2:11:37 PM, you wrote:

 -Original Message-
 From: Pavel Tsekov [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, May 16, 2002 10:07 PM

 Sorry, for spamming the mail list :(

RC It wasn't spam. I think that the NTFS changes may well be needed
RC anyway... or are you saying that just tweaking the cygfile remove to
RC have the SetFileAttributes thing is enough?

Well.. I was acting encumbered with a wrong assumption and a result
from and incorrect testcase :(. When you asked me if it is required to use
both calls I've run some more tests while replying and saw that DeleteFile
works just ok with mode 0400 files when FILE_ATTRIBUTE_READONLY is unset.
On the other hand the method I've suggested doesn't work with
FILE_ATTRIBUTE_READONLY set i.e. no difference between DeleteFile and
CreateFile/FILE_FLAG_DELETE_ON_CLOSE. These mails should be ignored!

RC As for the X problem, yes that would explain it, as setup doesn't know
RC to uninstall. 




Re: setup.exe and inuse files for X

2002-05-02 Thread Corinna Vinschen

On Wed, May 01, 2002 at 04:58:36PM +1000, Robert Collins wrote:
 I think I've got a handle on this... looks like read only (-r--r--r--)
 files don't delete properly, so setup fails to overwrite them.
 
 Patches gratefully accepted, it's going in the TODO for now.

I recall having sent a patch for this a few months ago to the
cygwin-apps list...

Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Developermailto:[EMAIL PROTECTED]
Red Hat, Inc.



RE: setup.exe and inuse files for X

2002-05-02 Thread Robert Collins



 -Original Message-
 From: Corinna Vinschen [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, May 03, 2002 1:44 AM
 To: CygWin Apps; Cygwin-Xfree
 Subject: Re: setup.exe and inuse files for X
 
 
 On Wed, May 01, 2002 at 04:58:36PM +1000, Robert Collins wrote:
  I think I've got a handle on this... looks like read only 
 (-r--r--r--) 
  files don't delete properly, so setup fails to overwrite them.
  
  Patches gratefully accepted, it's going in the TODO for now.
 
 I recall having sent a patch for this a few months ago to the 
 cygwin-apps list...

Yes. And I had implemented similar code. (Including the
SetFileAttributes call).

I'm not sure why it is still failing to do what it should. 

Rob



setup.exe and inuse files for X

2002-05-01 Thread Robert Collins

I think I've got a handle on this... looks like read only (-r--r--r--)
files don't delete properly, so setup fails to overwrite them.

Patches gratefully accepted, it's going in the TODO for now.

Rob