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: working sync() code


On Apr 10 16:26, Dmitry Karasik wrote:
> int 
> sync( char drive) 
> {
>    HANDLE f;
>    int ret;
>    char file[7] = "\\\\.\\X:";
>    file[5] = drive;
>    f = CreateFile( file, GENERIC_READ|GENERIC_WRITE,
> FILE_SHARE_READ|FILE_SHARE_WRITE, 
> 		  NULL, OPEN_EXISTING, 0, NULL);
>    if ((int) f < 0) 
>       return -1;
>    ret = FlushFileBuffers(f) ? 0 : -1;
>    CloseHandle(f);
>    return ret;
> }
> 
> And yes, it is working and doing actual sync of the corresponding file
> system,
> at least on my w2k machine.

How did you know?  Did you monitor cache activity somehow?

> but I think this may improve cygwin implementations of sync(), fsync(),
> and 
> probably msync().

fsync and msync are already implemented so that would only add a sync
implementation.  However, I'm not convinced that this improves Cygwin. 
Today's applications should not rely on sync actually guaranteeing
to sync disks (even Linux sync doesn't guarantee this) and it's generally
advisable to use fsync instead of sync anyway.

> PPS. If you'd prefer an actual patch instead of the vague code just tell
> me and 
> I'll resubmit.

A patch is usually the way to go.  But a patch of that size requires 
a copyright assignment.  See http://cygwin.com/contrib.html for details.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

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