delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/10/10:27:09

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
Message-ID: <4078041C.1020AC42@karasik.eu.org>
Date: Sat, 10 Apr 2004 16:26:36 +0200
From: Dmitry Karasik <dmitry AT karasik DOT eu DOT org>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: working sync() code

Hi all,

I found a way to issue an actual sync() on win32, and as browsing
through winsup directory gave me only this


winsup/sygwin/syscalls.cc #1128
extern "C" int
sync ()
{
   return 0;
}


I think cygwin DLL might benefit from a code I found by looking in
sync.exe by M.Russinovich, which is schematically as such:


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.

I do not know if there are any issues or why sync() wasn't implemented
yet
but I think this may improve cygwin implementations of sync(), fsync(),
and 
probably msync().

Cheers,
   Dmitry Karasik

PS. This message is probably better off to developers@ or patches@ or
whatever,
but I don't want to subscribe for sending this letter only.

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

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