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: file accessibility and copying/archive/...

Hugh Sasse wrote:

> Trying to copy a windows XP NTFS drive to a big disk using cygwin tools
> I encounter inaccessible files such as ntusers.dat.  tar is not

ntuser.dat is the filename of the per-user registry hive
(HKEY_CURRENT_USER).  It is opened by the system in exclusive mode, so
it cannot be opened.

> I suspect this is a common problem, but don't know how to frame it
> correctly to extract something useful from Google.  The setup in
> question only has the one PC so things like rsync are out.  Windows

Note that rsync works just fine as a local copying tool like xcopy. 
There's nothing that says you have to use it with a remote machine.  But
it will be of no use to you in this case.

> keeps some things in use, but I don't know what.  Can anyone point
> me at the specific thing I should be reading, or suggest anything?
> If you mail me off list then, if there is interest I will summarize
> to the list.  Thank you.

You can't open the file because it's been opened with a sharing mode
that disallows any other process to open it.  The third parameter of
CreateFile() is dwShareMode and can one or more of FILE_SHARE_DELETE,
FILE_SHARE_READ, FILE_SHARE_WRITE.  If it is 0 then no sharing is
allowed, and the file cannot be opened by any other process until the
handle is closed.

This is why backup programs are more than just file copying utilities. 
There are a number of files that you can't just copy from a live
system.  Even if you could forcibly open the file, if you were to
naïvely copy it you might get inconsistent state, since the whole point
for opening a file exclusively is so that you can have full control over
it and implement your own form of transactions.

Starting with XP, Microsoft introduced the Volume Shadow Copy service,
as the other reply in this thread indicated.  This is a vastly
complicated[1] COM interface that can be used by backup programs to get
consistent state for all files on a live system.  Certainly no Cygwin
tool or app uses this API.

What I do is simply use the built in Windows backup program (ntbackup)
to create a backup to a file.  Ntbackup uses all the proper backup APIs
and can deal with all in-use files correctly, and the resulting output
is just a plain file that can be copied around with standard tools, or
split/burned to DVDR, or whatever.



Unsubscribe info:
Problem reports:

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