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: Cannot write files if they are hidden


Joe Smith wrote:

> I seccond the motion that the windows hidden attribute be ignored. I suspect
> that nearly every user on the list has Explorer.exe set to show hidden
> files. Sice Cygwin is very useful for system administrators, and they almost
> always leave hidden files visable, it makes no sense to treat these files in
> any special way. (Assming that cygwin does).

Again, as Dave K has been trying to say, Cygwin is not treating the
Hidden attribute special in any way.  It asks Windows to open the file
and if it fails, it fails.  You can run strace and see.

In the case of "echo something > hiddenfile", this results in an open()
with the mode flags set to O_CREAT | O_TRUNC | O_WRONLY, which
translates to a call to NtCreateFile() in fhandler_base::open with
CreateDisposition set to FILE_OVERWRITE_IF, which returns an error code
of 0xC0000022.  This NT error status translates into win32 errno 5, or
"Access is denied."

In the case of "echo something >> hiddenfile", the call to open() has
flags O_CREAT | O_APPEND | O_WRONLY which translates into
CreateDisposition = FILE_OPEN_IF.  This succeeds with return value of 0.

So in other words, Windows is fine with opening the file for appending,
but not for replacing (truncating) it.  There is no special "treat +H
files weird" code in Cygwin.

Brian

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


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