public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: tar and open files
@ 2004-02-20 23:36 DePriest, Jason R.
  2004-02-20 23:55 ` Brian Dessent
  0 siblings, 1 reply; 9+ messages in thread
From: DePriest, Jason R. @ 2004-02-20 23:36 UTC (permalink / raw)
  To: cygwin

For a DLL, does just unregistering the DLL do what you need?  I mean,
running 'regsvr32 /u <dll>', put new file in place, run 'regsvr32
<dll>'?

-Jason

> -----Original Message-----
> From: cygwin-owner at cygwin dot com 
> [mailto: cygwin-owner at cygwin dot com] On Behalf Of Igor
Pechtchanski
> Sent: Friday, February 20, 2004 5:02 PM
> To: Steven Hartland
> Cc: cygwin at cygwin dot com
> Subject: Re: tar and open files
> 
> 
> On Fri, 20 Feb 2004, Steven Hartland wrote:
> 
> > Does anyone know of a way of getting round the file locking 
> in win32 /
> > cygwin so that in use files e.g. dll's can be replaced and 
> next time the
> > app restarts they are picked up?
> >     Steve
> 
> Setup.exe uses the Windows "replace-on-reboot" feature for this.  If
> you're interested in how this works, see the setup.exe 
> sources or MSDN.
> AFAIK, there's no other way to do a delayed replace of in-use files on
> Windows, but I've been known to err...
> 	Igor
> -- 
> 				http://cs.nyu.edu/~pechtcha/
>       |\      _,,,---,,_		pechtcha at cs dot nyu dot edu
> ZZZzz /,`.-'`'    -.  ;-;;,_		igor at watson dot ibm dot com
>      |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
>     '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!
> 
> "I have since come to realize that being between your mentor 
> and his route
> to the bathroom is a major career booster."  -- Patrick Naughton
> 
> 


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-20 23:36 tar and open files DePriest, Jason R.
@ 2004-02-20 23:55 ` Brian Dessent
  2004-02-21  0:10   ` Christopher Faylor
  2004-02-21  0:33   ` Steven Hartland
  0 siblings, 2 replies; 9+ messages in thread
From: Brian Dessent @ 2004-02-20 23:55 UTC (permalink / raw)
  To: cygwin

"DePriest, Jason R." wrote:
> 
> For a DLL, does just unregistering the DLL do what you need?  I mean,
> running 'regsvr32 /u <dll>', put new file in place, run 'regsvr32
> <dll>'?

No.  The replacement only occurs at boot-time.

I don't know if this is quite off-topic or not but I wrote the following
perl script which reads the list of Pending File Rename Operations (to
occur at next boot time) and outputs a shell script to perform them. 
Example of its use would be:

- Run setup.exe
- try to upgrade some in-use thing
- setup.exe tells you that you need to reboot because you forget to stop
all cygwin processes
- you stop all cygwin processes
- run this script, which outputs a script to perform the pending renames
without having to reboot, assuming those files are now not open
- delete the PendingFileRenameOperations registry key with regedit or
/proc/registry
- restart processes without a reboot

It requires libwin32, but you could probably modify it to use
/proc/registry as well.  Note also that it wouldn't work without
modification for replacing cygwin1.dll since it spits out a set of 'mv'
commands, and mv requires cygwin1.dll.  It's also overly complicated
since it cygwin-izes the paths.  It would have been easier to spit out
dos commands probably.  Hindsight...

Note that this does not do any magic!  It's only for the case where you
try to install or upgrade something where you forgot to stop it first. 
It won't let you magically replace inuse files, it's only for the case
where you can stop the process, but don't feel like rebooting just to
rename some files.

There's no error checking, use at your own risk, blah blah blah.

#!/usr/bin/perl -w

use Win32::TieRegistry;

my $pr =
$Registry->{'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\PendingFileRenameOperations'};

my @list = split('\0', $pr);

print "# ", join("\n# ", @list), "\n";

while (@list) {
  my $a = shift @list;
  my $b = shift @list;
  
  if ($b) {
    print "mv -f " . fix($a) . " " . fix($b) . "\n";
  } else {
    print "rm " . fix($a) . "\n";
  }
}
        
sub fix
{
  my $in = shift;
  
  $in =~ s%^\!?\\\?\?\\%%;
  my $foo = quotemeta($in);
  chomp (my $bar = `cygpath -u $foo`);
  return "\'$bar\'";
}

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-20 23:55 ` Brian Dessent
@ 2004-02-21  0:10   ` Christopher Faylor
  2004-02-21  0:33   ` Steven Hartland
  1 sibling, 0 replies; 9+ messages in thread
From: Christopher Faylor @ 2004-02-21  0:10 UTC (permalink / raw)
  To: cygwin

