![]()
[<<]Message[>>] [<<]Author[>>] [<<]Subject[>>] [<<]Thread[>>]
Number : 7988 Date : 2004-06-03 Author : Kan Yabumoto Subject : Re: switch for open files Size(KB) : 6
John: wrote: >--- In xxcopy@yahoogroups.com, Francis Leboutte >wrote: > > At 2/06/2004 19:31, John Zeman wrote: > > >--- In xxcopy@yahoogroups.com, "coonfatback" wrote: > > > > what switch do you use to copy any open files and which switch >is > > > > used to continue with errors? > > > > > > > > >There is no xxcopy switch to copy open files. If another program >has > > >a file open and locked, then it's off limits to any other program > > >including xxcopy. > > > > Is it really off limits of any program? I have heard some backup > > software are able to do this, like Backup Exec. > > > > Francis > > > >Kan would be much more qualified to answer this than I am, but in >general I believe it's basically true. I have heard of some programs >that can overcome the restriction for certain in use files, such as >xxclone, but for any given open file that was opened by any given >program it's been my experience that in general, it's a bad idea to >even try to copy such files until they've been closed. > >I recognize that I may have over simplified things when I made the >statement that no program could access a locked file, but I did so >because Brian only asked the simple question of how to copy open >files without giving any specific details. A simple question without >any details tends to evoke a simplified answer from me. > >John I think I wrote many messages on the topic of open files in the past. Let me go over this topic once again. Contrary to the popular belief, XXCOPY (and many other programs) can access and copy open files to somewhere else. But, in some cases, certain open files cannot be accessed. When a file is not opened by any program, it is free to be grabbed by any program. The ground rule is very simple --- first-come-first-served. The first program to access a file can make the call as to how the file will be shared by another program. The great majority of file accesses are read-only. In that case, the first program to access a file for read-only may declare the open file to be shared by others for share-for-read-purposes. This generally serves well. The OS would not grant the second program to open with the intention for write purposes, or to open for exclusive access (deny-access). But, one can write a program to open a file for exclusive access (no-sharing). In the case of XXCOPY, it allows for sharing with other programs in any access mode (read, write, read/write). On the other hand typical programs (or, quick-and-dirty programs) do not share access at all with other programs. Fortunately, most file accesses are quite short. Therefore, when XXCOPY tries to access a file and the OS denies the access to XXCOPY, all it can (has to) do is to wait a while and try again. In the great majority of cases, this works. There are two types in making a file-access exclusive to the program who opens a file. 1. Share control (as discussed above). The declaration is made when the file is being opened. 2. locking (explained below). This is done at any time while the file is opened. When a program which opens a file for a very long period of times, it may open the file with all modes of sharing (read, write, read/write). And, when a critical moment arrives (such as to update part of the big file), it temporarily locks a part or the whole file for exclusive access. This is how most database programs control its big file. In this case, again, XXCOPY can wait a while until the lock is removed. In either of the above cases (share control and lock control), a well-behaving program should allow other programs opportunities to access when it opens a file and keeps it open for an extended period. The programmer who write a program has the sole discretion of how it opens a file. After all, the programmer is in the position to make the decision. Other programs or the OS can speculate how it should be done. But, ultimately, each program as the discretion of how file sharing and locking is done. Some self-centered programs can make user's life miserable. The system registry files is a perfect example of this topic. In Windows, the operating system always opens the several system registry file for nearly the entire duration of Windows operations. In Win9X, the system apparently allows access to the system registry files by ordinary programs such as XXCOPY (locks the files from time to time when the files are being updated). This is why XXCOPY can duplicate the system registry files without much problem. On the other hand, in the NT-family Windows, the system takes no chances and does not allow access to the system registry file at all time. In neither case, Windows allows write-accesses to the system registry files at all. ------------------ Going back to the original question, the question should be rephrased. Can XXCOPY access a file that is exclusively opened by another program? Also, can XXCOPY access a file that is locked by another program? The answer to these question is still, Yes and No. XXCOPY can wait for the exclusionary period to end and access when the file becomes available. That is exactly how XXCOPY does it. The real question is can XXCOPY access a file that is semi-permanently opened exclusively by another program? The answer is NO. Unless the exclusionary condition remains in effect, no programs are allowed to access the file. This is the ground rule in multi-tasking environment. There are various techniques to circumvent such problems. One possible scenario is to interject a snooping module in the system which keeps eye on file open/close activities and always creates a temporary copy of the file for which a program request a file-open for its exclusive access. Another technique would schedule a file-copy operation at the next boot-up time. XXCOPY does not attempt any such operations. There is at least one commercial product which claims to provide access to exclusively-opened files: St.Bernard software's Open File Manager http://www.stbernard.com/products/ofm/products_ofm.asp I have never used it nor do I know anyone who successfully used this product. This is not an endorsement. I just want to show that there is a product who claims the capability. The best approach you can do with XXCOPY is to increase the retry period by /CR. The default timeout is set to 3 seconds (/CR3). Lastly, this is only what I know about the ground rule of file access and sharing. I might be wrong in believing that there is no straightforward technique to access a file that is exclusively opened or locked. Kan Yabumoto
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.