delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/10/18:39:11

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sat, 10 Apr 2004 22:30:26 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: working sync() code
Message-ID: <20040410203026.GR26558@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4078041C DOT 1020AC42 AT karasik DOT eu DOT org>
Mime-Version: 1.0
In-Reply-To: <4078041C.1020AC42@karasik.eu.org>
User-Agent: Mutt/1.4.2i

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 AT cygwin DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019