On Fri, Feb 20, 2004 at 03:45:14PM -0800, Brian Dessent wrote:
>"DePriest, Jason R." wrote:
>> 
>> For a DLL, does just unregistering the DLL do what you need?  I mean,
>> running 'regsvr32 /u <dll>', put new file in place, run 'regsvr32
>> <dll>'?
>
>No.  The replacement only occurs at boot-time.
>
>I don't know if this is quite off-topic or not but I wrote the following
>perl script which reads the list of Pending File Rename Operations (to
>occur at next boot time) and outputs a shell script to perform them. 

If it is off-topic, I'll grant it a special dispensation for showing an
interesting technique.

I had no idea you could do this.

Thanks for sharing it with us.  I think I can use this.

cgf

>
>#!/usr/bin/perl -w
>
>use Win32::TieRegistry;
>
>my $pr =
>$Registry->{'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
>Manager\PendingFileRenameOperations'};
>
>my @list = split('\0', $pr);
>
>print "# ", join("\n# ", @list), "\n";
>
>while (@list) {
>  my $a = shift @list;
>  my $b = shift @list;
>  
>  if ($b) {
>    print "mv -f " . fix($a) . " " . fix($b) . "\n";
>  } else {
>    print "rm " . fix($a) . "\n";
>  }
>}
>        
>sub fix
>{
>  my $in = shift;
>  
>  $in =~ s%^\!?\\\?\?\\%%;
>  my $foo = quotemeta($in);
>  chomp (my $bar = `cygpath -u $foo`);
>  return "\'$bar\'";
>}
>
>--
>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/

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-20 23:55 ` Brian Dessent
  2004-02-21  0:10   ` Christopher Faylor
@ 2004-02-21  0:33   ` Steven Hartland
  2004-02-21  2:49     ` Larry Hall
  1 sibling, 1 reply; 9+ messages in thread
From: Steven Hartland @ 2004-02-21  0:33 UTC (permalink / raw)
  To: cygwin

That's a cool idea but its not an install so no pending files :(

I was toying with the idea of amending tar for cygwin so that
it could move the offending files to a specific dir or /var/tmp
by default when encountering such a file. All the times I've
tried this its still possible to move the file even though its
locked open. Delete fails otherwise --unlink would work
Actually now I just said it could alter --unlink to do a move
if the delete failed and that would also fix and would be
a neater solution. What do people think?

    Steve 

----- Original Message ----- 
From: "Brian Dessent" <brian@dessent.net>
To: <cygwin@cygwin.com>
Sent: Friday, February 20, 2004 11:45 PM
Subject: Re: tar and open files


> "DePriest, Jason R." wrote:
> > 
> > For a DLL, does just unregistering the DLL do what you need?  I mean,
> > running 'regsvr32 /u <dll>', put new file in place, run 'regsvr32
> > <dll>'?
> 
> No.  The replacement only occurs at boot-time.
> 
> I don't know if this is quite off-topic or not but I wrote the following
> perl script which reads the list of Pending File Rename Operations (to
> occur at next boot time) and outputs a shell script to perform them. 

================================================
This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 

In the event of misdirection, illegible or incomplete transmission please telephone (023) 8024 3137
or return the E.mail to postmaster@multiplay.co.uk.



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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-21  0:33   ` Steven Hartland
@ 2004-02-21  2:49     ` Larry Hall
  2004-02-21  3:17       ` Steven Hartland
  0 siblings, 1 reply; 9+ messages in thread
From: Larry Hall @ 2004-02-21  2:49 UTC (permalink / raw)
  To: Steven Hartland, cygwin

At 07:25 PM 2/20/2004, Steven Hartland you wrote:
>That's a cool idea but its not an install so no pending files :(
>
>I was toying with the idea of amending tar for cygwin so that
>it could move the offending files to a specific dir or /var/tmp
>by default when encountering such a file. All the times I've
>tried this its still possible to move the file even though its
>locked open. Delete fails otherwise --unlink would work
>Actually now I just said it could alter --unlink to do a move
>if the delete failed and that would also fix and would be
>a neater solution. What do people think?


If it's just delaying the problem, I'm not sure this really helps.
What happens when you tar again?  What happens to the "thing" that's
locked the file?  How do you get it to "update" to the new one.  If
this doesn't just push the puck down the ice, I think it's a great 
idea. 


--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-21  2:49     ` Larry Hall
@ 2004-02-21  3:17       ` Steven Hartland
  2004-02-21  4:46         ` Larry Hall
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Hartland @ 2004-02-21  3:17 UTC (permalink / raw)
  To: Cygwin List

----- Original Message ----- 
From: "Larry Hall" 
> At 07:25 PM 2/20/2004, Steven Hartland you wrote:
> >That's a cool idea but its not an install so no pending files :(
> >
> >I was toying with the idea of amending tar for cygwin so that
> >it could move the offending files to a specific dir or /var/tmp
> >by default when encountering such a file. All the times I've
> >tried this its still possible to move the file even though its
> >locked open. Delete fails otherwise --unlink would work
> >Actually now I just said it could alter --unlink to do a move
> >if the delete failed and that would also fix and would be
> >a neater solution. What do people think?
> 
> 
> If it's just delaying the problem, I'm not sure this really helps.
> What happens when you tar again?  What happens to the "thing" that's
> locked the file?  How do you get it to "update" to the new one.  If
> this doesn't just push the puck down the ice, I think it's a great 
> idea. 

In the situation I have here its updating an app where we are
not bothered if it doesnt get updated till the user restarts the
app. The thing that's locked the file will continue to run with
the old version without issue, only when it unlocks and
subsequently reopens ( e.g. in a restart ) will it pick the new
file up. The only issue I see is the remaining files after move
one hack for this may be to manually move them to the
recycle bin if that's possible? Duplicate names in the
destination could be easily be checked for so that's not
an issue. If recycle bin isn't an option then the system temp
dir with a suitable filename might be a way to go unless
there's is a FS level delete on close within win32?

    Steve

================================================
This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 

In the event of misdirection, illegible or incomplete transmission please telephone (023) 8024 3137
or return the E.mail to postmaster@multiplay.co.uk.



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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-21  3:17       ` Steven Hartland
@ 2004-02-21  4:46         ` Larry Hall
  0 siblings, 0 replies; 9+ messages in thread
From: Larry Hall @ 2004-02-21  4:46 UTC (permalink / raw)
  To: Steven Hartland, Cygwin List

At 10:10 PM 2/20/2004, Steven Hartland you wrote:
>----- Original Message ----- 
>From: "Larry Hall" 
>> At 07:25 PM 2/20/2004, Steven Hartland you wrote:
>> >That's a cool idea but its not an install so no pending files :(
>> >
>> >I was toying with the idea of amending tar for cygwin so that
>> >it could move the offending files to a specific dir or /var/tmp
>> >by default when encountering such a file. All the times I've
>> >tried this its still possible to move the file even though its
>> >locked open. Delete fails otherwise --unlink would work
>> >Actually now I just said it could alter --unlink to do a move
>> >if the delete failed and that would also fix and would be
>> >a neater solution. What do people think?
>> 
>> 
>> If it's just delaying the problem, I'm not sure this really helps.
>> What happens when you tar again?  What happens to the "thing" that's
>> locked the file?  How do you get it to "update" to the new one.  If
>> this doesn't just push the puck down the ice, I think it's a great 
>> idea. 
>
>In the situation I have here its updating an app where we are
>not bothered if it doesnt get updated till the user restarts the
>app. The thing that's locked the file will continue to run with
>the old version without issue, only when it unlocks and
>subsequently reopens ( e.g. in a restart ) will it pick the new
>file up. The only issue I see is the remaining files after move
>one hack for this may be to manually move them to the
>recycle bin if that's possible? Duplicate names in the
>destination could be easily be checked for so that's not
>an issue. If recycle bin isn't an option then the system temp
>dir with a suitable filename might be a way to go unless
>there's is a FS level delete on close within win32?
>


Delete-on-close in Win32 is O/S based, not file-system based AFAIK.
And it's pretty buggy on older platforms.  I think what you're suggesting
could work fine for your case (and others like it) but I'm not sure I 
see a good general solution, unless someone's willing to write a file
system filter driver or something (yuck! ;-) ).


--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tar and open files
  2004-02-20 22:39 Steven Hartland
@ 2004-02-20 23:27 ` Igor Pechtchanski
  0 siblings, 0 replies; 9+ messages in thread
From: Igor Pechtchanski @ 2004-02-20 23:27 UTC (permalink / raw)
  To: Steven Hartland; +Cc: cygwin

On Fri, 20 Feb 2004, Steven Hartland wrote:

> Does anyone know of a way of getting round the file locking in win32 /
> cygwin so that in use files e.g. dll's can be replaced and next time the
> app restarts they are picked up?
>     Steve

Setup.exe uses the Windows "replace-on-reboot" feature for this.  If
you're interested in how this works, see the setup.exe sources or MSDN.
AFAIK, there's no other way to do a delayed replace of in-use files on
Windows, but I've been known to err...
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* tar and open files
@ 2004-02-20 22:39 Steven Hartland
  2004-02-20 23:27 ` Igor Pechtchanski
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Hartland @ 2004-02-20 22:39 UTC (permalink / raw)
  To: cygwin

Does anyone know of a way of getting round the file locking
in win32 / cygwin so that in use files e.g. dll's can be replaced
and next time the app restarts they are picked up?

    Steve

================================================
This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 

In the event of misdirection, illegible or incomplete transmission please telephone (023) 8024 3137
or return the E.mail to postmaster@multiplay.co.uk.



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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-02-21  3:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20 23:36 tar and open files DePriest, Jason R.
2004-02-20 23:55 ` Brian Dessent
2004-02-21  0:10   ` Christopher Faylor
2004-02-21  0:33   ` Steven Hartland
2004-02-21  2:49     ` Larry Hall
2004-02-21  3:17       ` Steven Hartland
2004-02-21  4:46         ` Larry Hall
  -- strict thread matches above, loose matches on Subject: below --
2004-02-20 22:39 Steven Hartland
2004-02-20 23:27 ` Igor Pechtchanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).